Quick Fix on Laravel 5.4.9 on API Route
Update Migration, Model Factory and User
model as per above.
Run php artisan tinker
and create new user:
Psy Shell v0.8.1 (PHP 7.0.8 — cli) by Justin Hileman
>>> factory(App\User::class)->create();
=> App\User {#695
name: "Dr. Dewitt Rippin III",
email: "chaya.gerlach@example.org",
api_token: "z0DANKhTH7H4mIBPIZL1qyqQ3qJjmz9r3A4XOwqFRtrGyjM8XyM9ppqou0Lj",
updated_at: "2017-02-07 04:00:31",
created_at: "2017-02-07 04:00:31",
id: 1,
}
>>>
Now in Postman, use header Authorization
, value is Bearer [api_token]
. Then submit to http://localhost:8000/api/user
.
You should get current user logged in.