-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCreateSponsorshipForm.php
59 lines (49 loc) · 1.43 KB
/
CreateSponsorshipForm.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
<?php
namespace App\Http\Livewire\Sponsorships;
use App\Models\SponsorTier;
use App\Models\Team;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Contracts\View\Factory;
use Illuminate\Foundation\Application;
use Illuminate\Http\RedirectResponse;
use Livewire\Component;
class CreateSponsorshipForm extends Component
{
public $teamId;
public $tierId;
public $teams;
public $tiers;
/**
* Triggered on the initializing of the component
* @return void
*/
public function mount()
{
$this->teams = Team::where('sponsor_tier_id', null)->get();
$this->tiers = SponsorTier::all()->filter(function ($tier) {
return $tier->areMoreSponsorsAllowed();
});
$this->teamId = $this->teams->first()->id;
$this->tierId = $this->tiers->first()->id;
}
/**
* Add company as a sponsor
* @return RedirectResponse
*/
public function addSponsorship()
{
$team = Team::find($this->teamId);
$team->sponsor_tier_id = $this->tierId;
$team->is_sponsor_approved = 1;
$team->save();
return redirect(route('moderator.sponsors.index'));
}
/**
* Render the component
* @return Factory|Application|\Illuminate\Contracts\View\View|ApplicationContract
*/
public function render()
{
return view('moderator.sponsors.create-sponsorship-form');
}
}