app/Http/Controllers/dashboard/students/StudentsProfileController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $student = Students::query()
            ->join('users', 'users.id', '=', 'students.user_id')
            ->where('students.user_id', auth()->user()->id)
            ->select('students.*',  'users.email')
            ->first();
        if (empty($student)) return redirect('form-students');
        if ($student->classroom_id) {
            $student->classroom = $student
                ->join('classrooms', 'classrooms.id', '=', 'students.classroom_id')
                ->join('grades', 'grades.id', '=', 'classrooms.grade_id')
                ->select('classrooms.name as classroom_name', 'grades.name AS grade_name',)
                ->where('students.user_id', auth()->user()->id)
                ->get()
                ->first();
        }
        return view('pages/dashboard/students.profile.index', array('title' => "Student Profile", 'student' => $student, 'notifications' => $this->notification));
    }
public function index ( ) { $ student = Students :: query ( ) -> join ( 'users' , 'users.id' , '=' , 'students.user_id' ) -> where ( 'students.user_id' , auth ( ) -> user ( ) -> id ) -> select ( 'students.*' , 'users.email' ) -> first ( ) ; if ( empty ( $ student ) ) return redirect ( 'form-students' ) ; if ( $ student -> classroom_id ) { $ student -> classroom = $ student -> join ( 'classrooms' , 'classrooms.id' , '=' , 'students.classroom_id' ) -> join ( 'grades' , 'grades.id' , '=' , 'classrooms.grade_id' ) -> select ( 'classrooms.name as classroom_name' , 'grades.name AS grade_name' , ) -> where ( 'students.user_id' , auth ( ) -> user ( ) -> id ) -> get ( ) -> first ( ) ; } return view ( 'pages/dashboard/students.profile.index' , array ( 'title' => " Student Profile " , 'student' => $ student , 'notifications' => $ this -> notification ) ) ; }
Display a listing of the resource.
Display a listing of the resource .