74 lines
1.5 KiB
PHP
74 lines
1.5 KiB
PHP
<?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 = [
|
|
'tenant_id',
|
|
'project_id',
|
|
'national_code',
|
|
'first_name',
|
|
'last_name',
|
|
'phone',
|
|
'job_title',
|
|
'contract_type',
|
|
'hire_date',
|
|
'termination_date',
|
|
'status',
|
|
'base_salary',
|
|
'currency_id',
|
|
'bank_account',
|
|
'notes',
|
|
];
|
|
|
|
protected $casts = [
|
|
'hire_date' => 'date',
|
|
'termination_date' => 'date',
|
|
'national_code' => 'encrypted',
|
|
'bank_account' => 'encrypted',
|
|
'base_salary' => 'encrypted',
|
|
];
|
|
|
|
public function tenant()
|
|
{
|
|
return $this->belongsTo(Tenant::class);
|
|
}
|
|
|
|
public function project()
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
public function currency()
|
|
{
|
|
return $this->belongsTo(Currency::class);
|
|
}
|
|
|
|
public function workLogs()
|
|
{
|
|
return $this->hasMany(WorkLog::class);
|
|
}
|
|
|
|
public function financials()
|
|
{
|
|
return $this->hasMany(EmployeeFinancial::class);
|
|
}
|
|
|
|
public function expenses()
|
|
{
|
|
return $this->hasMany(Expense::class, 'employee_id');
|
|
}
|
|
|
|
public function getFullNameAttribute()
|
|
{
|
|
return $this->first_name . ' ' . $this->last_name;
|
|
}
|
|
}
|