0

i am trying to do an update using dynamic for "education history" but there is an image also, i use eloquent to update too, for some reason the data is saved in the database but the image just tmp and cannot find in the folder.

    //count array data inputed
    for($incs=0; $incs < count($data_detail_user['institution_names']); $incs++) {
        // update education
        foreach( $data_detail_user['institution_names'] as $key => $file ){
                    // get old photo thumbnail
            $get_photo = Educations::where('id', $key)->first();

            // store photo
            $path = $file->store(
                'assets/education/thumbnail', 'public'
            );

            $education_user = Educations::find($incs);
            $education_user->detail_user_id = $detail_user['id'];
            $education_user->name = $data_detail_user['institution_names'][$incs];
            $education_user->course = $data_detail_user['education_courses'][$incs];
            $education_user->start = $data_detail_user['education_starts'][$incs];
            $education_user->graduate = $data_detail_user['education_graduates'][$incs];
            $education_user->address = $data_detail_user['education_addresses'][$incs];
            $education_user->regencies = $data_detail_user['education_regencies'][$incs];
            $education_user->provinces = $data_detail_user['education_provinces'][$incs];
            $education_user->country = $data_detail_user['education_countries'][$incs];
            $education_user->zip_code = $data_detail_user['education_zips'][$incs];
            $education_user->certificate = $data_detail_user['education_certificates'][$incs][$path];
            $education_user->save();

            $data_detail_user = 'storage/' .$get_photo['certificate'];
            if (File::exists($data_detail_user)) {
                File::delete($data_detail_user);
            } else {
                File::delete('storage/app/public/' .$get_photo['certificate']);
            }
        }
    }

[the error show Call to a member function store() on string] this is the screenshoot of the error [1]: https://i.stack.imgur.com/l96sm.png

1 Answers1

0
$path = $request->file('path')->store('public/post');

I assume you have a directory where the image is suppose to be stored that's why i created the post directory after public.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 22 '22 at 10:21
  • but i already put it like this @stephane timene $path = $file->store( 'assets/education/thumbnail', 'public' ); – Faqih Syakir Jul 13 '22 at 06:50