<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Employee extends Model
{
    use HasFactory, SoftDeletes;
    protected $fillable=['business_id','user_id','department_id','manager_id','employee_code','job_title','employment_type','hire_date','phone','work_location','status'];
    protected function casts():array{return ['hire_date'=>'date'];}
    public function business(){return $this->belongsTo(Business::class);}
    public function user(){return $this->belongsTo(User::class);}
    public function department(){return $this->belongsTo(Department::class);}
    public function manager(){return $this->belongsTo(self::class,'manager_id');}
    public function directReports(){return $this->hasMany(self::class,'manager_id');}
}
