-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEditPresentationModal.php
76 lines (64 loc) · 2.11 KB
/
EditPresentationModal.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
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace App\Livewire\Presentation;
use App\Jobs\NotifyPresentationRoles;
use App\Livewire\Forms\PresentationForm;
use App\Mail\PresentationUpdatedMailable;
use App\Models\Presentation;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
use Livewire\Component;
use LivewireUI\Modal\ModalComponent;
class EditPresentationModal extends ModalComponent
{
public Presentation $presentation;
public PresentationForm $form;
/**
* Initializes the component
* @param Presentation $presentation
* @return void
*/
public function mount(Presentation $presentation)
{
$this->presentation = $presentation;
$this->form->setCompany($presentation);
}
/**
* Saves the updates made on the form
*/
public function save()
{
$this->authorize('update', $this->presentation);
$this->validate();
$this->form->update();
if (Auth::user()->presenter_of) {
if (!$this->presentation->isSamePresentation($this->form->presentation)) {
NotifyPresentationRoles::dispatch('crew', $this->presentation, PresentationUpdatedMailable::class);
}
return redirect(route('presentations.show', $this->presentation))
->with('status', 'Presentation successfully updated.');
} else {
if (!$this->presentation->isSamePresentation($this->form->presentation)) {
NotifyPresentationRoles::dispatch('speaker', $this->presentation, PresentationUpdatedMailable::class);
}
return redirect(route('moderator.presentations.show', $this->presentation))
->with('status', 'Presentation successfully updated.');
}
}
/**
* Sets the maximum width of the modal according to docs
* @return string
*/
public static function modalMaxWidth(): string
{
return '6xl';
}
/**
* Renders the component
* @return View
*/
public function render() : View
{
return view('livewire.presentation.edit-presentation-modal');
}
}