lundi 19 octobre 2015

Laravel 5.1 event fire

I'm firing event and passing object with array like this:

$event = new App\Events\SendMessage;
$event->msg = [ 'sender_id'=>'191', 
                'recepient_id'=>'190',
                'text'=>'some text',
              ];
Event::fire($event);

Is it possible to make this call a bit shorter and fire event in one line like this?

Event::fire(new App\Events\SendMessage([
                        'sender_id'=>'191', 
                        'recepient_id'=>'190',
                        'text'=>'some text',
                    ]));



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire