暂无描述

User.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. use Illuminate\Auth\UserTrait;
  3. use Illuminate\Auth\UserInterface;
  4. use Illuminate\Auth\Reminders\RemindableTrait;
  5. use Illuminate\Auth\Reminders\RemindableInterface;
  6. use Zizaco\Entrust\HasRole;
  7. class User extends Eloquent implements UserInterface, RemindableInterface {
  8. use UserTrait, RemindableTrait, HasRole;
  9. /**
  10. * The database table used by the model.
  11. *
  12. * @var string
  13. */
  14. protected $table = 'users';
  15. /**
  16. * The attributes excluded from the model's JSON form.
  17. *
  18. * @var array
  19. */
  20. protected $hidden = array();
  21. /**
  22. * The attributes that can be massively assigned
  23. */
  24. protected $fillable = array('ssn', 'first_name', 'surnames', 'email', 'role', 'school_id', 'has_access', 'cell_phone', 'office_phone', 'office_extension');
  25. /**
  26. * Searchable rules.
  27. *
  28. * @var array
  29. */
  30. protected $searchable = [
  31. 'columns' => [
  32. 'first_name' => 10,
  33. 'surnames' => 10,
  34. 'email' => 2,
  35. ],
  36. ];
  37. public function program()
  38. {
  39. return $this->belongsTo('Program');
  40. }
  41. public function school()
  42. {
  43. return $this->belongsTo('School');
  44. }
  45. public function courses()
  46. {
  47. return $this->hasMany('Course')->whereIn('semester_id', Session::get('semesters_ids'))->orderBy('code')->orderBy('number')->orderBy('section')->orderBy('semester_id');
  48. }
  49. public function rubrics()
  50. {
  51. return $this->hasMany('Rubric')->orderBy('name');
  52. }
  53. // return the programs the user is a pcoord of
  54. public function programs()
  55. {
  56. return $this->belongsToMany('Program')->select('programs.id', 'programs.name', 'programs.school_id', 'programs.is_graduate');
  57. }
  58. }