-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEditEditionEventModal.php
65 lines (55 loc) · 1.5 KB
/
EditEditionEventModal.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace App\Livewire\EditionEvent;
use App\Livewire\Forms\EditionEventForm;
use App\Models\Edition;
use App\Models\EditionEvent;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
use LivewireUI\Modal\ModalComponent;
class EditEditionEventModal extends ModalComponent
{
public Edition $edition;
public EditionEvent $editionEvent;
public EditionEventForm $form;
/**
* Initializes the component
* @param Edition $edition
* @param EditionEvent $editionEvent
* @return void
*/
public function mount(Edition $edition, EditionEvent $editionEvent): void
{
$this->edition = $edition;
$this->editionEvent = $editionEvent;
$this->form->setEditionEvent($editionEvent, $edition);
}
/**
* Saves the updates made on the form
*/
public function save()
{
if (Auth::user()->cannot('update', Edition::class)) {
abort(403);
}
$this->validate();
$this->form->update();
return redirect(route('moderator.editions.show', $this->edition))
->with('status', 'Event successfully updated.');
}
/**
* Sets the maximum width of the modal according to docs
* @return string
*/
public static function modalMaxWidth(): string
{
return 'lg';
}
/**
* Renders the component
* @return View
*/
public function render() : View
{
return view('livewire.edition-event.edit-edition-event-modal');
}
}