Reputation: 59
I have create admin in laravel. so now i want to post as a admin to database but when i did i got error like above. i have a Post Table, I have admin id, I have admin table but it couldn't work. // To create post
$post = new Post;
$post->title = $request->input('title');
$post->body = $request->input('body');
$post->admin_id = Auth()->guard('admin')->id;
$post->save();
I did like this above but i got error. I also tried as
$post->admin_id = Auth()->admin()->id;
i got admin() not found. I did Everything as per instructions but i got error.
$post->user_id = Auth()->user()->id;
Whereas this works i don't know what to do. i did everything as per instructions in Github but I have a trouble here. Please help me Guard declaration:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'admin-api' => [
'driver' => 'token',
'provider' => 'admins',
],
],
Upvotes: 0
Views: 7503