Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Laravel 5.4 Nadawanie roli dla użytkowników, Nadawanie roli dla użytkowników - Fatal Error
K3n0
post
Post #1





Grupa: Zarejestrowani
Postów: 46
Pomógł: 0
Dołączył: 3.05.2016

Ostrzeżenie: (0%)
-----


Witam,
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
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4.  
  5. class Role extends Model
  6. {
  7. public function users()
  8. {
  9. return $this->belongsToMany('App\User', 'user_role', 'role_id', 'user_id');
  10. }
  11. }

Model User:
  1. <?php
  2.  
  3. namespace App;
  4.  
  5. use Illuminate\Notifications\Notifiable;
  6. use Illuminate\Foundation\Auth\User as Authenticatable;
  7.  
  8. class User extends Authenticatable
  9. {
  10. public function roles()
  11. {
  12. return $this->belongsToMany('App\Role', 'user_role', 'user_id', 'role_id');
  13. }
  14. use Notifiable;
  15. /**
  16.   * The attributes that are mass assignable.
  17.   *
  18.   * @var array
  19.   */
  20. protected $fillable = [
  21. 'lastname', 'name', 'phonenumber', 'email', 'password',
  22. ];
  23. /**
  24.   * The attributes that should be hidden for arrays.
  25.   *
  26.   * @var array
  27.   */
  28. protected $hidden = [
  29. 'password', 'remember_token',
  30. ];
  31.  
  32. }

create_role_table
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5.  
  6. class CreateRolesTable extends Migration
  7. {
  8. /**
  9.   * Run the migrations.
  10.   *
  11.   * @return void
  12.   */
  13. public function up()
  14. {
  15. Schema::create('roles', function (Blueprint $table) {
  16. $table->increments('id');
  17. $table->string('name_role');
  18. $table->string('description');
  19. $table->timestamps();
  20. });
  21. }
  22. /**
  23.   * Reverse the migrations.
  24.   *
  25.   * @return void
  26.   */
  27. public function down()
  28. {
  29. Schema::drop('roles');
  30. }
  31. }

create_user_role_table
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5.  
  6. class CreateUserRoleTable extends Migration
  7. {
  8. /**
  9.   * Run the migrations.
  10.   *
  11.   * @return void
  12.   */
  13. public function up()
  14. {
  15. Schema::create('user_role', function (Blueprint $table) {
  16. $table->increments('id');
  17. $table->integer('user_id');
  18. $table->integer('role_id');
  19. $table->timestamps();
  20. });
  21. }
  22. /**
  23.   * Reverse the migrations.
  24.   *
  25.   * @return void
  26.   */
  27. public function down()
  28. {
  29. Schema::drop('user_role');
  30. }
  31. }
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 15:14