parser = new ComponentParser( config('livewire.class_namespace'), config('livewire.view_path'), $this->argument('name') ); if (! $force = $this->option('force')) { $shouldContinue = $this->confirm( "Are you sure you want to delete the following files?\n\n{$this->parser->relativeClassPath()}\n{$this->parser->relativeViewPath()}\n" ); if (! $shouldContinue) { return; } } $inline = $this->option('inline'); $test = $this->option('test'); $class = $this->removeClass($force); if (! $inline) $view = $this->removeView($force); if ($test) $test = $this->removeTest($force); $this->refreshComponentAutodiscovery(); $this->line(" COMPONENT DESTROYED 🦖💫\n"); $class && $this->line("CLASS: {$this->parser->relativeClassPath()}"); if (! $inline) $view && $this->line("VIEW: {$this->parser->relativeViewPath()}"); if ($test) $test && $this->line("Test: {$this->parser->relativeTestPath()}"); } protected function removeTest($force = false) { $testPath = $this->parser->testPath(); if (! File::exists($testPath) && ! $force) { $this->line(" WHOOPS-IE-TOOTLES 😳 \n"); $this->line("Test doesn't exist: {$this->parser->relativeTestPath()}"); return false; } File::delete($testPath); return $testPath; } protected function removeClass($force = false) { $classPath = $this->parser->classPath(); if (! File::exists($classPath) && ! $force) { $this->line(" WHOOPS-IE-TOOTLES 😳 \n"); $this->line("Class doesn't exist: {$this->parser->relativeClassPath()}"); return false; } File::delete($classPath); return $classPath; } protected function removeView($force = false) { $viewPath = $this->parser->viewPath(); if (! File::exists($viewPath) && ! $force) { $this->line("View doesn't exist: {$this->parser->relativeViewPath()}"); return false; } File::delete($viewPath); return $viewPath; } }