-1
public function index()
{
    $product = new Product();
    $order = new Order();
    $user = new User();

    return view(view:'admin.dashboard',
                data:compact(var_name : 'product',  _ : 'order', 'user'));
}
Peppermintology
  • 9,343
  • 3
  • 27
  • 51
G-guy
  • 25
  • 1
  • 7
  • 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 Answers1

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
  • 5,457
  • 3
  • 26
  • 42