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
46
votes
5 answers

Laravel check if updateOrCreate performed an update

I have the following code in my controller: for($i=0; $i<$number_of_tourists; $i++) { $tourist = Tourist::updateOrCreate([ 'doc_number' => $request['doc_number'][$I] ], $tourist_to_update); } Each time updateOrCreate runs, it…
Sergej Fomin
  • 1,822
  • 3
  • 24
  • 42
42
votes
10 answers

LogicException: Please make sure the PHP Redis extension is installed and enabled

Laravel Version: 7.5.0 PHP Version: 7.2 Database Driver & Version: Redis Everything was working fine but suddenly this error appear i changed the phpredis to predis but error is same. Steps To Reproduce: I am calling the event function event(new…
UMAIR ALI
  • 1,055
  • 5
  • 14
  • 25
14
votes
2 answers

Laravel Event listener and caching not working

I am facing some difficulties while developing an app on Laravel. I want to use Event and Listener to delete and rebuild the cache of an object. Here is the code: app\Events\CampaignEvent.php namespace App\Events; use…
9
votes
2 answers

Laravel Eloquent ORM - removing rows and all the child relationship, with event deleting

I have three models that relate to each other one to many: Country class Country extends Model { protected $fillable=['name','sort']; public $timestamps=false; public function region(){ return…
Kamol Hakimbaev
  • 143
  • 1
  • 1
  • 7
7
votes
1 answer

Laravel 5.8 : How to send email after user click verify link

I implemented auth system by php artisan make:auth and already setup user email verify by MustVerify from laravel feature I want to send another email (Greeting mail) after user click verify link. How can I do that?
Don Noinongyao
  • 175
  • 1
  • 9
7
votes
3 answers

Laravel Mailable queue, how to pass custom data to MessageSent event

I am using Laravel Mailable to send email, and I want to log the email that was successfully sent. Laravel Mailable have default event that was fired after the email was sent https://laravel.com/docs/5.6/mail#events So I hook my listener to this…
cyberfly
  • 5,568
  • 8
  • 50
  • 67
7
votes
5 answers

Laravel Broadcast - Combining multiple middleware (web, auth:api)

I am using Laravel Event Broadcast and Pusher to utilize websockets both on my API and Web. If I try them individually, both work fine. What I mean is: Broadcast::routes(['middleware' => 'web']); // this works for my Laravel…
senty
  • 12,385
  • 28
  • 130
  • 260
6
votes
2 answers

Laravel event dispatch assertion fails

I am writing some unit tests to test a database transaction middleware, on an exception everything within the transaction should do a rollback. And This piece of code works perfectly fine and passes the unit test: Unit test method that…
Stephan-v
  • 19,255
  • 31
  • 115
  • 201
5
votes
2 answers

Why is my event listener not firing in laravel 5?

So I am trying to log something simple when a new order is created in the laravel 5 application I am working on. So I have a OrderWasCreated event which looks like so:
Rohan
  • 13,308
  • 21
  • 81
  • 154
4
votes
2 answers

lararvel uuid as primary key

I'm trying to set an uuid as primary key in a Laravel Model. I've done it setting a boot method in my model as stablished here so I don't have to manually create it everytime I want to create and save the model. I have a controller that just creates…
Alberto
  • 1,348
  • 2
  • 14
  • 28
4
votes
1 answer

How to manually trigger Laravel model event

When no data is changed then laravel checks for isDirty and never executed the update query and hence model updated event is not fired. How can we manually trigger an event?
Jagadesha NH
  • 2,529
  • 2
  • 23
  • 41
4
votes
3 answers

How to test/assert if an event is broadcasted in Laravel

I am developing a Laravel application. I am using Laravel Broadcast in my application. What I am trying to do now is that I am trying to test if an event is broadcasted in Laravel. I am broadcasting an event like this: broadcast(new…
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
4
votes
0 answers

Laravel - Event Subscriber Enqueue - When Subscribers Methods are in different class

Hello Good Developers, I've tried using solution from This Question but it didn't solve my problem hence I am asking it as a separate question. TL;DR - I want my subscriber Listeners to get executed in a queue asynchronously. My Subscriber calls…
Pankaj Jha
  • 886
  • 15
  • 37
4
votes
1 answer

In Laravel, Where I should fire events and emails in repo or in controller?

I am using repository pattern in develop an application using laravel, my question is where I have to write code for fire events, send email or send an notification? and why?
4
votes
1 answer

Handling events only when model properties/columns are updated - Laravel Observer

I am dealing here with two events of a model, updating and updated as you can see in the below code. My concern is that I want to do some task in the updated event only if the teacherId has been changed, So I figured to check the value at the…
BlackBurn027
  • 592
  • 4
  • 20
1
2 3 4 5 6 7 8