1 回答
TA贡献1807条经验 获得超9个赞
Laravel 观察者只监视 Eloquent 事件,例如Model::create();
因此不会调度事件,因为您使用 DB Facade 直接插入值而不使用 Eloquent ORM
因此更改您的代码以使用 Eloquent
$property_id = $property->create([
'title' => $request->title,
'description' => $request->description,
'email' => $request->email,
'number' => $request->number,
'city' => $request->city,
'street' => $request->adresa,
'price' => $request->cena,
'quadrature' => $request->kvadratura,
'main_photo_id' => $main_photo_id,
'main_video_id' => $main_video_id,
'active' => 'Q',
'page_views' => '0',
'user_id' => Auth::user()->id,
'expires_on' => Carbon::now()->addDays(30),
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
])->id;
不要忘记在您的模型中
或仅在您的模型中使属性可填充App\Property
protected $guarded = []; // yolo
- 1 回答
- 0 关注
- 214 浏览
添加回答
举报