pedi3/app/Actions/Jetstream/UpdateTeamName.php

31 lines
750 B
PHP
Raw Normal View History

2024-02-24 20:41:30 -03:00
<?php
namespace App\Actions\Jetstream;
use App\Models\Team;
use App\Models\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
use Laravel\Jetstream\Contracts\UpdatesTeamNames;
class UpdateTeamName implements UpdatesTeamNames
{
/**
* Validate and update the given team's name.
*
* @param array<string, string> $input
*/
public function update(User $user, Team $team, array $input): void
{
Gate::forUser($user)->authorize('update', $team);
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
])->validateWithBag('updateTeamName');
$team->forceFill([
'name' => $input['name'],
])->save();
}
}