50 lines
1.0 KiB
PHP
50 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class TeamMember extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public const ROLE_DRIVER = 'driver';
|
|
|
|
public const ROLE_HELPER = 'helper';
|
|
|
|
public const ROLE_SCANNER = 'scanner';
|
|
|
|
public const ROLE_LEAD = 'lead';
|
|
|
|
public const STATUS_PENDING = 'pending';
|
|
|
|
public const STATUS_ACCEPTED = 'accepted';
|
|
|
|
public const STATUS_REJECTED = 'rejected';
|
|
|
|
protected $fillable = [
|
|
'team_id', 'user_id', 'role_in_team',
|
|
'assigned_from', 'assigned_until', 'status',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'assigned_from' => 'date',
|
|
'assigned_until' => 'date',
|
|
];
|
|
}
|
|
|
|
public function team(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CollectionTeam::class, 'team_id');
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|