Нет описания

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