Questions tagged [laravel-events]

Laravel's events provides a simple observer implementation, allowing you to subscribe and listen for events in your application.

Laravel's events provides a simple observer implementation, allowing you to subscribe and listen for events in your application.

Event classes are typically stored in the app/Events directory, while their listeners are stored in app/Listeners.

114 questions
0
votes
2 answers

Laravel each() closure not executing

I am following a Laracast. (https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/28) I am trying to get one of my tests to pass. I have done a bit of debugging. In RecordActivity.php I currently have the following: …
Tom Morison
  • 564
  • 1
  • 8
  • 26
0
votes
2 answers

What is the best way to add the authenticated user to a related model?

What is the best way to add the authenticated user to a related model? If I wanted to add the authenticated user as the author on a post model whenever a new post is created, what would be the best way to do it? Currently, I have the following which…
Adnan
  • 3,129
  • 6
  • 31
  • 36
0
votes
1 answer

Removal of SerializesModels on Queued Event Listeners does not take effect when mocking on unit tests

I'm currently working with Laravel's Queued Event Listeners on an Eloquent model's saving event. On my event class, I have set up a public property that contains my model which I can then access inside the $event object within my listener via…
Dreadnaut
  • 107
  • 1
  • 10
0
votes
1 answer

Laravel - writing exception for schedule event in model listener

I've a Model Product that fires retrieved event ProductRetrieved and a listener CheckProductValidity that throws an exception depending on the API path (if-else condition). Also, I've a update query that I have implemented in Console\Kernal.php that…
abhig10
  • 535
  • 7
  • 24
0
votes
1 answer

Undefined variable: event error in AppServiceProvider

I'm trying to call some function after the a laravel job gets processed and i have my code just like the example on the Docs page, but i get undefined variable event error.
Seun Oyebode
  • 41
  • 1
  • 6
0
votes
2 answers

How to stop event faking (toggle event faking) in Laravel unit testing

I am developing a Laravel application and doing the unit test. Now, I am having a bit of an issue with faking and un-faking Laravel event in the unit test. What I am trying to do is something like this. public function test_something() { …
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
0
votes
1 answer

How i can use laravel Event Listner to send mail notification before an event

I am Trying to achieve a feature in my laravel Project. I am currently doing an Event related project. And there is Event start date and Event voting start date etc. The voting will be start at a date set on the database. How i can send a…
anoop
  • 1,604
  • 6
  • 24
  • 50
0
votes
0 answers

refresh a view from event in laravel

I need to waiting (listen) for a request from client trough API route, that will send me some text, when the request is received i need to confirm it to the client and send the text to a blade view not back to the client's api. I dont think that i…
JahStation
  • 893
  • 3
  • 15
  • 35
0
votes
0 answers

Laravel - updating client from long api call

I have a long PHP event script (~1 min long) that gets fired off from the front-end. In my script, I currently just echo to the console thats running the server, but I'd like to forward those echos to the client side as well. These echos are just to…
yeehuboi
  • 175
  • 1
  • 5
0
votes
1 answer

How to send data to laravel even from client using socket.io

I am trying to use socket.io. and want to send a variable from my javascript (client side) to laravel event and then pass it back to client. I commented in my code what I want. below is my code: Event:
Haren Sarma
  • 2,267
  • 6
  • 43
  • 72
0
votes
1 answer

Laravel Job not recognizing object property

I am passing a request to a job class to send an email for a contact form. The issue is that I cannot directly access the property. I set the $request in the constructor as $this->request = $request; In the handle() method, I do this: \Log::info(…
Dan
  • 919
  • 1
  • 10
  • 28
0
votes
1 answer

Laravel Event Not Triggering in Controller

I Create Transport Booking System in Laravel. When Customer Book a New Trip to Transport i calculate Commission Amount using Event (CalculateCustomerBookingolCharges). I try to book a new trip, all data's has been save but Commission Amount Not…
Karthik
  • 5,589
  • 18
  • 46
  • 78
0
votes
1 answer

post some event data in Laravel event handler

I made below code for save some data to user table when taken a logout event, and now need to save same data to "login_histories" table for recording user log histories, then how to modify this function handle in below code?…
JsWizard
  • 1,663
  • 3
  • 21
  • 48
0
votes
2 answers

Laravel Eloquent Events Implementation

I am updating my model instance or inserting a new one like this: $model = Model::updateOrCreate([id' => $request['id']], $model_to_update_array); I want to execute some code only when existing model instance ('tourist') was updated (and NOT when a…
Sergej Fomin
  • 1,822
  • 3
  • 24
  • 42
0
votes
3 answers

Laravel 5.4 Broadcast Error

I try to fire the event public function index() { event(new MessageSent("HELLO")); return view('home'); } and got this error in PusherBroadcaster.php (line 106) at PusherBroadcaster->broadcast(array(object(PrivateChannel)), …