所以由于某种原因,在我的本地机器上make()方法不起作用,这就是我想要做的
public function adunit($position)
{
$default_adunits = $this->defaultAdunits();
$adunit = Cache::remember("programs:{$this->program_id}:adunit:{$position}", 5, function() use ($position){
$pivot = DB::table('program_video_adunit')
->where('program_id', $this->program_id)
->where('position', $position)
->first();
return (! empty($pivot)) ? VideoAdunit::find($pivot->video_adunit_id) : null;
});
return $adunit ?? VideoAdunit::make(['link' => $default_adunits[$position], 'position' => $position]);
}
看起来你正在尝试创建新的VideoAdunit
。正确使用的方法是create
。据我所知,在Laravel QueryBuilder中没有定义make
。