Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
laragear-alerts-create-alert
laragear-alerts-create-alert
laragear/alerts
claude-code
alerts
blade
fluent-setters
artisan
translations
view-rendering

Generate new alert classes with Artisan, add fluent setter methods, define defaults, handle translations, or customize HTML rendering of an alert. Exclude pushing alerts to the session, rendering alerts in views, or sending alerts as Notifications (use laragear-alerts-push-alert, laragear-alerts-render-alert, laragear-alerts-notify-alert).

Install
php artisan boost:add-skill laragear/alerts

Save this content to: .claude/skills/create-alert/SKILL.md

# Create Alerts

Use when defining a new alert type, or changing how an existing alert class builds or renders its content.

## Generate the class

1. Run `php artisan alert:create MyAlert`.
2. This creates the class in `app/Views/Alerts/MyAlert.php` and its view in `resources/views/alerts/my-alert.blade.php`.

## Fluent setters

Expose attributes as fluent methods that call `$this->set()`. Always wrap translations inside a method, so call sites stay clean:

```php
public function type(string $type): static
{
    return $this->set('type', $type);
}

public function message(string $key, array $replace = []): static
{
    return $this->set('body', trans($key, $replace));
}
```

## Defaults

Override `getDefaults()` so every instance starts consistent:

```php
protected function getDefaults(): array
{
    return [
        'level' => 'info',
        'dismissible' => true,
    ];
}
```

## Rendering

`toHtml()` must always return the view with all attributes passed through — no manual HTML strings inside the class:

```php
public function toHtml(): mixed
{
    return view('alerts.my-alert', $this->all());
}
```

**Success check:** the alert renders without missing-variable errors when pushed and displayed in a Blade view containing `<x-alerts-container />`.

Create Alerts

Use when defining a new alert type, or changing how an existing alert class builds or renders its content.

Generate the class

  1. Run php artisan alert:create MyAlert.
  2. This creates the class in app/Views/Alerts/MyAlert.php and its view in resources/views/alerts/my-alert.blade.php.

Fluent setters

Expose attributes as fluent methods that call $this->set(). Always wrap translations inside a method, so call sites stay clean:

public function type(string $type): static
{
    return $this->set('type', $type);
}

public function message(string $key, array $replace = []): static
{
    return $this->set('body', trans($key, $replace));
}

Defaults

Override getDefaults() so every instance starts consistent:

protected function getDefaults(): array
{
    return [
        'level' => 'info',
        'dismissible' => true,
    ];
}

Rendering

toHtml() must always return the view with all attributes passed through — no manual HTML strings inside the class:

public function toHtml(): mixed
{
    return view('alerts.my-alert', $this->all());
}

Success check: the alert renders without missing-variable errors when pushed and displayed in a Blade view containing <x-alerts-container />.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle