-
Notifications
You must be signed in to change notification settings - Fork 2
/
AddTeam.php
63 lines (53 loc) · 1.21 KB
/
AddTeam.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
<?php
namespace App\Livewire\Crew;
use App\Models\User;
use Illuminate\View\View;
use LivewireUI\Modal\ModalComponent;
class AddTeam extends ModalComponent
{
public User $user;
public $crew_team;
/**
* Initializes the component
* @param User $user
* @return void
*/
public function mount(User $user)
{
$this->user = $user;
$this->crew_team = $user->crew_team;
}
/**
* Saves the tag for the user
*/
public function save()
{
$validated = $this->validate([
'crew_team' => 'required|in:organization,website'
]);
$this->user->update([
'crew_team' => $this->crew_team
]);
return redirect()->to(route('moderator.crew.index'));
}
/**
* Removes the set team of the crew user
*
* @return \Illuminate\Http\RedirectResponse
*/
public function removeTeam()
{
$this->user->update([
'crew_team' => null
]);
return redirect()->to(route('moderator.crew.index'));
}
/**
* Renders the component
* @return View
*/
public function render(): View
{
return view('livewire.crew.add-team');
}
}