1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\Models;
- use App\Models\Scopes\CompanyScope;
- use EloquentFilter\Filterable;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- class Department extends Model
- {
- use HasFactory,Filterable;
- protected $table = 'department';
- protected $fillable = [
- 'name',
- 'parent_id',
- 'company_id',
- 'manager_id',
- ];
- protected static function booted()
- {
- parent::booted(); // TODO: Change the autogenerated stub
- static::addGlobalScope(new CompanyScope);
- }
- public function children()
- {
- return $this->hasMany(Department::class, 'parent_id');
- }
- }
|