argument('name') ?? $this->askRequired('Name (e.g. `Wizard`)', 'name')) ->trim('/') ->trim('\\') ->trim(' ') ->replace('/', '\\'); $componentClass = (string) Str::of($component)->afterLast('\\'); $componentNamespace = Str::of($component)->contains('\\') ? (string) Str::of($component)->beforeLast('\\') : ''; $view = Str::of($component) ->prepend('forms\\components\\') ->explode('\\') ->map(fn ($segment) => Str::kebab($segment)) ->implode('.'); $path = app_path( (string) Str::of($component) ->prepend('Forms\\Components\\') ->replace('\\', '/') ->append('.php'), ); $viewPath = resource_path( (string) Str::of($view) ->replace('.', '/') ->prepend('views/') ->append('.blade.php'), ); if (! $this->option('force') && $this->checkForCollision([ $path, ])) { return static::INVALID; } $this->copyStubToApp('LayoutComponent', $path, [ 'class' => $componentClass, 'namespace' => 'App\\Forms\\Components' . ($componentNamespace !== '' ? "\\{$componentNamespace}" : ''), 'view' => $view, ]); if (! $this->fileExists($viewPath)) { $this->copyStubToApp('LayoutComponentView', $viewPath); } $this->info("Successfully created {$component}!"); return static::SUCCESS; } }