ufodisko's avatar

Laravel Stapler ,Working on User::create but not on update

Below code works well for Adding a new user with file upload but its shows the error Column not found: 1054 Unknown column 'avatar' in 'field list when updating a user with a file upload.

I have the required fields in the user table and every thing works well on the User::create

//In Form Add
 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 Form Edit
 
 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'];
/* Laravel Stapler checking if the form has image and uploading it */
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);
    }```
0 likes
0 replies

Please or to participate in this conversation.