[ 'App\Listeners\EventListener', ], ]; /** * Register any other events for your application. * * @param \Illuminate\Contracts\Events\Dispatcher $events * @return void */ public function boot(DispatcherContract $events) { parent::boot($events); Property::saved(function ($property) { $property->attributes()->delete(); foreach ((array) Request::input('attr') as $key => $value) { $property->attributes()->save(new Attribute(['key' => $key, 'value' => $value])); } }); } }