✨
Virtue
View on GitHub
  • ✨Virtue
  • 🚀GETTING STARTED
    • Installation
    • Changelog
  • 🛠️MODEL ATTRIBUTES
    • Configuration
    • Cast
    • Database
    • Dispatches Events
    • Fillable
    • Hidden
    • Primary Key
    • Relationships
  • 💻COMMAND ATTRIBUTES
    • Configuration
    • Defining Arguments
    • Defining Options
Powered by GitBook
On this page

Was this helpful?

  1. MODEL ATTRIBUTES

Dispatches Events

The DispatchesOn attribute allows you to set your Model's events to be dispatched in the same way that the $dispatchesEvents property does.

use App\Events\ProductCreated;
use App\Events\ProductDeleted;
use App\Events\ProductUpdated;
use Illuminate\Database\Eloquent\Model;
use WendellAdriel\Virtue\Models\Attributes\DispatchesOn;
use WendellAdriel\Virtue\Models\Concerns\Virtue;

#[DispatchesOn(event: 'created', class: ProductCreated::class)]
#[DispatchesOn(event: 'updated', class: ProductUpdated::class)]
#[DispatchesOn(event: 'deleted', class: ProductDeleted::class)]
final class Product extends Model
{
    use Virtue;
}
PreviousDatabaseNextFillable

Last updated 1 year ago

Was this helpful?

🛠️