In this topic I asked a question: Laravel 5.2 auth change 'users' table
But now my problem has changed. By default the users table has an id. But I want a customer_id, so I changed everything but it don't work. It keeps asking for an id.
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from
klantenwhereid= 1 limit 1)
In the table klanten I have a customer_id, but it keeps asking for an id.
Things I've changed:
config/auth
'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
        'table' => 'klanten',
    ],
created a klanten migration
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();
    });
}
If I remove timestamps it keeps asking for created_at and updated_at too.
Controllers/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',
];
I hope somebody can help me!
$id = Auth::id(); // Retrieve the currently authenticated user's ID... $user = $request->user(); // returns an instance of the authenticated user... $id = $request->user()->id; // Retrieve the currently authenticated user's ID... $user = auth()->user(); // Retrieve the currently authenticated user...
edit your user model and add this:
protected $primaryKey = 'customer_id';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With