In my Laravel project, default User extend as follows :
class User extends Authenticatable{
use Notifiable;
protected $fillable = [
'id','name', 'email', 'password','type',
];
protected $hidden = [
'password', 'remember_token',
];
}
When I'm trying to get all registered users using this,
$user = User::all();
return $user;
[{"id":0,"name":"sdfsd","email":"[email protected]","type":"a","created_at":"2016-12-11 19:44:39","updated_at":"2016-12-11 19:44:39"},{"id":0,"name":"dcsdc","email":"[email protected]","type":"a","created_at":"2016-12-12 12:14:42","updated_at":"2016-12-12 12:14:42"}]
I got all the users but without their user ids.Id give as '0'.
And when I'm trying with 'where' constrain it gives a Exception.
So can I use User as a Eloquent model? How do I retrieve user table info in Laravel?
User::all()
but id shown as 0. I have checked db and they are not 0. And usingUser::where('id', "NPC0001")
I get error saying 'ErrorException in helpers.php line 519: htmlspecialchars() expects parameter 1 to be string' – Sathindu Kavneth