public function index()
{
$product = new Product();
$order = new Order();
$user = new User();
return view(view:'admin.dashboard',
data:compact(var_name : 'product', _ : 'order', 'user'));
}
Asked
Active
Viewed 1,275 times
-2
Peppermintology
- 6,125
- 3
- 23
- 49
G-guy
- 3
- 4
-
What is you problem. Give us some errors to look at. – Jacob Brassington Jun 09 '21 at 14:31
-
Apparently named arguments (var_name, _) have to come *after* the unnamed/"positional" arguments. (See [example 16](https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments)) In this case, either use `var_name` for everything in `compact`, or don't use it at all. – aynber Jun 09 '21 at 14:33
1 Answers
0
There is no reason for named arguments:
public function index()
{
$product = new Product();
$order = new Order();
$user = new User();
return view('admin.dashboard', compact('product', 'order', 'user'));
}
shaedrich
- 4,826
- 2
- 26
- 35