dimanche 21 février 2016

Eloquent - Using manipulated column in selectRaw

I need an eloquent query in which I need to use a manipulated column alias in select raw, similar to this,

$this->selectRaw(<some_manipulation_on_cols> as col1)->selectRaw(case when col1=1 then 0 else 1 as col2)->get();

But, this errors out saying col1 doesn't exists. Is there a way achieving this without using subquery.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire