0

Im got error in section elseif, i want make HOD looking only at its own department data

public function index(User $user)
    {
        if(auth()->user()->role == 'Admin')
        {
            $form = Form::all();
        }
        elseif(auth()->user()->positions == 'HOD') 
        {
            $form = Form::all()->department('user_id', \Auth::user()->id)->get();
        }
        else
        {
            $form = Form::where('user_id', \Auth::user()->id)->get();
        }
    
        return view('form.index', ['list_form' => $form]);
    }

what should i change in elseif code ?

IT Newbie
  • 23
  • 8

1 Answers1

0

Try to do a dd() on auth()->user()->positions if it returns nothing, the relation between User model and Positions doesnt exist, or is set up wrong.

Musti
  • 470
  • 2
  • 11