Level 70
You forgot to import the Auth top of your class. It should be like this-
use Auth;
Here should be your updated code-
<?php
namespace App\Http\Controllers;
use Auth;
use Illuminate\Http\Request;
use App\Exceptions\InputException;
class OrderController extends Controller {
public function index(Request $request)
{
$user = Auth::user();
$productId = $request->route('productId');
$product = Product::where('id', $productId)->first();
return $product;
}
Now it should work fine.
8 likes