From 86b9f3d2f0f8b39addaffe08754f7518069fa17b Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 19 Feb 2023 13:56:09 +0100 Subject: [PATCH] Formatting fixes. --- app/Http/Livewire/Form/AccountForm.php | 32 ++++---- app/Http/Livewire/Form/CardForm.php | 100 +++++++++++------------ app/Http/Livewire/Form/CharacterForm.php | 36 ++++---- app/Http/Livewire/Form/LoginForm.php | 30 +++---- app/Http/Livewire/Form/ModelForm.php | 86 +++++++++---------- app/Http/Livewire/Form/RaidForm.php | 36 ++++---- app/Http/Livewire/GameComponent.php | 2 +- 7 files changed, 161 insertions(+), 161 deletions(-) diff --git a/app/Http/Livewire/Form/AccountForm.php b/app/Http/Livewire/Form/AccountForm.php index a4aa4cb..7cd0033 100644 --- a/app/Http/Livewire/Form/AccountForm.php +++ b/app/Http/Livewire/Form/AccountForm.php @@ -29,25 +29,25 @@ class AccountForm extends Component 'password' => 'new password', ]; - public function mount(Request $request) - { + public function mount(Request $request) + { $this->record = $request->user(); $this->username = $this->record->username; - } + } - /** - * Validation rules - */ - protected function rules() - { - return [ - 'password_current' => [ 'required', 'password' ], - 'password' => [ Password::min(8)->letters()->mixedCase()->numbers(), 'confirmed' ] - ]; - } + /** + * Validation rules + */ + protected function rules() + { + return [ + 'password_current' => ['required', 'password'], + 'password' => [Password::min(8)->letters()->mixedCase()->numbers(), 'confirmed'] + ]; + } - public function updated($property, $value) + public function updated($property, $value) { if ($property == 'password_confirmation') { $property = 'password'; @@ -64,12 +64,12 @@ class AccountForm extends Component $this->record->save(); return redirect()->route('admin') - ->with('info', __('Password was successfully updated.')); + ->with('info', __('Password was successfully updated.')); } public function render() { return view('form.account') - ->layout('layouts.admin'); + ->layout('layouts.admin'); } } diff --git a/app/Http/Livewire/Form/CardForm.php b/app/Http/Livewire/Form/CardForm.php index a92eca0..bd9f4d2 100644 --- a/app/Http/Livewire/Form/CardForm.php +++ b/app/Http/Livewire/Form/CardForm.php @@ -9,62 +9,62 @@ use App\Models\Wow; class CardForm extends ModelForm { - /** - * Array of available characters - */ - public $characters; + /** + * Array of available characters + */ + public $characters; - /** - * Array of available raids - */ - public $raids; + /** + * Array of available raids + */ + public $raids; - /** - * Redirect after this route after record was created. - */ - public string $redirect_route = 'admin.card.index'; + /** + * Redirect after this route after record was created. + */ + public string $redirect_route = 'admin.card.index'; - public function mount(Card $card) - { - $this->record = $card; - $this->characters = Character::all()->pluck('name', 'id'); - $this->raids = Raid::all()->pluck('name', 'id'); - $this->classes = Wow::$classes; - $this->exist = $card->exists; - } - - /** - * Validation rules - */ - protected function rules() - { - return [ - 'record.body' => 'required|string|min:3|max:200', - 'record.character_id' => 'exists:' . Character::class . ',id|nullable', - 'record.raid_id' => 'exists:' . Raid::class . ',id|nullable', - 'record.class' => 'in:' . collect($this->classes)->keys() . '|nullable', - ]; - } - - public function updated($property, $value) + public function mount(Card $card) { - // Hack to force empty value to null. - if (in_array($property, ['record.character_id', 'record.raid_id', 'record.class'])) { - if (empty($value)) { - $this->{$property} = null; - } - } + $this->record = $card; + $this->characters = Character::all()->pluck('name', 'id'); + $this->raids = Raid::all()->pluck('name', 'id'); + $this->classes = Wow::$classes; + $this->exist = $card->exists; + } + + /** + * Validation rules + */ + protected function rules() + { + return [ + 'record.body' => 'required|string|min:3|max:200', + 'record.character_id' => 'exists:' . Character::class . ',id|nullable', + 'record.raid_id' => 'exists:' . Raid::class . ',id|nullable', + 'record.class' => 'in:' . collect($this->classes)->keys() . '|nullable', + ]; + } + + public function updated($property, $value) + { + // Hack to force empty value to null. + if (in_array($property, ['record.character_id', 'record.raid_id', 'record.class'])) { + if (empty($value)) { + $this->{$property} = null; + } + } $this->validateOnly($property); } - public function getSubjectProperty() - { - if ($this->record->character_id) { - return $this->characters[$this->record->character_id]; - } else if ($this->record->class) { - return $this->classes[$this->record->class]; - } - return "Somebody"; - } + public function getSubjectProperty() + { + if ($this->record->character_id) { + return $this->characters[$this->record->character_id]; + } else if ($this->record->class) { + return $this->classes[$this->record->class]; + } + return "Somebody"; + } } diff --git a/app/Http/Livewire/Form/CharacterForm.php b/app/Http/Livewire/Form/CharacterForm.php index 8358107..5002528 100644 --- a/app/Http/Livewire/Form/CharacterForm.php +++ b/app/Http/Livewire/Form/CharacterForm.php @@ -6,24 +6,24 @@ use App\Models\Character; class CharacterForm extends ModelForm { - /** - * Redirect after this route after record was created. - */ - public string $redirect_route = 'admin.character.index'; + /** + * Redirect after this route after record was created. + */ + public string $redirect_route = 'admin.character.index'; - public function mount(Character $character) - { - $this->record = $character; - $this->exist = $character->exists; - } + public function mount(Character $character) + { + $this->record = $character; + $this->exist = $character->exists; + } - /** - * Validation rules - */ - protected function rules() - { - return [ - 'record.name' => 'required|string|min:3|max:14', - ]; - } + /** + * Validation rules + */ + protected function rules() + { + return [ + 'record.name' => 'required|string|min:3|max:14', + ]; + } } diff --git a/app/Http/Livewire/Form/LoginForm.php b/app/Http/Livewire/Form/LoginForm.php index 01568cf..dc91b91 100644 --- a/app/Http/Livewire/Form/LoginForm.php +++ b/app/Http/Livewire/Form/LoginForm.php @@ -7,31 +7,31 @@ use Illuminate\Support\Facades\Auth; class LoginForm extends Component { - public $username; + public $username; - public $password; + public $password; - protected $rules = [ + protected $rules = [ 'username' => 'required|string|min:3', 'password' => 'required|string', ]; - public function submit() - { - $this->validate(); + public function submit() + { + $this->validate(); - $cred = [ - 'username' => $this->username, - 'password' => $this->password - ]; + $cred = [ + 'username' => $this->username, + 'password' => $this->password + ]; - if (!Auth::attempt($cred)) { - session()->flash('message', __('auth.failed')); - return; + if (!Auth::attempt($cred)) { + session()->flash('message', __('auth.failed')); + return; } - return redirect()->intended('/admin'); - } + return redirect()->intended('/admin'); + } /** * Render the setup page diff --git a/app/Http/Livewire/Form/ModelForm.php b/app/Http/Livewire/Form/ModelForm.php index a44d7c9..e4ae801 100644 --- a/app/Http/Livewire/Form/ModelForm.php +++ b/app/Http/Livewire/Form/ModelForm.php @@ -9,68 +9,68 @@ use Illuminate\Support\Str; abstract class ModelForm extends Component { - use Alert; + use Alert; - /** - * The model record - */ - public $record; + /** + * The model record + */ + public $record; - /** - * True if the record already exists in the database. - */ - public bool $exist; + /** + * True if the record already exists in the database. + */ + public bool $exist; - /** - * Redirect after this route after record was created. - */ - public string $redirect_route; + /** + * Redirect after this route after record was created. + */ + public string $redirect_route; - /** - * Get the name of the model - */ - public function getModelName() : string - { - return Str::afterLast(get_class($this->record), '\\'); - } + /** + * Get the name of the model + */ + public function getModelName(): string + { + return Str::afterLast(get_class($this->record), '\\'); + } - public function updated($property, $value) + public function updated($property, $value) { $this->validateOnly($property); } - /** - * Returns true if this record has not been stored in the database. - */ - public function isNew() : bool - { - return !$this->exist; - } + /** + * Returns true if this record has not been stored in the database. + */ + public function isNew(): bool + { + return !$this->exist; + } - /** - * Submit the form, create/update record. - */ - public function submit() - { - $this->validate(); - $this->record->save(); + /** + * Submit the form, create/update record. + */ + public function submit() + { + $this->validate(); + $this->record->save(); - if ($this->isNew()) { - return redirect()->route($this->redirect_route) - ->with('info', __("{$this->getModelName()} was successfully created.")); - } + if ($this->isNew()) { + return redirect()->route($this->redirect_route) + ->with('info', __("{$this->getModelName()} was successfully created.")); + } - $this->info(__("{$this->getModelName()} was successfully updated.")); - } + $this->info(__("{$this->getModelName()} was successfully updated.")); + } /** * Render the setup page */ public function render() { - $script = Str::lower($this->getModelName()); + $script = Str::lower($this->getModelName()); return view("form.$script") - ->layout('layouts.admin'); + ->layout('layouts.admin'); } } diff --git a/app/Http/Livewire/Form/RaidForm.php b/app/Http/Livewire/Form/RaidForm.php index 831e2dc..c927338 100644 --- a/app/Http/Livewire/Form/RaidForm.php +++ b/app/Http/Livewire/Form/RaidForm.php @@ -6,24 +6,24 @@ use App\Models\Raid; class RaidForm extends ModelForm { - /** - * Redirect after this route after record was created. - */ - public string $redirect_route = 'admin.raid.index'; + /** + * Redirect after this route after record was created. + */ + public string $redirect_route = 'admin.raid.index'; - public function mount(Raid $raid) - { - $this->record = $raid; - $this->exist = $raid->exists; - } + public function mount(Raid $raid) + { + $this->record = $raid; + $this->exist = $raid->exists; + } - /** - * Validation rules - */ - protected function rules() - { - return [ - 'record.name' => 'required|string|min:2|max:20', - ]; - } + /** + * Validation rules + */ + protected function rules() + { + return [ + 'record.name' => 'required|string|min:2|max:20', + ]; + } } diff --git a/app/Http/Livewire/GameComponent.php b/app/Http/Livewire/GameComponent.php index 300459b..862ced5 100644 --- a/app/Http/Livewire/GameComponent.php +++ b/app/Http/Livewire/GameComponent.php @@ -11,7 +11,7 @@ abstract class GameComponent extends Component /** * Get the game service object */ - public function getServiceProperty() : GameService + public function getServiceProperty(): GameService { return app()->make(GameService::class); }