Support the ongoing development of →
Database Eloquent Architecture
Last updated 2 years ago.

I think it should work like this:

$tags = Tag::where('name', 'LIKE', $query . '%')->select('name', 'value', 'id as tag_id')->get();

The select() method is the wrapper for normal SQL selects where you can choose the column so you can use the AS as an alias like in MySQL.


Thank you ftiersch. I feel like an idiot, I should have realized that.


Sign in to participate in this thread!


Your banner here too?

Yelldon yelldon Joined 2 Mar 2015


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

Your logo here?

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

© 2024 - All rights reserved.