-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adiciona segurança de acesso aos pets
- Loading branch information
Showing
4 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace App\Policies; | ||
|
||
use App\Models\Pet; | ||
use App\Models\User; | ||
use Illuminate\Auth\Access\Response; | ||
|
||
class PetPolicy | ||
{ | ||
/** | ||
* Determine whether the user can view any models. | ||
*/ | ||
public function viewAny(User $user): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Determine whether the user can view the model. | ||
*/ | ||
public function view(User $user, Pet $pet): bool | ||
{ | ||
return $pet->user->is($user); | ||
} | ||
|
||
/** | ||
* Determine whether the user can create models. | ||
*/ | ||
public function create(User $user): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Determine whether the user can update the model. | ||
*/ | ||
public function update(User $user, Pet $pet): bool | ||
{ | ||
return $pet->user->is($user); | ||
} | ||
|
||
/** | ||
* Determine whether the user can delete the model. | ||
*/ | ||
public function delete(User $user, Pet $pet): bool | ||
{ | ||
return $pet->user->is($user); | ||
} | ||
|
||
/** | ||
* Determine whether the user can restore the model. | ||
*/ | ||
public function restore(User $user, Pet $pet): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Determine whether the user can permanently delete the model. | ||
*/ | ||
public function forceDelete(User $user, Pet $pet): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters