public function save(Request $request, FileUploader $fileUploader)
    {
        $data = $request->except('_token');

        if ($request->hasFile('image')) {
            $file = $fileUploader->handle($request->file('image'), 'settings');
            $this->deleteImage();
            $data['image'] = $file['filename'];
        }

        foreach ($data as $group_name => $array) {
            if (!is_array($array)) {
                $array = [$group_name => $array];
                $group_name = 'config';
            }
            foreach ($array as $key_name => $value) {
                $model = Setting::firstOrCreate(['key_name' => $key_name, 'group_name' => $group_name]);
                $model->value = $value;
                $model->save();
                $this->repository->forgetCache();
            }
        }

        return redirect()->route('admin::index-settings');
    }
public function save(Request $request, FileUploader $fileUploader)
    {
        $data = $request->except('_token');

        if ($request->hasFile('image')) {
            $file = $fileUploader->handle($request->file('image'), 'settings');
            $this->deleteImage();
            $data['image'] = $file['filename'];
        }

        foreach ($data as $group_name => $array) {
            if (!is_array($array)) {
                $array = [$group_name => $array];
                $group_name = 'config';
            }
            foreach ($array as $key_name => $value) {
                $model = Setting::firstOrCreate(['key_name' => $key_name, 'group_name' => $group_name]);
                $model->value = $value;
                $model->save();
                $this->repository->forgetCache();
            }
        }

        return redirect()->route('admin::index-settings');
    }
public function save ( Request $ request , FileUploader $ fileUploader ) { $ data = $ request -> except ( '_token' ) ; if ( $ request -> hasFile ( 'image' ) ) { $ file = $ fileUploader -> handle ( $ request -> file ( 'image' ) , 'settings' ) ; $ this -> deleteImage ( ) ; $ data [ 'image' ] = $ file [ 'filename' ] ; } foreach ( $ data as $ group_name => $ array ) { if ( ! is_array ( $ array ) ) { $ array = [ $ group_name => $ array ] ; $ group_name = 'config' ; } foreach ( $ array as $ key_name => $ value ) { $ model = Setting :: firstOrCreate ( [ 'key_name' => $ key_name , 'group_name' => $ group_name ] ) ; $ model -> value = $ value ; $ model -> save ( ) ; $ this -> repository -> forgetCache ( ) ; } } return redirect ( ) -> route ( 'admin::index-settings' ) ; }
Save settings.

@return \Illuminate\Http\RedirectResponse
Save settings .