vendredi 1 mars 2019

Why laravel query is not fetching right data?

I'm trying to get records having mode easy and advanced but it's returning only easy records each time. i.e Those records having mode set to easy.

Query string: mywebsite.com/game?easy=easy&advanced=advanced

public function index(Request $request) {

    if($request->has('easy') {
        return GameMode::where('mode', $request->easy)->get();
    }

    if($request->has('advanced') {
        return GameMode::where('mode', $request->advanced)->get();
    }

    return GameMode::all();
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire