Laravel 5模型事件不起作用(在生产中)

时间:2015-06-08 15:05:02

标签: php events laravel model laravel-5

我的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没有加载到制作中?

0 个答案:

没有答案