Skip to content

Commit

Permalink
Allow admins to create TAs for approved trips
Browse files Browse the repository at this point in the history
  • Loading branch information
kberzinch committed Mar 23, 2024
1 parent e8d67cf commit 59bb997
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/Nova/TravelAssignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Rules\MatrixItineraryDataStructure;
use App\Util\Matrix;
use Closure;
use Illuminate\Support\Facades\Auth;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\Code;
Expand Down Expand Up @@ -119,7 +120,7 @@ public function fields(NovaRequest $request): array
static function (string $attribute, mixed $value, Closure $fail): void {
$trip = \App\Models\Travel::where('id', '=', $value)->sole();

if ($trip->status !== 'draft') {
if ($trip->status !== 'draft' && ! Auth::user()->hasRole('admin')) {
$fail('Assignments cannot be created for this trip because it is not in draft status.');
}
}
Expand Down

0 comments on commit 59bb997

Please sign in to comment.