PHP code example of binary-cats / fireable-attribute-events

1. Go to this page and download the library: Download binary-cats/fireable-attribute-events library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

binary-cats / fireable-attribute-events example snippets


use App\Events\OrderStatusChanged;
use App\Events\OrderMarkedHighPriority;
use App\Events\OrderMarkedUrgent;
use BinaryCats\FireableAttributeEvents\FireableAttributes;
use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    use FireableAttributes;

    protected array $fireableAttributes = [
        'status' => OrderStatusChanged::class,
        'priority' => [
            'high' => OrderMarkedHighPriority::class,
            'urgent' => \OrderMarkedUrgent::class,
        ],
    ];
}

$order = Order::find(1);

$order->update(['status' => 'shipped']); // 🚀 Fires OrderStatusChanged event
$order->update(['priority' => 'urgent']); // 🚀 Fires OrderMarkedUrgent event