$model */ public function __construct(protected string $model) { parent::__construct('Update'.Str::pascal(class_basename($model))); } /** * Get the arguments for the create mutation. * * @return Argument[] */ public function arguments(): array { $arguments = []; $baseType = $this->baseType(); if ($baseType instanceof BaseType) { $arguments[] = $this->resolveBindArguments($baseType->fields()); $arguments[] = $this->resolveUpdateMutationArguments($baseType->fields()); } return Arr::flatten($arguments); } /** * The directives of the mutation. * * @return array */ public function directives(): array { return [ 'canModel' => [ 'ability' => 'update', 'injectArgs' => true, 'model' => $this->model, ], ...parent::directives(), ]; } /** * Get the rules for the create mutation. * * @param array $args * @return array */ public function rules(array $args): array { $baseType = $this->baseType(); if ($baseType instanceof BaseType) { return collect($baseType->fields()) ->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 getType(): Type { return Type::nonNull($this->baseType()); } }