34 lines
676 B
PHP
34 lines
676 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Domain\Trip\Policies;
|
||
|
|
|
||
|
|
use App\Models\User;
|
||
|
|
use App\Models\Trip;
|
||
|
|
|
||
|
|
class TripPolicy
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Determine if the user can view the trip
|
||
|
|
*/
|
||
|
|
public function view(User $user, Trip $trip): bool
|
||
|
|
{
|
||
|
|
return $trip->created_by_user_id === $user->id;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Determine if the user can update the trip
|
||
|
|
*/
|
||
|
|
public function update(User $user, Trip $trip): bool
|
||
|
|
{
|
||
|
|
return $trip->created_by_user_id === $user->id;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Determine if the user can delete the trip
|
||
|
|
*/
|
||
|
|
public function delete(User $user, Trip $trip): bool
|
||
|
|
{
|
||
|
|
return $trip->created_by_user_id === $user->id;
|
||
|
|
}
|
||
|
|
}
|