Laravel query builder: select all fields except a few

With Laravel's query builder, it's easy to select or alias using ->select()

.

How do I select all but a few fields?
For example, I don’t want to post id

my entry back to the interface.

+3


source to share


1 answer


http://laravel.com/docs/4.2/eloquent

If you don't mind still technically choosing them, you can suppress fields from the default Laravel / JSON array:



class User extends Eloquent {
    protected $hidden = ['password', 'id', ...];
}

      

+6


source







All Articles