I'm working on a Laravel 5.5 app and in one of my models I have a mistener for when a new record is created. This listener is working normally in my local machine (I'm using XAMPP on Windows 10) but when I push it to the server the event does not trigger.
By reading similar questions I tried:
composer dumpautoload
php artisan clear-compiled
php artisan optimize
None of them worked. This is my model:
class ForumDiscussionMessage extends Model
{
use Notifiable;
protected $dispatchesEvents = [
'created' => ForumDiscussionMessageAdded::class,
];
// more code in here, not relevant
}
My /app/Events/ForumDiscussionMessageAdded.php
class ForumDiscussionMessageAdded
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
public function __construct($message)
{
$this->message = $message;
}
}
My app/Listeners/ForumMessageListener.php
class ForumMessageListener
{
public function __construct(){}
public function handle(ForumDiscussionMessageAdded $event)
{
$message = $event->message;
// logic from here on
}
}
Finally inside my app/Providers/EventServiceProvider.php
protected $listen = [
'App\Events\Event' => [
'App\Listeners\EventListener',
],
'App\Events\JobOfferSaved' => [
'App\Listeners\UpdateJobOfferRegionListener',
],
'App\Events\ForumDiscussionMessageAdded' => [
'App\Listeners\ForumMessageListener',
],
];
I'm not sure What is making it not work in the production server. In my local machines it does, no problem at all. The problem is when deploying it to the server
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire