您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CurrencyPolicy.php 1.4KB

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