12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Repositories\Models\Base;
- use App\Repositories\Models\CourseCategory;
- use App\Repositories\Models\Model;
- use Prettus\Repository\Contracts\Transformable;
- use Prettus\Repository\Traits\TransformableTrait;
- /**
- * Class Department.
- *
- * @package namespace App\Repositories\Models;
- */
- class Department extends Model implements Transformable
- {
- use TransformableTrait;
- protected $table = 'base_departments';
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $fillable = ['name', 'parent_id', 'sort', 'status'];
- protected static function booted()
- {
- self::language();
- }
- public function parent()
- {
- return $this->belongsTo(Department::class, 'parent_id', 'id');
- }
- public function getParentNameAttribute()
- {
- return self::query()->where('id', $this->attributes['parent_id'])->value('name');
- }
- }
|