name(), [new ResourceToolElement($this->toolComponent())]); $this->element = $this->data[0]; } /** * Get the displayable name of the resource tool. * * @return string */ public function name() { return $this->name ?: Str::title(Str::snake(class_basename(get_class($this)), ' ')); } /** * Get the component name for the resource tool. * * @return string */ public function toolComponent() { return $this->toolComponent ?? Str::kebab(class_basename(get_class($this))); } /** * Set the callback to be run to authorize viewing the card. * * @param \Closure(\Illuminate\Http\Request):bool $callback * @return $this */ public function canSee(Closure $callback) { $this->element->canSee($callback); return $this; } /** * Set additional meta information for the resource tool. * * @param array $meta * @return $this */ public function withMeta(array $meta) { $this->element->withMeta($meta); return $this; } /** * Dynamically proxy method calls to meta information. * * @param string $method * @param array $parameters * @return $this */ public function __call($method, $parameters) { return $this->withMeta([$method => ($parameters[0] ?? true)]); } }