Support the ongoing development of Laravel.io →
Authentication Views
Last updated 1 year ago.
0

you are trying to insert a null value into the user_id field of profiles table.

just make sure it isn't null.

Last updated 1 year ago.
0

In your migration:

/*
 * Engine
 */
$table->engine = 'InnoDB';

/*
 * Fields
 */
$table->integer('user_id')->unsigned()->nullable();

/*
 * Foreign Keys
 */
$table->foreign('user_id', 'relation_user_id')
  ->references('id')
  ->on('users')
  ->onUpdate('cascade')
  ->onDelete('cascade');
Last updated 1 year ago.
0

Hey Felipe!

I implemented your suggestion, and I got passed the error, only to be thrown a new one;

ErrorException
Argument 1 passed to Illuminate\Auth\Guard::login() must implement interface Illuminate\Auth\UserInterface, null    given

What seems to be the issue here? Since it says "null given" I assume its the null value that makes trouble now?

Thank you!

EDIT

The user has been added to the database, however the error above still persists.

EDIT #2

I suspect that its my user model that cause the trouble, since i am using the ConfideUser class to login my users.

This is my model:

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
use Zizaco\Confide\ConfideUser;
use Zizaco\Confide\Confide;
use Zizaco\Entrust\HasRole;

class User extends ConfideUser implements UserInterface { 

...

}

EDIT #3

This is my entire model as it is now, I still get the same error, but I also tried without using the ConfideUser. Any suggestions?

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
use Zizaco\Confide\ConfideUser;
use Zizaco\Confide\Confide;
use Zizaco\Entrust\HasRole;

 class User extends ConfideUser implements UserInterface, RemindableInterface {

public function getAuthIdentifier()
{
    return $this->getKey();
}

public function getReminderEmail() {
	return $this->email;
}

/**
 * Get the password for the user.
 *
 * @return string
 */
public function getAuthPassword()
{
    return $this->password;
}

public static $rules = array (
		'username'    => 'required|min:3',
		'password'    => 'required|min:3',
		);

public function annoncer()
{
	return $this->hasMany('annonce');
}

 public function getUserByUsername( $username )
{
    return $this->where('username', '=', $username)->first();
}

public function profiles()
{
    return $this->hasMany('Profile');
}

}

Last updated 1 year ago.
0

Any inputs? :)

Last updated 1 year ago.
0

Are you doing Auth::login anywhere?

Last updated 1 year ago.
0

Hey guys, just wanted to make an update here. I decided to use the oauth facebook login instead, and that works perfectly for my use case.

So thanks!

Last updated 1 year ago.
0

hey anyone got the answer for this? am still getting the same error

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Reached reached Joined 27 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.