In the form Add to my controller
public function add()
{
$input = Input::all();
$validator = Validator::make( $input, User::$rules['create'] );
if ( $validator->fails() ) {
return "failure";
}
else{
return User::create(Input::all());
}
}
In the form editor in the m-controller
public function edit()
{
$input = Input::all();
$validator = Validator::make( $input, User::$rules['edit'] );
if ( $validator->fails() ) {
return "failure";
}
else{
$user=new User();
$user->find(1);
$user->update(Input::all());
}
}
In user model
protected $fillable = ['name', 'email', 'password','role','position','mobile_number','picture','facebook','twitter','instagram','linkedin','avatar'];
public function __construct(array $attributes = array()) {
$this->hasAttachedFile('avatar', [
'styles' => [
'medium' => '300x300',
'thumb' => '100x100'
],
'url' => '/uploads/:attachment/:id_partition/:style/:filename',
'default_url' => '/uploads/defaults/:style/missing.png'
]);
parent::__construct($attributes);
}
This code works well to add a new user, but it shows an error
Column not found: 1054 Unknown column 'avatar' in 'field list
I have required fields in the user table and everything works well on User::create
Edited: Here is my dd ($ user)
http://pastebin.com/4e3HSusG
source
share