When I\'m using eloquent, I can use the \"where\" method then the method \'get\' to fill an object containing what I\'ve selected in my database. I mean:
$us
I have a solution that worked for me, which is slightly different than those already stated.
$all_columns = Schema::getColumnListing('TABLE_NAME');
$exclude_columns = ['COLUMN_TO_EXCLUDE_1', 'COLUMN_TO_EXCLUDE_2'];
$get_columns = array_diff($all_columns, $exclude_columns);
return User::select($get_columns)->get();
For me:
BadMethodCallException with message 'Call to undefined method App/CaseStudy::exclude()'
So, in the end, I modified Razor's solution so that it would work without having to hide any of the columns for each method.
I hope this helps someone!
you can use hidden
array like this:
class Promotion extends Model
{
protected $table = 'promotion';
protected $hidden = array('id');
}