vendredi 24 juillet 2020

this is my code but my pagination is not working ..please guide me with similar solutions

public function index(Request $request) { if($_GET) { if(!empty($_GET['name'])&& (empty($_GET['email'])&&empty($_GET['phone']))) { $data = Users::where('name', $_GET['name'])->paginate(5); $links = $data->appends(['sort' => 'name'])->links(); return view('users.index', compact('data', 'links'));

        }
        else  if(!empty($_GET['email'])&&(empty($_GET['name'])&&empty($_GET['phone'])))
        {
            $data = Users::where('email', $_GET['email'])->paginate(5);
            $links = $data->appends(['sort' => 'email'])->links();
            return view('users.index', compact('data', 'links'));

        }
        else  if(!empty($_GET['phone'])&&(empty($_GET['name'])&&empty($_GET['email'])))
        {
            $data = Users::where('phone', $_GET['phone'])->paginate(5);
            $links = $data->appends(['sort' => 'phone'])->links();
            return view('users.index', compact('data', 'links'));

        }
        else  if(empty($_GET['phone'])&&(!empty($_GET['name']))&&(!empty($_GET['email'])))
        {
           // $data= DB::table('users')->where('name', $_GET['name'])->where('email', $_GET['email'])->get();
          //  $data = Users::where('name', $_GET['name'] )->where('email', $_GET['email'] );
            $data = Users::where('name', '=' ,$_GET['name'])->where('email', '=', $_GET['email'])->paginate(5);
             $links = $data->appends(['sort' => 'name'])->links();
            return view('users.index', compact('data', 'links'));

        }
        else  if(empty($_GET['email'])&&(!empty($_GET['name']))&&(!empty($_GET['phone'])))
        {

            $data = Users::where('name', '=' ,$_GET['name'])->where('phone', '=', $_GET['phone'])->paginate(5);
            $links = $data->appends(['sort' => 'name'])->links();
            return view('users.index', compact('data', 'links'));

        }
        else  if(empty($_GET['name'])&&(!empty($_GET['email']))&&(!empty($_GET['phone'])))
        {

            $data = Users::where('email', '=' ,$_GET['email'])->where('phone', '=', $_GET['phone'])->paginate(5);
            $links = $data->appends(['sort' => 'name'])->links();
            return view('users.index', compact('data', 'links'));

        }
        else  if(!empty($_GET['name'])&&(!empty($_GET['email']))&&(!empty($_GET['phone'])))
        {

            $data = Users::where('name', '=' ,$_GET['name'])->where('email', '=', $_GET['email'])->where('phone', '=', $_GET['phone'])->paginate(5);
            $links = $data->appends(['sort' => 'name'])->links();
            return view('users.index', compact('data', 'links'));

        }

   }

    else{
        $data = Users::orderBy('name', 'ASC')->paginate(5);
        //print_r($data);die();
        $links = $data->appends(['sort' => 'name'])->links();
        return view('users.index', compact('data', 'links'));

    }
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3hrvOtC
via IFTTT

Aucun commentaire:

Enregistrer un commentaire