vendredi 30 juin 2017

How to add an sql function to a laravel eloquent model

I'm wanting to create a laravel model with a computed column. I've seen how to do this once the data is downloaded however the computation I wish to do is expensive but accessible as a function in my sql. Essentially I'd like to append one more column to the query builder but I'm unsure how to go about it.

The query needs to be something like:

select *, my_function(ID) as my_value from my_table;

I'm hoping to avoid multiple queries.

Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire