'required|url', ]; public function mount() { if (env('APP_ENV') === 'local') { $this->public_repository_url = 'https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify'; $this->port = 3000; } $this->servers = session('currentTeam')->load(['servers'])->servers; } public function chooseServer($server_id) { $this->chosenServer = $server_id; $this->standalone_docker = StandaloneDocker::where('server_id', $server_id)->get(); $this->swarm_docker = SwarmDocker::where('server_id', $server_id)->get(); } public function setDestination($destination_uuid, $destination_type) { $class = "App\Models\\{$destination_type}"; $instance = new $class; $this->chosenDestination = $instance::where('uuid', $destination_uuid)->first(); } public function submit() { $this->validate(); $url = Url::fromString($this->public_repository_url); $git_host = $url->getHost(); $git_repository = $url->getSegment(1) . '/' . $url->getSegment(2); $git_branch = $url->getSegment(4) ?? 'main'; $project = Project::create([ 'name' => fake()->company(), 'description' => fake()->sentence(), 'team_id' => session('currentTeam')->id, ]); $application_init = [ 'name' => fake()->words(2, true), 'git_repository' => $git_repository, 'git_branch' => $git_branch, 'build_pack' => 'nixpacks', 'ports_exposes' => $this->port, 'environment_id' => $project->environments->first()->id, 'destination_id' => $this->chosenDestination->id, 'destination_type' => $this->chosenDestination->getMorphClass(), ]; if ($git_host == 'github.com') { $application_init['source_id'] = GithubApp::where('name', 'Public GitHub')->first()->id; $application_init['source_type'] = GithubApp::class; } elseif ($git_host == 'gitlab.com') { $application_init['source_id'] = GitlabApp::where('name', 'Public GitLab')->first()->id; $application_init['source_type'] = GitlabApp::class; } elseif ($git_host == 'bitbucket.org') { // $application_init['source_id'] = GithubApp::where('name', 'Public Bitbucket')->first()->id; // $application_init['source_type'] = GithubApp::class; } Application::create($application_init); } }