-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathResetTimeslots.php
44 lines (38 loc) · 1.17 KB
/
ResetTimeslots.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace App\Http\Livewire\Schedule;
use App\Models\DefaultPresentation;
use App\Models\Presentation;
use App\Models\Timeslot;
use Illuminate\View\Factory;
use Illuminate\View\View;
use Livewire\Component;
use Symfony\Component\Console\Application;
class ResetTimeslots extends Component
{
public $isOpen = false;
/**
* Resets all scheduled presentations
* @return void
*/
public function confirm()
{
$presentations = Presentation::all();
foreach ($presentations as $presentation) {
$presentation->timeslot_id = null;
$presentation->room_id = null;
$presentation->save();
}
// TODO: After refactoring the constraints, this can be switched to truncate
DefaultPresentation::truncate();
Timeslot::where('id', '>', 0)->delete();
$this->redirect(route('moderator.schedule.default.presentation.create', 'opening'));
}
/**
* Renders the component
* @return View|Application|Factory|\Illuminate\Contracts\Foundation\Application
*/
public function render()
{
return view('moderator.schedule.timeslots.reset-timeslots');
}
}