UserPolicy.php 486 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Policies;
  3. use App\Models\User;
  4. use Illuminate\Auth\Access\HandlesAuthorization;
  5. class UserPolicy
  6. {
  7. use HandlesAuthorization;
  8. /**
  9. * Create a new policy instance.
  10. *
  11. * @return void
  12. */
  13. public function __construct()
  14. {
  15. //
  16. }
  17. public function admin(User $user)
  18. {
  19. return $user->role->code === "admin";
  20. }
  21. public function user(User $user)
  22. {
  23. return $user->role->code === "user";
  24. }
  25. }