Post::select(['id as the_id'])->first();
By doing so the result will be as follows.
App\Models\Post {#4736 the_id: 3, }
Learn how to rename / alias column name when querying with Laravel Eloquent
Created on Jul 10, 2021
•1065 views
Post::select(['id as the_id'])->first();
App\Models\Post {#4736 the_id: 3, }
If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️
Load comments for How to Alias Column Name in Laravel Eloquent
Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.
View Components2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago