Reviewed-on: https://codeberg.org/lvl0/trip-planner/pulls/34 Co-authored-by: myrmidex <myrmidex@myrmidex.net> Co-committed-by: myrmidex <myrmidex@myrmidex.net>
34 lines
838 B
PHP
34 lines
838 B
PHP
<?php
|
|
|
|
namespace App\Domain\CalendarSlot\Policies;
|
|
|
|
use App\Models\User;
|
|
use App\Models\CalendarSlot;
|
|
use App\Models\Trip;
|
|
|
|
class CalendarSlotPolicy
|
|
{
|
|
/**
|
|
* Determine if the user can view calendar slots for the given trip
|
|
*/
|
|
public function viewAny(User $user, Trip $trip): bool
|
|
{
|
|
return $trip->created_by_user_id === $user->id;
|
|
}
|
|
|
|
/**
|
|
* Determine if the user can update the calendar slot
|
|
*/
|
|
public function update(User $user, CalendarSlot $calendarSlot): bool
|
|
{
|
|
return $calendarSlot->trip->created_by_user_id === $user->id;
|
|
}
|
|
|
|
/**
|
|
* Determine if the user can reorder items in the calendar slot
|
|
*/
|
|
public function reorder(User $user, CalendarSlot $calendarSlot): bool
|
|
{
|
|
return $calendarSlot->trip->created_by_user_id === $user->id;
|
|
}
|
|
}
|