I try to get laravel-blog running on an already existing laravel project.
Everything seems fine except of the auth part.
I'm logged in as admin but "\Auth::check()" in "UserCanManageBlogPosts" results in "error evaluating code" when debugging.
I changed '_usermodel' to \App\Admin::class which is my user/admin model.
This is how my model looks like:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Admin extends Authenticatable
{
use Notifiable;
// The authentication guard for admin
protected $guard = 'admin';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'username', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* Enter your own logic (e.g. if ($this->id === 1) to
* enable this user to be able to add/edit blog posts
*
* @return bool - true = they can edit / manage blog posts,
* false = they have no access to the blog admin panel
*/
public function canManageBinshopsBlogPosts()
{
// Enter the logic needed for your app.
// Maybe you can just hardcode in a user id that you
// know is always an admin ID?
if($this->username === "testadmin")
{
// return true so this user CAN edit/post/delete
// blog posts (and post any HTML/JS)
return true;
}
// otherwise return false, so they have no access
// to the admin panel (but can still view posts)
return false;
}
}
I tried to add "use Illuminate\Support\Facades\Auth;" to "UserCanManageBlogPosts" and changed "\Auth::check()" to "Auth::check()" which doesn't result in an error anymore, but that for in a false, although I'm logged in as admin.
I'm not sure how to get the auth running correctly here, what could be the problem and what could solve it?
I try to get laravel-blog running on an already existing laravel project.
Everything seems fine except of the auth part. I'm logged in as admin but "\Auth::check()" in "UserCanManageBlogPosts" results in "error evaluating code" when debugging.
I changed '_usermodel' to \App\Admin::class which is my user/admin model. This is how my model looks like:
I tried to add "use Illuminate\Support\Facades\Auth;" to "UserCanManageBlogPosts" and changed "\Auth::check()" to "Auth::check()" which doesn't result in an error anymore, but that for in a false, although I'm logged in as admin.
I'm not sure how to get the auth running correctly here, what could be the problem and what could solve it?