53 lines
1.3 KiB
PHP
Executable File
53 lines
1.3 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\Helpdesk\Models;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
final class Team extends Model
|
|
{
|
|
use HasFactory;
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'helpdesk_teams';
|
|
|
|
/** @var list<string> */
|
|
protected $fillable = ['name', 'slug', 'color', 'description', 'archived_at', 'is_default'];
|
|
|
|
/** @var array<string, string> */
|
|
protected $casts = [
|
|
'archived_at' => 'datetime',
|
|
'is_default' => 'boolean',
|
|
];
|
|
|
|
/** @return BelongsToMany<User, Team> */
|
|
public function users(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(
|
|
User::class,
|
|
'helpdesk_team_user',
|
|
'team_id',
|
|
'user_id'
|
|
)->withTimestamps();
|
|
}
|
|
|
|
/** @return HasMany<Project> */
|
|
public function projects(): HasMany
|
|
{
|
|
return $this->hasMany(Project::class, 'team_id');
|
|
}
|
|
|
|
/** @return HasMany<Ticket> */
|
|
public function tickets(): HasMany
|
|
{
|
|
return $this->hasMany(Ticket::class, 'team_id');
|
|
}
|
|
}
|