-
Notifications
You must be signed in to change notification settings - Fork 2
/
OverrideDifficulty.php
51 lines (43 loc) · 1.2 KB
/
OverrideDifficulty.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
45
46
47
48
49
50
51
<?php
namespace App\Http\Livewire;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Contracts\View\Factory;
use Illuminate\Foundation\Application;
use Livewire\Component;
class OverrideDifficulty extends Component
{
public $presentation;
public $selectedDifficultyId;
protected $rules = [
'selectedDifficultyId' => 'required'
];
/**
* Triggered when initializing the component
* @param $presentation
* @return void
*/
public function mount($presentation)
{
$this->presentation = $presentation;
$this->selectedDifficultyId = $presentation->difficulty->id;
}
/**
* Saves changes on the difficulty level
* @return void
*/
public function updateDifficulty()
{
$this->presentation->update([
'difficulty_id' => $this->selectedDifficultyId
]);
session()->flash('message', 'The difficulty level is successfully updated.');
}
/**
* Render the component
* @return Factory|Application|\Illuminate\Contracts\View\View|ApplicationContract
*/
public function render()
{
return view('livewire.override-difficulty');
}
}