@willvincent
No, you're not missing anything here. Your code actually works. Thanks ;)
At the initial stage, I had
$order = auth()->user()->orders()->find($id);
if (! $order) return redirect('dashboard');
So that only user can access his/her invoice and redirect when is not. For example, www.domain.com/dashboard/1/invoice where 1 is the order_id.
And thereafter I add another relationship between Order & Invoice so I can access $order->invoice->whatever.
public function show ($id) {
$order = Order::with('invoice')->findOrFail($id);
return view('invoice', compact('order'));
}
Now with your code (yes, it's working), I need to redirect the user to /dashboard if the user try to access www.domain.com/dashboard/2/invoice where 2 is not his order_id.
At the moment, it just gives the error not 'redirecting'.