dimanche 1 novembre 2015

Laravel 5 multiple select() in query builder

In laravel 5.1, I want to do like

$myTable = MyTable->select('firstField');

if ($somethingTrue) {
    $myTable->select('secondField');
}

$myTable->get();

where I want both firstField & secondField to be selected.
Of course the code above is not working, i.e. only the secondField is selected in the end.

Is there any function provided by query builder class that can do exactly what I want?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire