Enam
Enam

Reputation: 11

Nested If in laravel blade

My nested if not working properly. I wanted to first check a user is logged in or not, if logged in then I check the user id and the user id belongs to post is matched or not if matched then I want to show the link to edit or delete but, when I logged in I watched every post with edit/delete option. I marked with red color in picture

enter image description here

Upvotes: 1

Views: 1035

Answers (1)

Option
Option

Reputation: 2645

Add this to your controller:

public function __construct()
    {
        $this->middleware('auth');
    }

Then remove the if (Auth::check()) statement from the view.

Also, this needs to be changed:

if (Auth::user()->id == $variable ) not if (Auth::user()->id = $variable)

Upvotes: 1

Related Questions