我的saving
EventServiceProvider.php
模型事件
<?php namespace App\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use App\UnprotectedLead;
class EventServiceProvider extends ServiceProvider {
/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [
'event.name' => [
'EventListener',
],
];
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
UnprotectedLead::saving(function($lead)
{
dd($lead->lead_phone);
$lead->lead_phone_clean = preg_replace('/[^0-9]/', '', $lead->lead_phone);
});
}
}
此代码在localhost上正常工作,但在生产保存事件中不起作用(我使用dd()在prod中检查它,但脚本没有死)
如何调试?也许EventServiceProvider.php
没有加载到制作中?