Replace create() with forceCreate() across internal model creation operations to bypass mass assignment protection. This is appropriate for internal code that constructs complete model state without user input. Add InternalModelCreationMassAssignmentTest to ensure internal model creation behavior is properly tested. Optimize imports by using shortened Livewire attribute references and removing unused imports.
21 lines
547 B
PHP
21 lines
547 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Project\New;
|
|
|
|
use App\Models\Project;
|
|
use Livewire\Component;
|
|
use Visus\Cuid2\Cuid2;
|
|
|
|
class EmptyProject extends Component
|
|
{
|
|
public function createEmptyProject()
|
|
{
|
|
$project = Project::forceCreate([
|
|
'name' => generate_random_name(),
|
|
'team_id' => currentTeam()->id,
|
|
'uuid' => (string) new Cuid2,
|
|
]);
|
|
|
|
return redirectRoute($this, 'project.show', ['project_uuid' => $project->uuid, 'environment_uuid' => $project->environments->first()->uuid]);
|
|
}
|
|
}
|