first commit
This commit is contained in:
59
app/Models/Department.php
Normal file
59
app/Models/Department.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user