Commit 081a8ca9 by Aan Choesni Herlingga

bug fix store local and delete file local

parent 8ebc4736
...@@ -52,7 +52,7 @@ class SliderRepository extends Repository ...@@ -52,7 +52,7 @@ class SliderRepository extends Repository
if ($setting['external_storage'] == 1) { if ($setting['external_storage'] == 1) {
Storage::disk('storage')->put($setting['directory'] . '/slider/' . $filename, file_get_contents($cover->getRealPath())); Storage::disk('storage')->put($setting['directory'] . '/slider/' . $filename, file_get_contents($cover->getRealPath()));
} else { } else {
Storage::disk('local')->put('slider/' . $filename, file_get_contents($cover->getRealPath())); Storage::disk('local')->put('public/slider/' . $filename, file_get_contents($cover->getRealPath()));
} }
$data['images'] = $filename; $data['images'] = $filename;
} }
...@@ -81,7 +81,7 @@ class SliderRepository extends Repository ...@@ -81,7 +81,7 @@ class SliderRepository extends Repository
if ($setting['external_storage'] == 1) { if ($setting['external_storage'] == 1) {
Storage::disk('storage')->put($setting['directory'] . '/slider/' . $filename, file_get_contents($cover->getRealPath())); Storage::disk('storage')->put($setting['directory'] . '/slider/' . $filename, file_get_contents($cover->getRealPath()));
} else { } else {
Storage::disk('local')->put('slider/' . $filename, file_get_contents($cover->getRealPath())); Storage::disk('local')->put('public/slider/' . $filename, file_get_contents($cover->getRealPath()));
} }
$data['images'] = $filename; $data['images'] = $filename;
...@@ -91,6 +91,32 @@ class SliderRepository extends Repository ...@@ -91,6 +91,32 @@ class SliderRepository extends Repository
return $sModel->update($data); return $sModel->update($data);
} }
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Slider $slider
* @return \Illuminate\Http\Response
*/
public function destroy($sModel)
{
$setting = webprofilesetting();
try {
if ($sModel->images) {
if ($setting['external_storage'] == 1) {
Storage::disk('storage')->delete($setting['directory'] . '/slider/' . $sModel->images);
} else {
Storage::disk('local')->delete('public/slider/' . $sModel->images);
}
}
$sModel->delete($sModel->id);
return redirect()->route('sliders.index');
} catch (\Exception $id) {
return redirect()->route('sliders.index');
}
}
public function datatable($data) public function datatable($data)
{ {
$setting = webprofilesetting(); $setting = webprofilesetting();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment