coolify/app/Http/Livewire/Source/Github/Create.php

51 lines
1.6 KiB
PHP
Raw Normal View History

2023-05-08 13:36:49 +02:00
<?php
2023-05-31 22:23:17 +02:00
namespace App\Http\Livewire\Source\Github;
2023-05-08 13:36:49 +02:00
use App\Models\GithubApp;
use Livewire\Component;
class Create extends Component
{
public string $name;
public string|null $organization = null;
public string $api_url = 'https://api.github.com';
public string $html_url = 'https://github.com';
public string $custom_user = 'git';
public int $custom_port = 22;
public bool $is_system_wide = false;
public function mount()
{
2023-05-24 14:26:50 +02:00
$this->name = generate_random_name();
2023-05-08 13:36:49 +02:00
}
2023-05-08 13:36:49 +02:00
public function createGitHubApp()
{
try {
$this->validate([
"name" => 'required|string',
"organization" => 'nullable|string',
"api_url" => 'required|string',
"html_url" => 'required|string',
"custom_user" => 'required|string',
"custom_port" => 'required|int',
"is_system_wide" => 'required|bool',
]);
2023-05-09 11:33:50 +02:00
$github_app = GithubApp::create([
2023-05-08 13:36:49 +02:00
'name' => $this->name,
'organization' => $this->organization,
'api_url' => $this->api_url,
'html_url' => $this->html_url,
'custom_user' => $this->custom_user,
'custom_port' => $this->custom_port,
'is_system_wide' => $this->is_system_wide,
'team_id' => session('currentTeam')->id,
]);
2023-05-09 11:33:50 +02:00
redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]);
2023-05-08 13:36:49 +02:00
} catch (\Exception $e) {
2023-06-09 15:55:21 +02:00
return general_error_handler(err: $e, that: $this);
2023-05-08 13:36:49 +02:00
}
}
}