Laravel hak akses/multi login

Screenshot from 2016-04-28 13:37:23.png saya belajar membuat multi login/hak akses memakai framework laravel,nah pas saat melakukan Register muncul eror seperti di atas,mohon koreksinya gan apa ada yang salah dengan kodingan saya :) ->Ini koding migrationnya:
class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('roles_id')->nullable();
            $table->string('username')->unique();
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });

        Schema::create('roles', function (Blueprint $kolom) {
            $kolom->increments('id');
            $kolom->string('nameroles');
        });

        Schema::table('users', function (Blueprint $kolom) {
          $kolom->foreign('roles_id')->references('id')->on('roles')->onDelete('cascade')->onUpdate('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('users');

        Schema::drop('roles');

    }
}
-> Ini koding RegisterControllernya :
<?php

namespace App\Http\Controllers;

use App\User;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;

class RegisterController extends Controller
{
    public function __construct()
    {
        $this->middleware('guest');
    }

    public function getRegister()
    {
        return view('Register.FormRegister');
    }
    public function postRegister(Request $request)
    {
      $user = new User();
      $user->email = Input::get('email');
      $user->username = Input::get('username');
      $user->password = bcrypt(Input::get('password'));
      $user->roles_id = DB::table('roles')->select('id')->where('nameroles', 'user')->first();
      $user->save();
    }
}
avatar bangadam

@bangadam

18 Kontribusi 7 Poin


Jawaban

Belum ada Jawaban, jadi yang pertama

Login untuk gabung berdiskusi