Skip to content

Commit

Permalink
Merge pull request #301 from P3D-Legacy/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dsbilling authored Dec 15, 2023
2 parents c31a703 + 5c4a031 commit 7c88253
Show file tree
Hide file tree
Showing 78 changed files with 632 additions and 713 deletions.
18 changes: 9 additions & 9 deletions app/Http/Livewire/Server/ServerCreateForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
use App\Models\Server;
use App\Rules\IPHostnameARecord;
use App\Rules\StrNotContain;
use Illuminate\Contracts\View\View;
use Livewire\Component;
use Livewire\Redirector;

class ServerCreateForm extends Component
{
public $name;
public string $name;

public $host;
public string $host;

public $port;
public int $port;

public $description;
public string $description;

/**
* Create a server.
*
* @return void
*/
public function save()
public function save(): Redirector
{
$this->resetErrorBag();
$this->resetValidation();

$this->validate([
'name' => ['required', 'string', new StrNotContain('official')],
'host' => ['required', new StrNotContain('pokemon3d.net'), new IPHostnameARecord()],
'host' => ['required', new StrNotContain('pokemon3d.net'), new IPHostnameARecord(), 'lowercase'],
'port' => ['required', 'integer', 'min:10', 'max:99999'],
'description' => ['nullable', 'string'],
]);
Expand All @@ -46,7 +46,7 @@ public function save()
return redirect()->route('server.index');
}

public function render()
public function render(): View
{
return view('livewire.server.server-create-form');
}
Expand Down
34 changes: 13 additions & 21 deletions app/Http/Livewire/Server/ServerEditForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@
use App\Models\Server;
use App\Rules\IPHostnameARecord;
use App\Rules\StrNotContain;
use Illuminate\Contracts\View\View;
use Livewire\Component;
use Livewire\Redirector;

class ServerEditForm extends Component
{
public $server;
public Server $server;

public $name;
public string $name;

public $host;
public string $host;

public $port;
public int $port;

public $description;
public string $description;

public function mount()
public function mount(Server $server): void
{
$this->server = $server;
$this->name = $this->server->name;
$this->host = $this->server->host;
$this->port = $this->server->port;
Expand All @@ -29,31 +32,20 @@ public function mount()

/**
* Update the server.
*
* @return void
*/
public function save()
public function save(): Redirector
{
$this->resetErrorBag();
$this->resetValidation();

$this->validate([
'name' => ['required', 'string', new StrNotContain('official')],
'host' => ['required', new StrNotContain('pokemon3d.net'), new IPHostnameARecord()],
'host' => ['required', new StrNotContain('pokemon3d.net'), new IPHostnameARecord(), 'lowercase'],
'port' => ['required', 'integer', 'min:10', 'max:99999'],
'description' => ['nullable', 'string'],
]);

$server = Server::find($this->server->uuid);

if (! $server) {
session()->flash('flash.banner', trans('Server not found.'));
session()->flash('flash.bannerStyle', 'danger');

return redirect()->route('server.index');
}

$server->update([
$this->server->update([
'name' => $this->name,
'host' => $this->host,
'port' => $this->port,
Expand All @@ -65,7 +57,7 @@ public function save()
return redirect()->route('server.index');
}

public function render()
public function render(): View
{
return view('livewire.server.server-edit-form');
}
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"kkomelin/laravel-translatable-string-exporter": "^1.16",
"knuckleswtf/scribe": "^4.21.2",
"laravel/framework": "^9.19",
"laravel/jetstream": "^2.6",
"laravel/jetstream": "^3.0",
"laravel/nova": "4.23.0",
"laravel/sanctum": "^2.14",
"laravel/socialite": "^5.5",
Expand All @@ -69,7 +69,6 @@
"sentry/sentry-laravel": "^2.11",
"socialiteproviders/facebook": "^4.1",
"socialiteproviders/twitch": "^5.3",
"socialiteproviders/twitter": "^4.1",
"spatie/cpu-load-health-check": "^1.0",
"spatie/laravel-activitylog": "^4.4",
"spatie/laravel-health": "^1.19",
Expand Down
Loading

0 comments on commit 7c88253

Please sign in to comment.