I'm currently studying eloquent of L4
and I encountered this mass assignment. I'd follow the instructions and I know you need to setup your $fillable
to use the create
method but I am still receiving a blank row in the database. here's my code:
MODEL:
class User extends Eloquent
{
protected $fillable = array('email','pwd','active','name');
}
CONTROLLER:
$user = new User;
$add = array(
'name'=>Input::get('custname'),
'active'=>1,
'pwd'=>Hash::make(Input::get('pwd')),
'email'=>Input::get('email')
);
return var_dump($user->create($add));
I also did: CONTROLLER
$add = array(
'name'=>Input::get('custname'),
'active'=>1,
'pwd'=>Hash::make(Input::get('pwd')),
'email'=>Input::get('email')
);
return var_dump(User::create($add));
But still the same result.
There was a bug causing this, see https://github.com/laravel/framework/issues/1548 Should be fixed now, run
composer update
to get the newest version oflaravel/framework
Yes with new version you can use public or protected keywords.
Simple use this :
You can also specify table name if you are working with other Model like this :
This is working fine after run composer update on the root of project directory.