📜  $request laravel undefined inside function query - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:46.404000             🧑  作者: Mango

代码示例1
class BookController extends Controller
{
   public function bookIndex($id, $slug) {
   // echo $id works without a problem

   $findcover = Thing::with(array('cover' => function($query) use ($id) {
        $query->where('imageable_type', 'App\Models\Thing')
              ->where('imageable_id', $id);
        }))->find($id);

        $maincover = $findcover->cover;
   }