Hemil
Hemil

Reputation: 247

How can I ignore some columns in eloquent Laravel

I Have 38 columns in one table, how can I ignore 3 of 38 columns while select query (Eloquent)?

Model::where('type',1)->select('id','title',..etc ....)->get();

the above select may lengthy, is there any solution to ignore the specific 3 and get all rest 35 from my table ?

Upvotes: 0

Views: 521

Answers (1)

Muhammad Dyas Yaskur
Muhammad Dyas Yaskur

Reputation: 8098

You can't create an exception in select query, but you can hide it using eloquent $hidden property. In example:

class User extends Model
{

    protected $hidden = [
        'created_at',
        'updated_at',
        'another_hidden_column',
    ];
 }

Upvotes: 1

Related Questions