38 lines
914 B
PHP
38 lines
914 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
#[Fillable(['name', 'manager_id'])]
|
|
class Department extends Model
|
|
{
|
|
public function manager(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'manager_id');
|
|
}
|
|
|
|
public function members(): HasMany
|
|
{
|
|
return $this->hasMany(User::class);
|
|
}
|
|
|
|
public function feedbacks(): HasMany
|
|
{
|
|
return $this->hasMany(Feedback::class, 'current_department_id');
|
|
}
|
|
|
|
public function transferLogsFrom(): HasMany
|
|
{
|
|
return $this->hasMany(TicketTransferLog::class, 'from_department_id');
|
|
}
|
|
|
|
public function transferLogsTo(): HasMany
|
|
{
|
|
return $this->hasMany(TicketTransferLog::class, 'to_department_id');
|
|
}
|
|
}
|