skip to Main Content

How to pass action to Laravel 8 routes?

I was using following Route declaration to pass language action to the routes. Route::get('/de', ['uses' => 'PageController@showHomepage', 'language' => 'de']); And in controller, I was able to get this value like this: $action = $request->route()->getAction(); // $action['language'] gives the given…

VIEW QUESTION

Route model binding select specific columns with relation – Laravel

Route: Route::get('/posts/{post}', [PostController::class, 'show']); Controller: public function show(Post $post){ $postData = $post->load(['author' => function($query){ $query->select('post_id', 'name'); }]) ->get(['title', 'desc', 'created_date']) ->toArray(); } This returns all the posts in the database, While I only want to get the selected post passed…

VIEW QUESTION
Back To Top
Search