mirror of
https://github.com/coollabsio/coolify.git
synced 2026-06-19 07:35:25 +00:00
062ad57740
Authorize cloud provider token access, audit sensitive operations, and standardize public IDs across deployment and resource flows.
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Project;
|
|
|
|
use App\Models\Project;
|
|
use App\Support\ValidationPatterns;
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
use Livewire\Component;
|
|
|
|
class AddEmpty extends Component
|
|
{
|
|
use AuthorizesRequests;
|
|
|
|
public string $name;
|
|
|
|
public string $description = '';
|
|
|
|
protected function rules(): array
|
|
{
|
|
return [
|
|
'name' => ValidationPatterns::nameRules(),
|
|
'description' => ValidationPatterns::descriptionRules(),
|
|
];
|
|
}
|
|
|
|
protected function messages(): array
|
|
{
|
|
return ValidationPatterns::combinedMessages();
|
|
}
|
|
|
|
public function submit()
|
|
{
|
|
try {
|
|
$this->authorize('create', Project::class);
|
|
$this->validate();
|
|
$project = Project::create([
|
|
'name' => $this->name,
|
|
'description' => $this->description,
|
|
'team_id' => currentTeam()->id,
|
|
'uuid' => new_public_id(),
|
|
]);
|
|
|
|
$productionEnvironment = $project->environments()->where('name', 'production')->first();
|
|
|
|
return redirect()->route('project.resource.index', [
|
|
'project_uuid' => $project->uuid,
|
|
'environment_uuid' => $productionEnvironment->uuid,
|
|
]);
|
|
} catch (\Throwable $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
}
|