Skip to content

Commit

Permalink
Merge pull request #207 from Laravel-Backpack/do-not-use-request-if-n…
Browse files Browse the repository at this point in the history
…o-request-validation-set

Do not use request if no request validation set
  • Loading branch information
pxpm authored Oct 15, 2024
2 parents fcecfbd + b2548ca commit cd193ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Console/Commands/CrudBackpackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function handle()
]);

// if the application uses cached routes, we should rebuild the cache so the previous added route will
// be acessible without manually clearing the route cache.
// be accessible without manually clearing the route cache.
if (app()->routesAreCached()) {
$this->call('route:cache');
}
Expand Down
7 changes: 7 additions & 0 deletions src/Console/Commands/CrudControllerBackpackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ protected function replaceRequest(&$stub)
$stub = str_replace(' CRUD::setValidation(DummyClassRequest::class);'.PHP_EOL, '', $stub);
}

if ($validation !== 'request') {
$stub = str_replace('use App\Http\Requests\DummyModelClassRequest;', '', $stub);
} else {
// add a new line after the use statement
$stub = str_replace('use App\Http\Requests\DummyModelClassRequest;', "use App\Http\Requests\DummyModelClassRequest;\n", $stub);
}

return $this;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Console/stubs/crud-controller.stub
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

namespace DummyNamespace;

use App\Http\Requests\DummyModelClassRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;

use App\Http\Requests\DummyModelClassRequest;
/**
* Class DummyClassCrudController
* @package App\Http\Controllers\Admin
Expand Down

0 comments on commit cd193ad

Please sign in to comment.