Recent Topics

Add profile photo option for user

  • hello
    I am trying to add profile photo options for the user, but I am having problems storing the photos on upload.
    My uploadImages function inside CustomerRepository:

    public function uploadImages($data)
            $customer = $this->find(auth()->guard('customer')->id());
            $type = "profile_photo";
            if (isset($data[$type])) {
                foreach ($data[$type] as $imageId => $image) {
                    $file = $type . '.' . $imageId;
                    $dir = 'customer/' . $customer->id;
                    if (request()->hasFile($file)) {
                        if ($customer->{$type}) {
                        $customer->{$type} = request()->file($file)->store($dir);
            } else {
                if ($customer->{$type}) {
                $customer->{$type} = null;

    The code skips if(request()->hasFile($file)) because it returns false.
    I call the upload function from [email protected] like so:


    The input on edit.blade.php is like so:

    <div slot="body">
                    <div class="control-group">
                            <image-wrapper :button-label="'写真を入れる'" input-name="profile_photo" :multiple="false" :images='"{{ $customer->lprofile_photo}}"'></image-wrapper>

    I also changed other parts, but I don't think they should have any impact.
    This is a sample output I get from $data["profile_photo"]

    array (
        'image_1' => 'store_vertical.svg',

    Which I think is missing some stuff?
    Also I tried to add the image to validation, but it does not pass.

    $this->validate(request(), [
                'profile_photo'         => 'image',

    The code does not give any errors, and since I am still new to most things, I cannot understand what parts I'm supposed to change.

  • This feature is already implemented in the master version.

  • Hello!
    Thank you so much for the reply!
    I didn't know the feature was added.
    Unfortunately we had to customise a lot of stuff and ended up changing a bunch of things directly in the Webkul folder, so merging the main branch directly would prove to be a problem.

    I tried copying from the following files from the master version:

    But I think I am missing something, could you help me out?

    new empty image column:
    No errors pop up but the image is not saved and the url is not either.
    random string in the "image" column:
    error: Class 'Webkul\Customer\Repositories\Storage' not found

    Thanks again!

  • I found the pull request for it!
    It is now working, thanks again!

Log in to reply