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.

UpdateCompanyName.php 890B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Actions\FilamentCompanies;
  3. use App\Models\Company;
  4. use App\Models\User;
  5. use Illuminate\Auth\Access\AuthorizationException;
  6. use Illuminate\Support\Facades\Gate;
  7. use Illuminate\Support\Facades\Validator;
  8. use Wallo\FilamentCompanies\Contracts\UpdatesCompanyNames;
  9. class UpdateCompanyName implements UpdatesCompanyNames
  10. {
  11. /**
  12. * Validate and update the given company's name.
  13. *
  14. * @param array<string, string> $input
  15. *
  16. * @throws AuthorizationException
  17. */
  18. public function update(User $user, Company $company, array $input): void
  19. {
  20. Gate::forUser($user)->authorize('update', $company);
  21. Validator::make($input, [
  22. 'name' => ['required', 'string', 'max:255'],
  23. ])->validateWithBag('updateCompanyName');
  24. $company->forceFill([
  25. 'name' => $input['name'],
  26. ])->save();
  27. }
  28. }