2 years ago

How to Pass Function Name From Route Database Query

Posted 2 years ago by Kaustubh

My Page Table

    ID    |      Page     |    FunctionName    
     1    |     Home      |    home        
     2    |    Welcome    |    wel

Here What i want to achive ---------------->

If user click on link, a page id will pass in route.

e.g. localhost/test/public/page/1

I want to write query in web.php and want to pass $function in controller function. So $function will change everytime whenever there will be new page ID

Route (Web.php)

$function = DB::table('page')->where('id',$id)->pluck('FunctionName');

Route::get('/page/{id}',['uses' => '[email protected]'$function]);

Please sign in or create an account to participate in this conversation.