You should use accessors to create calculated attributes on your model: http://laravel.com/docs/4.2/eloquent#accessors-and-mutators
You need to use the "raw" method on the DB facade.
use DB;
Model::select(DB::raw("IF(premium > 0, 'yes', 'no') as PremiumYesNo"))->get();
Model::addSelect(DB::raw('COUNT(*) as total'))->get();
Those should work for you.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community