Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CompanyPolicy.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Policies;
  3. use App\Models\Company;
  4. use App\Models\User;
  5. use Illuminate\Auth\Access\HandlesAuthorization;
  6. class CompanyPolicy
  7. {
  8. use HandlesAuthorization;
  9. /**
  10. * Determine whether the user can view any models.
  11. */
  12. public function viewAny(User $user): bool
  13. {
  14. return true;
  15. }
  16. /**
  17. * Determine whether the user can view the model.
  18. */
  19. public function view(User $user, Company $company): bool
  20. {
  21. return $user->belongsToCompany($company);
  22. }
  23. /**
  24. * Determine whether the user can create models.
  25. */
  26. public function create(User $user): bool
  27. {
  28. return true;
  29. }
  30. /**
  31. * Determine whether the user can update the model.
  32. */
  33. public function update(User $user, Company $company): bool
  34. {
  35. return $user->ownsCompany($company);
  36. }
  37. /**
  38. * Determine whether the user can add company employees.
  39. */
  40. public function addCompanyEmployee(User $user, Company $company): bool
  41. {
  42. return $user->ownsCompany($company);
  43. }
  44. /**
  45. * Determine whether the user can update company employee permissions.
  46. */
  47. public function updateCompanyEmployee(User $user, Company $company): bool
  48. {
  49. return $user->ownsCompany($company);
  50. }
  51. /**
  52. * Determine whether the user can remove company employees.
  53. */
  54. public function removeCompanyEmployee(User $user, Company $company): bool
  55. {
  56. return $user->ownsCompany($company);
  57. }
  58. /**
  59. * Determine whether the user can delete the model.
  60. */
  61. public function delete(User $user, Company $company): bool
  62. {
  63. return $user->ownsCompany($company);
  64. }
  65. }