You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AccountPolicy.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Policies;
  3. use App\Models\Banking\Account;
  4. use App\Models\User;
  5. use Illuminate\Auth\Access\Response;
  6. class AccountPolicy
  7. {
  8. /**
  9. * Determine whether the user can view any models.
  10. */
  11. public function viewAny(User $user): bool
  12. {
  13. return true;
  14. }
  15. /**
  16. * Determine whether the user can view the model.
  17. */
  18. public function view(User $user, Account $account): bool
  19. {
  20. return $user->belongsToCompany($account->company);
  21. }
  22. /**
  23. * Determine whether the user can create models.
  24. */
  25. public function create(User $user): bool
  26. {
  27. return true;
  28. }
  29. /**
  30. * Determine whether the user can update the model.
  31. */
  32. public function update(User $user, Account $account): bool
  33. {
  34. return $user->ownsCompany($account->company);
  35. }
  36. /**
  37. * Determine whether the user can delete the model.
  38. */
  39. public function delete(User $user, Account $account): bool
  40. {
  41. return $user->ownsCompany($account->company);
  42. }
  43. /**
  44. * Determine whether the user can restore the model.
  45. */
  46. public function restore(User $user, Account $account): bool
  47. {
  48. return $user->ownsCompany($account->company);
  49. }
  50. /**
  51. * Determine whether the user can permanently delete the model.
  52. */
  53. public function forceDelete(User $user, Account $account): bool
  54. {
  55. return $user->ownsCompany($account->company);
  56. }
  57. }