I get my $id from the url, but I could not find a way to use it in a function. How can I pass $ id to the request function?
I tried global $ id, but I still can't get the value, just a blank page.
My controller.
class BookController extends Controller { public function bookIndex($id, $slug) { // echo $id works without a problem $findcover = Thing::with(array('cover' => function($query) { $query->where('imageable_type', 'App\Models\Thing') ->where('imageable_id', $id); }))->find($id); $maincover = $findcover->cover; }
Error:
ErrorException in BookController.php line 49: Undefined variable: id
Line 49
->where('imageable_id', $id);
salep source share