moe-lk /
bulk-upload
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Models; |
||
| 4 | |||
| 5 | use Illuminate\Foundation\Auth\User as Authenticatable; |
||
| 6 | use Illuminate\Notifications\Notifiable; |
||
| 7 | use Laravel\Passport\HasApiTokens; |
||
| 8 | |||
| 9 | |||
| 10 | class User extends Authenticatable { |
||
| 11 | |||
| 12 | use HasApiTokens, Notifiable; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 13 | |||
| 14 | /** |
||
| 15 | * The database table used by the model. |
||
| 16 | * |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | protected $table = 'security_users'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Attributes that should be mass-assignable. |
||
| 23 | * |
||
| 24 | * @var array |
||
| 25 | */ |
||
| 26 | protected $fillable = [ |
||
| 27 | 'openemis_no', |
||
| 28 | 'first_name', |
||
| 29 | 'last_name', |
||
| 30 | 'address', |
||
| 31 | 'address_area_id', |
||
| 32 | 'birthplace_area_id', |
||
| 33 | 'gender_id', |
||
| 34 | 'date_of_birth', |
||
| 35 | 'nationality_id', |
||
| 36 | 'identity_type_id', |
||
| 37 | 'identity_number', |
||
| 38 | 'is_student', |
||
| 39 | 'modified_user_id', |
||
| 40 | 'modified', |
||
| 41 | 'created_user_id', |
||
| 42 | 'created', |
||
| 43 | 'username', |
||
| 44 | 'password', |
||
| 45 | 'remember_token' |
||
| 46 | ]; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * The attributes excluded from the model's JSON form. |
||
| 50 | * |
||
| 51 | * @var array |
||
| 52 | */ |
||
| 53 | protected $hidden = [ |
||
| 54 | 'password', 'remember_token', |
||
| 55 | ]; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * The attributes that should be casted to native types. |
||
| 59 | * |
||
| 60 | * @var array |
||
| 61 | */ |
||
| 62 | protected $casts = []; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * The attributes that should be mutated to dates. |
||
| 66 | * |
||
| 67 | * @var array |
||
| 68 | */ |
||
| 69 | protected $dates = ['email_verified_at']; |
||
| 70 | |||
| 71 | |||
| 72 | public function permissions(){ |
||
| 73 | return $this->hasMany('App\Models\Security_group_user','security_user_id','id') |
||
| 74 | ->where('security_group_users.security_role_id','=',5) |
||
| 75 | ->with(['security_group_institution','institution_staff','security_group' , 'staff_class','institution_group' , 'roles']); |
||
| 76 | } |
||
| 77 | |||
| 78 | public function principal(){ |
||
| 79 | return $this->hasMany('App\Models\Security_group_user','security_user_id','id') |
||
| 80 | ->where('security_group_users.security_role_id','=',4) |
||
| 81 | ->with(['security_group_institution','institution_staff','security_group' , 'staff_class','institution_group' , 'roles']); |
||
| 82 | } |
||
| 83 | |||
| 84 | public function zonal_cordinator(){ |
||
| 85 | return $this->hasMany('App\Models\Security_group_user','security_user_id','id') |
||
| 86 | ->where('security_group_users.security_role_id','=',3) |
||
| 87 | ->with(['security_group_institution','institution_staff','security_group' , 'staff_class','institution_group' , 'roles']); |
||
| 88 | } |
||
| 89 | |||
| 90 | |||
| 91 | public function institution_class_teacher(){ |
||
| 92 | return $this->hasMany('App\Models\Institution_staff','staff_id','id') |
||
| 93 | ->with(['staff_class']); |
||
| 94 | } |
||
| 95 | |||
| 96 | public function teacher_classes(){ |
||
| 97 | return $this->hasMany('App\Models\Institution_class','staff_id','id'); |
||
| 98 | } |
||
| 99 | |||
| 100 | public function findForPassport($username) { |
||
| 101 | return self::where('username', $username)->first(); // change column name whatever you use in credentials |
||
| 102 | } |
||
| 103 | } |
||
| 104 |