syntax error, unexpected token "<" (View: /Users/pathparakh/Projects/store/resources/views/product.blade.php) in laravel?

Viewed 1235

There are an error showing when i add @if ({{Auth::user()->utype}} == "ADM") Line of code in product.blade.php.

</head>
@if ({{Auth::user()->utype}} == "ADM")

    <body>
        
    </body>

@endif

This is my controller named ProductController.

public function index()
{
    $products = Product::all();
    return view('product', compact('products'));
}

public function create()
{
    return view('product');
}

public function store(Request $request)
{
    $request->validate([
        'name' => 'required',
        'brand' => 'required',
        'detail' => 'required',
        'size' => 'required',
        'type' => 'required',
        'price' => 'required',
        'image' => 'required',
    ]);
    $image = $request->file('image');
    $new_name = rand().'.'.$image->getClientOriginalExtension();
    $image->move(public_path('images'), $new_name);
    $form_data = array(
        'image' => $new_name,
        'name' => $request->input('name'),
        'size' => $request->input('size'),
        'type' => $request->input('type'),
        'price' => $request->input('price'),
        'detail' => $request->input('detail'),
        'brand' => $request->input('brand'),
    );

    Product::create($form_data);
    return redirect()->route('product.index')->withSuccess('Done');
}

enter image description here Please help me to solve the mistake.

1 Answers

You are already using blade directive, so no need to put {{}}, inside @if or any other directive try this

@if (Auth::user()->utype == "ADM")

    <body>
        
    </body>

@endif
Related