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

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.

0

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

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Yelldon yelldon Joined 2 Mar 2015

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.