Skip to content

Commit

Permalink
Merge pull request #500 from HDInnovations/fix-backup-route-related-i…
Browse files Browse the repository at this point in the history
…ssue

(Fix) Staff Dashboard Backup Delete Function
  • Loading branch information
HDVinnie authored Jan 15, 2019
2 parents f277a71 + 3b5eccb commit c799eb7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
16 changes: 10 additions & 6 deletions app/Http/Controllers/Staff/BackupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,20 @@ public function download(Request $request)
* Deletes A Backup.
*
* @param \Illuminate\Http\Request $request
* @param $file_name
*/
public function delete(Request $request, $file_name)
public function delete(Request $request)
{
$disk = Storage::disk($request->input('disk'));
$file_name = $request->input('file_name');
$adapter = $disk->getDriver()->getAdapter();

if ($disk->exists($file_name)) {
$disk->delete($file_name);

return 'success';
if ($adapter instanceof Local) {
if ($disk->exists($file_name)) {
$disk->delete($file_name);
return 'success';
} else {
return abort(404, trans('backup.backup_doesnt_exist'));
}
}

return abort(404, trans('backup.backup_doesnt_exist'));
Expand Down
8 changes: 5 additions & 3 deletions resources/views/Staff/backup/backup.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class="{{ config('other.font-awesome') }} fa-plus"></i> @lang('backup.create_a_n
href="{{ url('staff_dashboard/backup/download/') }}?disk={{ $b['disk'] }}&path={{ urlencode($b['file_path']) }}&file_name={{ urlencode($b['file_name']) }}"><i
class="{{ config('other.font-awesome') }} fa-cloud-download"></i> @lang('backup.download')</a>
@endif
<a class="btn btn-xs btn-danger" data-button-type="delete"
href="{{ url('staff_dashboard/backup/delete/'.$b['file_name']) }}?disk={{ $b['disk'] }}"><i
<a class="btn btn-xs btn-danger" data-disk="{{ $b['disk'] }}" data-file="{{ $b['file_name'] }}" data-button-type="delete"
href="{{ url('staff_dashboard/backup/delete') }}"><i
class="{{ config('other.font-awesome') }} fa-trash"></i> @lang('backup.delete')</a>
</td>
</tr>
Expand Down Expand Up @@ -126,11 +126,13 @@ class="{{ config('other.font-awesome') }} fa-trash"></i> @lang('backup.delete')<
e.preventDefault();
var delete_button = $(this);
var delete_url = $(this).attr('href');
var disk = $(this).attr('data-disk');
var file = $(this).attr('data-file');
if (confirm("@lang('backup.delete_confirm')") == true) {
$.ajax({
url: delete_url,
data: {_token: '{{csrf_token()}}'},
data: {_token: '{{csrf_token()}}', disk: disk, file_name: file },
type: 'POST',
success: function (result) {
// Show an alert with the result
Expand Down
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@
Route::get('/backup', 'BackupController@index')->name('backupManager');
Route::post('/backup/create', 'BackupController@create');
Route::get('/backup/download/{file_name?}', 'BackupController@download');
Route::post('/backup/delete/{file_name?}', 'BackupController@delete')->where('file_name', '=', '(.*)');
Route::post('/backup/delete', 'BackupController@delete');

// Mass Validate Users
Route::get('/massValidateUsers', 'UserController@massValidateUsers')->name('massValidateUsers');
Expand Down

0 comments on commit c799eb7

Please sign in to comment.