You can pass some information using the query string. Query string is very useful for creating dynamic page. As you can see in the image given above, the Query string is a circle of red color. Page content will be changed as per the product ID provided.
Step 1
Goto App>confirg>Routes.php add the Routes rule
$routes->get('product/(:any)', 'Home::product/$1');
In this write product specified the Page URL and (:any) specified, any thing after product/ will be consider query string . Which is get by the Home Controller's product method . $1 denote only one argument will be pass.
Step 2 (Controller code)
public function product($arg)
{
$data['title']='Contact Us';
$data['arg']=$arg;
return view('product',$data);
}
Step 3 (View)
You can access query string on view by using $arg variable.
echo $arg;
No comments:
Post a Comment