インポートしたデータを消せるようにする

This commit is contained in:
shibafu 2020-05-23 02:47:25 +09:00
parent fb5b34b239
commit c0d62f5112
5 changed files with 28 additions and 0 deletions

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\DeactivatedUser;
use App\Ejaculation;
use App\Exceptions\CsvImportException;
use App\Services\CheckinCsvExporter;
use App\Services\CheckinCsvImporter;
@ -104,6 +105,16 @@ class SettingController extends Controller
}
}
public function destroyImport()
{
Auth::user()
->ejaculations()
->where('ejaculations.source', Ejaculation::SOURCE_CSV)
->delete();
return redirect()->route('setting.import')->with('status', '削除が完了しました。');
}
public function export()
{
return view('setting.export');

5
resources/assets/js/setting/import.js vendored Normal file
View File

@ -0,0 +1,5 @@
$('#destroy-form').on('submit', function () {
if (!confirm('本当に削除してもよろしいですか?')) {
return false;
}
});

View File

@ -26,7 +26,17 @@
@endif
<button type="submit" class="btn btn-primary mt-2">アップロード</button>
</form>
<h3 class="mt-5">インポートしたデータを一括削除</h3>
<hr>
<p class="mb-0">取り込んだチェックインデータをすべて削除することができます。データにミスがあってやり直したい場合などにお使いください。</p>
<p class="text-danger">ただし、インポート後に個別に手修正などしている場合、そのデータも失われてしまうことに注意してください!</p>
<form id="destroy-form" class="mt-4" action="{{ route('setting.import.destroy') }}" method="post">
{{ csrf_field() }}
{{ method_field('DELETE') }}
<button type="submit" class="btn btn-danger mt-2">データを削除</button>
</form>
@endsection
@push('script')
<script src="{{ mix('js/setting/import.js') }}"></script>
@endpush

View File

@ -38,6 +38,7 @@ Route::middleware('auth')->group(function () {
Route::post('/setting/privacy', 'SettingController@updatePrivacy')->name('setting.privacy.update');
Route::get('/setting/import', 'SettingController@import')->name('setting.import');
Route::post('/setting/import', 'SettingController@storeImport')->name('setting.import');
Route::delete('/setting/import', 'SettingController@destroyImport')->name('setting.import.destroy');
Route::get('/setting/export', 'SettingController@export')->name('setting.export');
Route::get('/setting/export/csv', 'SettingController@exportToCsv')->name('setting.export.csv');
Route::get('/setting/deactivate', 'SettingController@deactivate')->name('setting.deactivate');

1
webpack.mix.js vendored
View File

@ -16,6 +16,7 @@ mix.js('resources/assets/js/app.js', 'public/js')
.js('resources/assets/js/home.js', 'public/js')
.js('resources/assets/js/user/stats.js', 'public/js/user')
.js('resources/assets/js/setting/privacy.js', 'public/js/setting')
.js('resources/assets/js/setting/import.js', 'public/js/setting')
.js('resources/assets/js/setting/deactivate.js', 'public/js/setting')
.ts('resources/assets/js/checkin.ts', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')