I got this ERROR in LARAVEL 5.1 while using Entrust Package.
After autoload in command line, I got this error
C:\xampp1\htdocs\project>composer dump-autoload Generating autoload files
C:\xampp1\htdocs\project>php artisan db:seed --class=RolesTableSeeder
[ErrorException] Argument 1 passed to Zizaco\Entrust\Middleware\EntrustRole::__construct() must be an instance of Illuminate\Contracts\Auth \Guard,
I'm very new to LARAVEL, Please anyone Help me.....
//////////////// Role Migration Class ////////////////////////
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class EntrustSetupTables extends Migration
{
public function up()
{
// Create table for storing roles
Schema::create('roles', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->string('display_name')->nullable();
$table->string('description')->nullable();
$table->timestamps();
});
}
public function down()
{
Schema::drop('roles');
}
}
?>
/////////////////// Role Model //////////////////////////////////
<?php
namespace App;
use Zizaco\Entrust\Middleware\EntrustRole;
use Zizaco\Entrust\Traits\EntrustUserTrait;
class Role extends EntrustRole
{
use EntrustUserTrait;
protected $fillable = ['name', 'display_name', 'description'];
}
?>
//////////////////// RolesTableSeeder ///////////////////////////
<?php
use App\Role;
use Illuminate\Database\Seeder;
use Zizaco\Entrust\Middleware;
class RolesTableSeeder extends Seeder
{
public function run()
{
$owner = new Role();
$owner->name = 'owner';
$owner->display_name = 'Project Owner'; // optional
$owner->description = 'User is the owner of a given project'; // optional
$owner->save();
$admin = new Role();
$admin->name = 'admin';
$admin->display_name = 'User Administrator'; // optional
$admin->description = 'User is allowed to manage and edit other users'; // optional
$admin->save();
}
}
?>
/////////////////////////// .env file //////////////////////////////
DB_HOST=localhost
DB_DATABASE=project_api
DB_USERNAME=root
DB_PASSWORD=
CACHE_DRIVER=array
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire