$model */ public function __construct(protected string $model) { parent::__construct('Update'.Str::pascal(class_basename($model))); } public function authorize($root, array $args, $ctx, ?ResolveInfo $resolveInfo = null, ?Closure $getSelectFields = null): bool { return Gate::allows('update', [$this->model, $args]); } /** * Get the arguments for the create mutation. * * @return Argument[] */ public function arguments(): array { $arguments = []; $baseType = $this->baseRebingType(); if ($baseType instanceof BaseType) { $arguments[] = $this->resolveBindArguments($baseType->fieldClasses()); $arguments[] = $this->resolveUpdateMutationArguments($baseType->fieldClasses()); } return Arr::flatten($arguments); } /** * @param array $args * @return array */ public function rulesForValidation(array $args = []): array { $baseType = $this->baseRebingType(); if ($baseType instanceof BaseType) { return collect($baseType->fieldClasses()) ->filter(fn (Field $field) => $field instanceof UpdatableField) ->mapWithKeys(fn (Field&UpdatableField $field) => [$field->getColumn() => $field->getUpdateRules($args)]) ->toArray(); } return []; } /** * The type returned by the field. */ public function type(): Type { return Type::nonNull($this->baseType()); } }