<?php
// Department Model
namespace App\Models;
use Illuminate\Database\Eloquent\Model;

class Department extends Model {
    protected $fillable = ['name','code','type','parent_id','head_user_id','location','description','is_active'];
    public function head()      { return $this->belongsTo(User::class, 'head_user_id'); }
    public function parent()    { return $this->belongsTo(Department::class, 'parent_id'); }
    public function children()  { return $this->hasMany(Department::class, 'parent_id'); }
    public function employees() { return $this->hasMany(Employee::class); }
    public function users()     { return $this->hasMany(User::class); }
}
