testapi/app/Models/Department.php

28 lines
576 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Department extends Model
{
use HasFactory;
protected $fillable = [
'name',
];
/**
* The projects that belong to the department.
*/
public function projects(): BelongsToMany {
return $this->belongsToMany(
Project::class,
'department_project',
'department_id',
'project_id'
);
}
}