Files
econom/app/Models/Department.php
brusnitsyn fb2e6c58e3
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled
first commit
2026-04-06 00:06:00 +09:00

60 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use Database\Factories\DepartmentFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['name', 'is_active', 'department_profile_id'])]
class Department extends Model
{
/** @use HasFactory<DepartmentFactory> */
use HasFactory;
/**
* Get the profile that the department belongs to.
*
* @return BelongsTo<DepartmentProfile, $this>
*/
public function departmentProfile(): BelongsTo
{
return $this->belongsTo(DepartmentProfile::class);
}
/**
* Get the services provided by the department.
*
* @return HasMany<ServiceEntry, $this>
*/
public function providedServiceEntries(): HasMany
{
return $this->hasMany(ServiceEntry::class, 'provider_department_id');
}
/**
* Get the services received by the department.
*
* @return HasMany<ServiceEntry, $this>
*/
public function receivedServiceEntries(): HasMany
{
return $this->hasMany(ServiceEntry::class, 'recipient_department_id');
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'is_active' => 'boolean',
];
}
}