trucks (with optional last_known_coordinates POINT 4326), collection_teams, team_members. Admin CRUD for both. TeamConflictDetector flags double-assignment of driver/scanner/truck/helper across active teams; override_conflicts: true bypasses for emergencies. Promotes routes.default_team_id to a real FK now that collection_teams exists. 144 feature tests passing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
896 B
PHP
41 lines
896 B
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';
|
|
|
|
protected $fillable = [
|
|
'team_id', 'user_id', 'role_in_team',
|
|
'assigned_from', 'assigned_until',
|
|
];
|
|
|
|
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);
|
|
}
|
|
}
|