I\'m using view composers in Laravel 5.1: nice. But how can I pass parameters to a view composer?
In my case I send week info (previous, current, next week, inc
All the data you pass to your view in the controller will be available in the view controller. Use the getData
method on the view instance like this:
$view->getData()["current_week"];
In your particular case, you can do this:
public function compose(View $view)
{
$current_week = $view->getData()["current_week"];
//use $current_week as desired
}
You can also get the data in the route (route parameters) from the request like this:
request()->route()->getParameter('week_number');