I want to get all the columns from the products table and apply sql case on pick_8 and pick_12 columns only but to do this i have to write all the column names in select. Is there any way in laravel where i can apply the simple get() method to retrieve all the columns with applying case on only 2, without having to write all the column names manually.
$products = Product::where('is_archive',0)->select('humanId','name','cost','retailPrice','memberPrice','points',
DB::raw('(CASE WHEN pick_8 = 1 THEN "True" ELSE "False" END) AS pick_8'),
DB::raw('(CASE WHEN pick_12 = 1 THEN "True" ELSE "False" END) AS pick_12'))->get()->toArray();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire