From 4097455d4729ad30c9411a3ad81145915644d6e9 Mon Sep 17 00:00:00 2001 From: Sohel Amin Date: Thu, 14 Mar 2024 00:01:18 +0600 Subject: [PATCH] Refactor view files --- composer.json | 2 +- src/Commands/CrudApiCommand.php | 4 ++-- src/Commands/CrudCommand.php | 4 ++-- src/stubs/views/blade/create.blade.stub | 4 ++-- src/stubs/views/blade/edit.blade.stub | 4 ++-- src/stubs/views/blade/index.blade.stub | 17 +++++++++++------ src/stubs/views/blade/show.blade.stub | 2 +- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index a73cac9..dbaecf9 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "mockery/mockery": "^1.0", "phpunit/phpunit": "^5.7|^8.0|^9.0", "orchestra/testbench": "^3.3|^4.0|^5.0", - "laravel/breeze": "^1.10" + "laravel/breeze": "^1.10|^2.0" }, "autoload": { "psr-4": { diff --git a/src/Commands/CrudApiCommand.php b/src/Commands/CrudApiCommand.php index ae4630c..16adbc6 100644 --- a/src/Commands/CrudApiCommand.php +++ b/src/Commands/CrudApiCommand.php @@ -116,7 +116,7 @@ public function handle() $softDeletes = $this->option('soft-deletes'); - $this->call('crud:api-controller', ['name' => $controllerNamespace . $name . 'Controller', '--crud-name' => $name, '--model-name' => $modelName, '--model-namespace' => $modelNamespace, '--pagination' => $perPage, '--validations' => $validations]); + $this->call('crud:api-controller', ['name' => $controllerNamespace . $modelName . 'Controller', '--crud-name' => $name, '--model-name' => $modelName, '--model-namespace' => $modelNamespace, '--pagination' => $perPage, '--validations' => $validations]); $this->call('crud:model', ['name' => $modelNamespace . $modelName, '--fillable' => $fillable, '--table' => $tableName, '--pk' => $primaryKey, '--relationships' => $relationships, '--soft-deletes' => $softDeletes]); $this->call('crud:migration', ['name' => $migrationName, '--schema' => $migrationFields, '--pk' => $primaryKey, '--indexes' => $indexes, '--foreign-keys' => $foreignKeys, '--soft-deletes' => $softDeletes]); @@ -124,7 +124,7 @@ public function handle() $routeFile = base_path('routes/api.php'); if (file_exists($routeFile) && (strtolower($this->option('route')) === 'yes')) { - $this->controller = ($controllerNamespace != '') ? $controllerNamespace . $name . 'Controller' : $name . 'Controller'; + $this->controller = ($controllerNamespace != '') ? $controllerNamespace . $modelName . 'Controller' : $modelName . 'Controller'; $isAdded = File::append($routeFile, "\n" . implode("\n", $this->addRoutes())); diff --git a/src/Commands/CrudCommand.php b/src/Commands/CrudCommand.php index 63984b4..10cdb1c 100644 --- a/src/Commands/CrudCommand.php +++ b/src/Commands/CrudCommand.php @@ -125,7 +125,7 @@ public function handle() $formHelper = $this->option('form-helper'); $softDeletes = $this->option('soft-deletes'); - $this->call('crud:controller', ['name' => $controllerNamespace . $name . 'Controller', '--crud-name' => $name, '--model-name' => $modelName, '--model-namespace' => $modelNamespace, '--view-path' => $viewPath, '--route-group' => $routeGroup, '--pagination' => $perPage, '--fields' => $fields, '--validations' => $validations]); + $this->call('crud:controller', ['name' => $controllerNamespace . $modelName . 'Controller', '--crud-name' => $name, '--model-name' => $modelName, '--model-namespace' => $modelNamespace, '--view-path' => $viewPath, '--route-group' => $routeGroup, '--pagination' => $perPage, '--fields' => $fields, '--validations' => $validations]); $this->call('crud:model', ['name' => $modelNamespace . $modelName, '--fillable' => $fillable, '--table' => $tableName, '--pk' => $primaryKey, '--relationships' => $relationships, '--soft-deletes' => $softDeletes]); $this->call('crud:migration', ['name' => $migrationName, '--schema' => $migrationFields, '--pk' => $primaryKey, '--indexes' => $indexes, '--foreign-keys' => $foreignKeys, '--soft-deletes' => $softDeletes]); $this->call('crud:view', ['name' => $name, '--fields' => $fields, '--validations' => $validations, '--view-path' => $viewPath, '--route-group' => $routeGroup, '--localize' => $localize, '--pk' => $primaryKey, '--form-helper' => $formHelper]); @@ -137,7 +137,7 @@ public function handle() $routeFile = base_path('routes/web.php'); if (file_exists($routeFile) && (strtolower($this->option('route')) === 'yes')) { - $this->controller = ($controllerNamespace != '') ? $controllerNamespace . $name . 'Controller' : $name . 'Controller'; + $this->controller = ($controllerNamespace != '') ? $controllerNamespace . $modelName . 'Controller' : $modelName . 'Controller'; $isAdded = File::append($routeFile, "\n" . implode("\n", $this->addRoutes())); diff --git a/src/stubs/views/blade/create.blade.stub b/src/stubs/views/blade/create.blade.stub index 9c21b54..ce22fc2 100644 --- a/src/stubs/views/blade/create.blade.stub +++ b/src/stubs/views/blade/create.blade.stub @@ -16,7 +16,7 @@ Create %%modelName%%
- < Back + < Back
@@ -28,7 +28,7 @@ @endif -
+ @csrf() @include ('%%viewTemplateDir%%.form', ['formMode' => 'create'])
diff --git a/src/stubs/views/blade/edit.blade.stub b/src/stubs/views/blade/edit.blade.stub index 76b7900..e3d5720 100644 --- a/src/stubs/views/blade/edit.blade.stub +++ b/src/stubs/views/blade/edit.blade.stub @@ -16,7 +16,7 @@ Edit %%modelName%% #{{ $%%crudNameSingular%%->%%primaryKey%% }}
- < Back + < Back
@@ -28,7 +28,7 @@ @endif -
+ {{ method_field('PATCH') }} @csrf() diff --git a/src/stubs/views/blade/index.blade.stub b/src/stubs/views/blade/index.blade.stub index ece898f..f5e8b31 100644 --- a/src/stubs/views/blade/index.blade.stub +++ b/src/stubs/views/blade/index.blade.stub @@ -15,14 +15,19 @@ %%crudNameCap%%
@if (session()->has('flash_message')) -
- {{ session('flash_message') }} +
+ + {{ session('flash_message') }} + +
@endif @@ -40,10 +45,10 @@ {{ $loop->iteration }} %%formBodyHtml%% - - + + - + {{ method_field('DELETE') }} @csrf() diff --git a/src/stubs/views/blade/show.blade.stub b/src/stubs/views/blade/show.blade.stub index ac9483f..f8f3fbf 100644 --- a/src/stubs/views/blade/show.blade.stub +++ b/src/stubs/views/blade/show.blade.stub @@ -16,7 +16,7 @@ Show %%modelName%%