initial
This commit is contained in:
71
app/Models/TravelRequest.php
Normal file
71
app/Models/TravelRequest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\EventType;
|
||||
use App\Enums\GeneralType;
|
||||
use App\Enums\TravelStatus;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class TravelRequest extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\TravelRequestFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'workflow_id',
|
||||
'status',
|
||||
'reason_summary',
|
||||
'event_type',
|
||||
'general_type',
|
||||
'needs_accommodation',
|
||||
'needs_car_hire',
|
||||
'vehicle_policy_acknowledged',
|
||||
'business_days',
|
||||
'private_days',
|
||||
'additional_notes',
|
||||
'submitted_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => TravelStatus::class,
|
||||
'event_type' => EventType::class,
|
||||
'general_type' => GeneralType::class,
|
||||
'needs_accommodation' => 'boolean',
|
||||
'needs_car_hire' => 'boolean',
|
||||
'vehicle_policy_acknowledged' => 'boolean',
|
||||
'submitted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function workflow(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ApprovalWorkflow::class, 'workflow_id');
|
||||
}
|
||||
|
||||
public function journeys(): HasMany
|
||||
{
|
||||
return $this->hasMany(TravelJourney::class);
|
||||
}
|
||||
|
||||
public function costCodes(): HasMany
|
||||
{
|
||||
return $this->hasMany(TravelCostCode::class);
|
||||
}
|
||||
|
||||
public function approvals(): HasMany
|
||||
{
|
||||
return $this->hasMany(TravelRequestApproval::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user