Laravel Stapler, User Experience :: creating but not updating

In the form Add to my controller

        public function add()
        {
            $input = Input::all();
            $validator = Validator::make( $input, User::$rules['create'] ); # Or 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'] ); # Or User::$rules['create']
       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

+4
source share
1 answer

Received a solution from different threads

$user = User::find(1);
$user->update(Input::except('avatar'));
$user->avatar = Input::file('avatar');
0
source

Source: https://habr.com/ru/post/1584379/


All Articles