Pulling my hair out over this one - Eloquent create only seems to be inserting certain columns
Doing a standard user::create() with the following code:
$email = Input::get('email');
$user_type = Input::get('user_type');
$user_type = ($user_type == 'ed') ? 1 : 2;
$organisation = Input::get('organisation');
$postcode = Input::get('postcode');
$job = Input::get('job');
$salutation = Input::get('salutation');
$forename = Input::get('forename');
$surname = Input::get('surname');
$password = Input::get('password');
// Activation Code
$code = str_random(60);
$user = User::create(array(
'email' => $email,
'user_type' => $user_type,
'organisation' => $organisation,
'postcode' => $postcode,
'job' => $job,
'salutation' => $salutation,
'forename' => $forename,
'surname' => $surname,
'password' => Hash::make($password),
'code' => $code,
'active' => 0
));
However, this is only inserting the columns: "id", "email", "password", "code", "active" and the Created / Updated. All other columns are empty.
I know that the variables are valid at the time of ::create.
My table structure is as follows:
1 id int(11)
2 email varchar(75)
3 user_type tinyint(4)
4 organisation varchar(40)
5 postcode varchar(10)
6 job varchar(60)
7 salutation varchar(5)
8 forename varchar(60)
9 surname varchar(60)
10 password varchar(60)
11 password_temp varchar(60)
12 code varchar(60)
13 active int(11)
14 created_at datetime
15 updated_at date
16 remember_Token varchar(100)
Add the missing columns in the $fillable property of User model see: Mass Assignment.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community