testapi/app/Models/Project.php

49 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Project extends Model
{
use HasFactory;
protected $fillable = [
'project_name',
'project_number',
];
/**
* The profiles associated with this project.
*/
public function profiles(): BelongsToMany {
return $this->belongsToMany(
SmartdokProfile::class,
'project_smartdok_profile',
'project_id',
'smartdok_profile_id'
);
}
/**
* The departments associated with this project.
*/
public function departments(): BelongsToMany {
return $this->belongsToMany(
Department::class,
'department_project',
'project_id',
'department_id'
);
}
/**
* The work hours entries linked to this project.
*/
public function workHours(): HasMany {
return $this->hasMany(WorkHour::class, 'project_id');
}
}