hachiman's avatar

save $fileName to database

I have a avatar upload thingy and i want to save the filename in the database

    public function avatarupload() {

        $input = Input::all();

        if (Input::hasFile('avatar')) {

            $fileName = 'avatar_'.$this->user->id;

            $image = Image::make($input['avatar']);
            $image->resize(300, 300);
            $image->save(public_path() . '/upload/profile/avatars/'.$fileName.'.jpg');

            $this->user->profile->fill($fileName)->save();

        }

        return Redirect::route('profile.edit', $this->user->id);
    }

But when i do this i get

Argument 1 passed to Illuminate\Database\Eloquent\Model::fill() must be of the type array, string given, 
0 likes
2 replies
toniperic's avatar
Level 30
$this->user->profile->fill(['column_you_want_to_update' => $fileName])->save();

Hope this was helpful.

1 like

Please or to participate in this conversation.