refactoring
This commit is contained in:
32
app/Http/Livewire/Dashboard.php
Normal file
32
app/Http/Livewire/Dashboard.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Models\S3Storage;
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
|
||||
class Dashboard extends Component
|
||||
{
|
||||
public int $projects = 0;
|
||||
public int $servers = 0;
|
||||
public int $s3s = 0;
|
||||
public int $resources = 0;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->servers = Server::ownedByCurrentTeam()->get()->count();
|
||||
$this->s3s = S3Storage::ownedByCurrentTeam()->get()->count();
|
||||
$projects = Project::ownedByCurrentTeam()->get();
|
||||
foreach ($projects as $project) {
|
||||
$this->resources += $project->applications->count();
|
||||
$this->resources += $project->postgresqls->count();
|
||||
}
|
||||
$this->projects = $projects->count();
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.dashboard');
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Dev;
|
||||
|
||||
use App\Models\S3Storage;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
|
||||
class S3Test extends Component
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
public $s3;
|
||||
public $file;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->s3 = S3Storage::first();
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
$this->validate([
|
||||
'file' => 'required|max:150', // 1MB Max
|
||||
]);
|
||||
set_s3_target($this->s3);
|
||||
$this->file->storeAs('files', $this->file->getClientOriginalName(), 'custom-s3');
|
||||
$this->emit('success', 'File uploaded successfully.');
|
||||
} catch (\Throwable $th) {
|
||||
return general_error_handler($th, $this, false);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_files()
|
||||
{
|
||||
set_s3_target($this->s3);
|
||||
dd(Storage::disk('custom-s3')->files('files'));
|
||||
}
|
||||
}
|
||||
20
app/Http/Livewire/Server/All.php
Normal file
20
app/Http/Livewire/Server/All.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Server;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Livewire\Component;
|
||||
|
||||
class All extends Component
|
||||
{
|
||||
public ?Collection $servers = null;
|
||||
|
||||
public function mount () {
|
||||
$this->servers = Server::ownedByCurrentTeam()->get();
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.server.all');
|
||||
}
|
||||
}
|
||||
19
app/Http/Livewire/Server/Show.php
Normal file
19
app/Http/Livewire/Server/Show.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Server;
|
||||
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
|
||||
class Show extends Component
|
||||
{
|
||||
public ?Server $server = null;
|
||||
public function mount()
|
||||
{
|
||||
$this->server = Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->firstOrFail();
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.server.show');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user