Pretend login user
Auth::loginUsingId(x);
Hook event in Model
Class Document extend Eloquent
{
public static functio boot(){
parent::boot();
static::updating(function($document)){
//do something
}
}
}
Pivot Model method withTimestamps and withPivot
public function adjustments(){
return $this->belongWithMany(User::class, 'adjustments')
->withTimestamps()
->withPivot(['before','after'])
->latest('pivot_updated_at']);
}
沒有留言:
張貼留言