Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0

Hi Pushkar.

You could use the raw method of the DB class to do that.

$result = Model::find(1)
->select('column1', 'column2', DB:raw('yourFunction(id) as alias'))
->where('column3', '>', 100)
->get();

Last updated 2 years ago.
0

Its not working ,

I have try to run it like this

->select("tw.*","tt.first_name","tt.last_name",DB:raw('time_format("tw.time","%r") as smstime'))

then php shows error

Last updated 2 years ago.
0

Use DB::raw() as PHP's static method call style. It works sweet.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.