app/Http/Controllers/Admin/TutorsController.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()
    {
        $t_name = isset($_GET['t_name']) ? trim($_GET['t_name']) : "";
        $email = isset($_GET['email']) ? trim($_GET['email']) : "";
        $status = isset($_GET['status']) ? trim($_GET['status']) : "";
        $approved = isset($_GET['approved']) ? trim($_GET['approved']) : "";
        $t_date = isset($_GET['t_date']) ? trim($_GET['t_date']) : "";
        $q = "1=1 ";
        if ($email) {
            $q.= " and email like '%".$email."%'";
        }
        if ($status) {
            if ($status == "Enabled")
                $q.= " and status like 1";
            else
            {
                $q.= " and (status is NULL or 0)";
            }
        }
        if ($approved) {
            if ($approved == "Yes")
                $q.= " and approved like 1";
            else
                $q.= " and (approved is NULL or 0)";
        }
        if ($t_date) {
            $q.= " and created_at like '%".$t_date."%'";
        }
        if ($t_name) {
            $q.= " and (fname like '%".$t_name."%' or lname like '%" .$t_name . "%') ";
        }
        $tutors = Role::find(config('global.TUTOR_ROLE_ID'))->users()
        ->whereRaw($q)->get();
        $data = [
            'tutors' => $tutors,
            'old' => [
                't_name' => $t_name,
                'email' => $email,
                'status' => $status,
                'approved' => $approved,
                't_date' => $t_date,
                ]
        ];
        session()->flash('error', null);
        if (count($tutors) == 0) {
            session()->flash('error', "No search results!");
            return view('admin.tutors.index')->with('data', $data);
        }
        return view('admin.tutors.index')->with('data', $data);
    }
public function index ( ) { $ t_name = isset ( $ _GET [ 't_name' ] ) ? trim ( $ _GET [ 't_name' ] ) : " " ; $ email = isset ( $ _GET [ 'email' ] ) ? trim ( $ _GET [ 'email' ] ) : " " ; $ status = isset ( $ _GET [ 'status' ] ) ? trim ( $ _GET [ 'status' ] ) : " " ; $ approved = isset ( $ _GET [ 'approved' ] ) ? trim ( $ _GET [ 'approved' ] ) : " " ; $ t_date = isset ( $ _GET [ 't_date' ] ) ? trim ( $ _GET [ 't_date' ] ) : " " ; $ q = " 1=1  " ; if ( $ email ) { $ q .= "  and email like '% " . $ email . " %' " ; } if ( $ status ) { if ( $ status == " Enabled " ) $ q .= "  and status like 1 " ; else { $ q .= "  and (status is NULL or 0) " ; } } if ( $ approved ) { if ( $ approved == " Yes " ) $ q .= "  and approved like 1 " ; else $ q .= "  and (approved is NULL or 0) " ; } if ( $ t_date ) { $ q .= "  and created_at like '% " . $ t_date . " %' " ; } if ( $ t_name ) { $ q .= "  and (fname like '% " . $ t_name . " %' or lname like '% " . $ t_name . " %')  " ; } $ tutors = Role :: find ( config ( 'global.TUTOR_ROLE_ID' ) ) -> users ( ) -> whereRaw ( $ q ) -> get ( ) ; $ data = [ 'tutors' => $ tutors , 'old' => [ 't_name' => $ t_name , 'email' => $ email , 'status' => $ status , 'approved' => $ approved , 't_date' => $ t_date , ] ] ; session ( ) -> flash ( 'error' , null ) ; if ( count ( $ tutors ) == 0 ) { session ( ) -> flash ( 'error' , " No search results! " ) ; return view ( 'admin.tutors.index' ) -> with ( 'data' , $ data ) ; } return view ( 'admin.tutors.index' ) -> with ( 'data' , $ data ) ; }
Display a listing of the resource.
Display a listing of the resource .
//$q = "1=1  and (approved is NULL or 0) and (fname like '%learnon%' or lname like '%learnon%')";