Próbuje zrobić nadawanie roli dla użytkowników, postępowałem jak w tutorialach pokazane było ale niestety natrafilem na taki błąd:
Call to undefined method Illuminate\Database\Schema\Blueprint::bool()
Komunikat ten pokazuje się, gdy chce zrobic migracje.
Model Role
<?php namespace App; use Illuminate\Database\Eloquent\Model; class Role extends Model { public function users() { return $this->belongsToMany('App\User', 'user_role', 'role_id', 'user_id'); } }
Model User:
<?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { public function roles() { return $this->belongsToMany('App\Role', 'user_role', 'user_id', 'role_id'); } use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'lastname', 'name', 'phonenumber', 'email', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; }
create_role_table
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateRolesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('roles', function (Blueprint $table) { $table->increments('id'); $table->string('name_role'); $table->string('description'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('roles'); } }
create_user_role_table
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUserRoleTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('user_role', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id'); $table->integer('role_id'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('user_role'); } }