validate($project, $input); $project->name = $input['name']; $project->save(); return $project; } public static function rules(Project $project): array { return [ 'name' => [ 'required', 'string', 'max:255', Rule::unique('projects', 'name')->ignore($project->id), 'lowercase:projects,name', ], ]; } private function validate(Project $project, array $input): void { Validator::make($input, self::rules($project))->validate(); } }