you are trying to insert a null value into the user_id field of profiles table.
just make sure it isn't null.
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');
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');
}
}
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!
hey anyone got the answer for this? am still getting the same error
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community