base commit
This commit is contained in:
105
app/Models/Employee.php
Normal file
105
app/Models/Employee.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\EmploymentStatus;
|
||||
use App\Enums\Gender;
|
||||
use App\Models\Concerns\LogsHrActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Employee extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use LogsHrActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_number',
|
||||
'full_name',
|
||||
'national_id',
|
||||
'gender',
|
||||
'birth_date',
|
||||
'phone',
|
||||
'address',
|
||||
'department_id',
|
||||
'position_id',
|
||||
'shift_id',
|
||||
'employment_status',
|
||||
'hire_date',
|
||||
'termination_date',
|
||||
'notes',
|
||||
'profile_photo_path',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'gender' => Gender::class,
|
||||
'birth_date' => 'date',
|
||||
'employment_status' => EmploymentStatus::class,
|
||||
'hire_date' => 'date',
|
||||
'termination_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function position(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Position::class);
|
||||
}
|
||||
|
||||
public function shift(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Shift::class);
|
||||
}
|
||||
|
||||
public function vacations(): HasMany
|
||||
{
|
||||
return $this->hasMany(Vacation::class);
|
||||
}
|
||||
|
||||
public function sickLeaves(): HasMany
|
||||
{
|
||||
return $this->hasMany(SickLeave::class);
|
||||
}
|
||||
|
||||
public function unpaidLeaves(): HasMany
|
||||
{
|
||||
return $this->hasMany(UnpaidLeave::class);
|
||||
}
|
||||
|
||||
public function disciplinaryReports(): HasMany
|
||||
{
|
||||
return $this->hasMany(DisciplinaryReport::class);
|
||||
}
|
||||
|
||||
public function explanations(): HasMany
|
||||
{
|
||||
return $this->hasMany(Explanation::class);
|
||||
}
|
||||
|
||||
public function bonuses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Bonus::class);
|
||||
}
|
||||
|
||||
public function gifts(): HasMany
|
||||
{
|
||||
return $this->hasMany(Gift::class);
|
||||
}
|
||||
|
||||
public function documents(): HasMany
|
||||
{
|
||||
return $this->hasMany(EmployeeDocument::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user