This commit is contained in:
Ryan Scherler
2020-04-05 19:45:55 -07:00
parent 1cb2b60a5e
commit 1710f8940d
2 changed files with 17 additions and 10 deletions
+4 -4
View File
@@ -5,7 +5,7 @@ namespace Filament\Http\Livewire;
use Filament\Support\Livewire\FormComponent;
use Filament\Support\Fields\ArrayField;
use Filament\Support\Fields\Field;
use Filament\Contracts\Dummy as DummyContract;
// use Filament\Contracts\Dummy as DummyContract;
class DummyComponent extends FormComponent
{
@@ -23,13 +23,13 @@ class DummyComponent extends FormComponent
public function success()
{
$DummyClass = app(DummyContract::class);
$DummyClass::create($this->form_data);
// $DummyClass = app(DummyContract::class);
// $DummyClass::create($this->form_data);
}
public function saveAndGoBackResponse()
{
return redirect()->route('filament.admin.DummyRoute.index');
return redirect('/'); // redirect()->route('filament.admin.dashboard');
}
public function render()
+13 -6
View File
@@ -10,24 +10,31 @@ use Filament;
class MakeForm extends Command
{
protected $signature = 'filament:form {name} {--model=Model}';
protected $signature = 'filament:form {name} {--model=Model} {--package}';
protected $description = 'Make a new Filament Livewire form component.';
public function handle()
{
$componentName = Str::studly($this->argument('name'));
$stub = File::get(__DIR__ . '/../../resources/stubs/component.stub');
$stub = str_replace('DummyComponent', $this->argument('name'), $stub);
$stub = str_replace('DummyComponent', $componentName, $stub);
$stub = str_replace('Contracts\Dummy', 'Contracts\\' . $this->option('model'), $stub);
$stub = str_replace('DummyClass', lcFirst($this->option('model')).'Class', $stub);
$stub = str_replace('DummyContract', $this->option('model').'Contract', $stub);
$stub = str_replace('DummyRoute', Str::slug(Str::plural($this->option('model'))), $stub);
$stub = str_replace('DummyView', Str::kebab($this->argument('name')), $stub);
$stub = str_replace('DummyView', Str::kebab($componentName), $stub);
if (!$this->option('package')) {
$stub = str_replace('namespace Filament', 'namespace App', $stub);
}
$path = __DIR__ . '/../Http/Livewire/' . $this->argument('name') . '.php';
$formPath = $this->option('package') ? __DIR__ . '/../Http/Livewire/' : app_path('Http/Livewire/');
$path = $formPath . $componentName . '.php';
if (!File::exists($path) || $this->confirm($this->argument('name') . ' already exists. Overwrite it?')) {
if (!File::exists($path) || $this->confirm($componentName . ' already exists. Overwrite it?')) {
File::put($path, $stub);
$this->info($this->argument('name') . ' was made!');
$this->info($componentName . ' was created in '. $formPath);
}
}
}