2024-01-07 15:23:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Livewire\Project;
|
|
|
|
|
|
2024-03-22 10:34:15 +00:00
|
|
|
use App\Models\PrivateKey;
|
2024-01-07 15:23:41 +00:00
|
|
|
use App\Models\Project;
|
|
|
|
|
use App\Models\Server;
|
2024-11-22 14:28:06 +00:00
|
|
|
use Illuminate\Support\Facades\Redirect;
|
2024-01-07 15:23:41 +00:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class Index extends Component
|
|
|
|
|
{
|
|
|
|
|
public $projects;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-01-07 15:23:41 +00:00
|
|
|
public $servers;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-03-22 10:34:15 +00:00
|
|
|
public $private_keys;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
|
|
|
|
public function mount()
|
|
|
|
|
{
|
2024-03-22 10:34:15 +00:00
|
|
|
$this->private_keys = PrivateKey::ownedByCurrentTeam()->get();
|
2024-10-09 21:45:57 +00:00
|
|
|
$this->projects = Project::ownedByCurrentTeam()->get()->map(function ($project) {
|
2024-10-10 07:45:13 +00:00
|
|
|
$project->settingsRoute = route('project.edit', ['project_uuid' => $project->uuid]);
|
2024-10-09 21:45:57 +00:00
|
|
|
|
|
|
|
|
return $project;
|
|
|
|
|
});
|
2024-01-07 15:23:41 +00:00
|
|
|
$this->servers = Server::ownedByCurrentTeam()->count();
|
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-01-07 15:23:41 +00:00
|
|
|
public function render()
|
|
|
|
|
{
|
|
|
|
|
return view('livewire.project.index');
|
|
|
|
|
}
|
2024-11-22 14:28:06 +00:00
|
|
|
|
|
|
|
|
public function navigateToProject($projectUuid)
|
|
|
|
|
{
|
2025-01-07 14:31:43 +00:00
|
|
|
$project = Project::where('uuid', $projectUuid)->first();
|
2024-11-22 14:30:17 +00:00
|
|
|
|
|
|
|
|
if ($project && $project->environments->count() === 1) {
|
|
|
|
|
return Redirect::route('project.resource.index', [
|
|
|
|
|
'project_uuid' => $projectUuid,
|
|
|
|
|
'environment_uuid' => $project->environments->first()->uuid,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-22 14:28:06 +00:00
|
|
|
return Redirect::route('project.show', ['project_uuid' => $projectUuid]);
|
|
|
|
|
}
|
2024-01-07 15:23:41 +00:00
|
|
|
}
|