12345678910111213141516171819202122232425 |
- <?php
-
- namespace App;
-
- use Illuminate\Database\Eloquent\Model;
-
- class Permission extends Model
- {
- public $timestamps = false;
-
- protected $fillable = [
- 'user_id',
- 'level',
- 'division_id'
- ];
-
- public function division() {
- if ($this->level === 1) {
- return $this->belongsTo(Department::class, 'division_id');
- } else if ($this->level === 2) {
- return $this->belongsTo(Faculty::class, 'division_id');
- }
- return null;
- }
- }
|