Jason Miller
2 years ago

#laravel

Do you know how to show hidden model field just for specific query request? Do you know about makeVisible() method?
Checkout this #laraveltip

                    class User extends Model
{
// in our User model we are hiding id 
protected $hidden=['id'];

}

// select all users
$user = new User();
$users = $user->all();

// show id for this query
$users->makeVisible(['id']);

return $users; // will contain id