2016-01-08 19 views
5

W tym temacie zadałem pytanie: Laravel 5.2 auth change 'users' tablelaravel 5,2 auth zmiana „id” do „customer_id”

Ale teraz mój problem został zmieniony. Domyślnie tabela użytkowników ma numer id. Ale chcę customer_id, więc zmieniłem wszystko, ale to nie działa. Ciągle pyta o numer id.

SQLSTATE [42S22] Kolumna nie znaleziono: 1054 wiadomo w kolumnie 'id' z 'gdzie punkt' (SQL: wybierz * z klanten gdzie id = 1 granica 1)

W tabeli klanten Mam numer customer_id, ale wciąż pytam o numer id.

Czego Zmieniliśmy:

config/auth

'providers' => [ 
    'users' => [ 
     'driver' => 'eloquent', 
     'model' => App\User::class, 
     'table' => 'klanten', 
    ], 

stworzył klanten migrację

public function up() 
{ 
    Schema::create('klanten', function (Blueprint $table) { 
     $table->increments('klant_id'); 
     $table->string('voornaam'); 
     $table->string('email')->unique(); 
     $table->string('password', 64); 
     $table->rememberToken(); 
     $table->boolean('status'); 
     $table->timestamps(); 
    }); 
} 

Jeśli usunąć znaczniki czasu utrzymuje z prośbą o created_at i updated_at także.

Kontrolery/Auth/AuthController

protected function validator(array $data) 
{ 
    return Validator::make($data, [ 
     'voornaam' => 'required|max:255', 
     'email' => 'required|email|max:255|unique:klanten', 
     'password' => 'required|confirmed|min:6', 
    ]); 
} 

protected function create(array $data) 
{ 
    return User::create([ 
     'voornaam' => $data['voornaam'], 
     'email' => $data['email'], 
     'password' => bcrypt($data['password']), 
    ]); 
} 

app/User

protected $table = 'klanten'; 

protected $fillable = [ 
    'voornaam', 'email', 'password', 
]; 

Mam nadzieję, że ktoś może mi pomóc!

Odpowiedz

14

edit model użytkownika i dodać to:

protected $primaryKey = 'customer_id'; 
3

można ustawić $primaryKey złożone w modelu User określić klucz podstawowy tabeli:

protected $primaryKey = 'customer_id'; 
Powiązane problemy