Initial Commit
This commit is contained in:
commit
ddf09fe00c
113 changed files with 187148 additions and 0 deletions
78
app/Http/Livewire/Setup.php
Normal file
78
app/Http/Livewire/Setup.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Models\Raid;
|
||||
use App\Models\Character;
|
||||
use App\Models\Card;
|
||||
|
||||
class Setup extends GameComponent
|
||||
{
|
||||
public $all_raids;
|
||||
|
||||
public $all_characters;
|
||||
|
||||
public $all_classes;
|
||||
|
||||
public $shared_settings;
|
||||
|
||||
public $values = [
|
||||
'classes' => [],
|
||||
'raids' => [],
|
||||
'characters' => []
|
||||
];
|
||||
|
||||
function mount()
|
||||
{
|
||||
$this->all_classes = Card::select('class')
|
||||
->whereNotNull('class')
|
||||
->groupBy('class')->orderBy('class')->get()->pluck('class');
|
||||
|
||||
$this->all_raids = Raid::select('id', 'name')->orderBy('name')->get();
|
||||
$this->all_characters = Character::select('id', 'name')
|
||||
->orderBy('name')->get();
|
||||
|
||||
// Load values from settings
|
||||
$this->values['classes'] = $this->settings->classes->toArray();
|
||||
$this->values['raids'] = $this->settings->raids->toArray();
|
||||
$this->values['characters'] = $this->settings->characters->toArray();
|
||||
}
|
||||
|
||||
public function getSettingsProperty()
|
||||
{
|
||||
return $this->service->session()->getSettings();
|
||||
}
|
||||
|
||||
public function resetSettings()
|
||||
{
|
||||
$this->reset('values');
|
||||
}
|
||||
|
||||
public function share()
|
||||
{
|
||||
$setting = Setting::create(['value' => $this->values]);
|
||||
|
||||
$this->shared_settings = $setting->hash;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
// Store values
|
||||
$this->settings->classes->fill($this->values['classes']);
|
||||
$this->settings->raids->fill($this->values['raids']);
|
||||
$this->settings->characters->fill($this->values['characters']);
|
||||
|
||||
$this->service->newSession($this->settings);
|
||||
|
||||
$this->redirectRoute('game');
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the setup page
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('setup');
|
||||
}
|
||||
}
|
||||
Reference in a new issue