DurgeshJha
2 years ago

unable to pass the Auth_> id in each view page

Posted 2 years ago by DurgeshJha

I want to pass the data from task table with reference to user id from the user table in the navigation view for each time the y load.

when i try this code from task controller then its working public function index() { //show task //$tasks = Task::all(); $id= Auth::id(); $users = DB::table('students')->where('id', $id)->get(); $tasks = DB::table('tasks')->where('student_id', $id)->get(); $counts =DB::table('tasks')->where('student_id', $id)->count(); return view('studentzone.homework.index', compact('users','tasks','counts')); } but when i click on another link from the navigation menu, error says undefined variable.

pls help

Please sign in or create an account to participate in this conversation.