Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

UpdateCompanyName.php 848B

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