小编ton*_*ics的帖子

Laravel Eager Load具有动态约束

任何人都可以帮助我理解为什么以下代码工作

$x = $widget->objGallery->galleryItems()->with(array('captions' => function($query){ $query->where('locale', 'IT' );}))->get() ;
Run Code Online (Sandbox Code Playgroud)

但是当我使用动态值时

$id='11';
$x = $widget->objGallery->galleryItems()->with(array('captions' => function($query){ $query->where('locale', $id );}))->get() ;
Run Code Online (Sandbox Code Playgroud)

在说

方法Illuminate\View\View :: __ toString()不得抛出异常

php closures anonymous-function eager-loading laravel

1
推荐指数
1
解决办法
1650
查看次数