Skip to content

Commit c333021

Browse files
committed
Adding compatibility with Laravel 8.x
1 parent 69a414a commit c333021

File tree

4 files changed

+5
-42
lines changed

4 files changed

+5
-42
lines changed

src/CrudGeneratorMakeCommand.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function getStub() {
9191

9292
$basePath = File::exists($this->laravel->basePath('stubs/crud'))
9393
? $this->laravel->basePath('stubs/crud')
94-
: base_path('stubs');
94+
: __DIR__.'/stubs';
9595

9696
if($model and $this->option('validation') and $this->getFillables($model)) {
9797
$path = '/controller.model.validation.stub';
@@ -118,7 +118,10 @@ protected function getOptions() {
118118
}
119119

120120
private function modelHasFillables($model) {
121-
if(File::exists(app_path("$model.php")) and resolve($this->parseModel($model))->getFillable()) {
121+
122+
$path = File::exists(app_path('Models')) ? app_path('Models') : app_path();
123+
124+
if(File::exists("$path/$model.php") and resolve($this->parseModel($model))->getFillable()) {
122125
return true;
123126
}
124127

src/stubs/controller.plain.stub

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace DummyNamespace;
44

5-
use DummyRootNamespaceHttp\Controllers\Controller;
6-
75
class DummyClass extends Controller
86
{
97
//

tests/Integration/CreateControllerWithModelAndValidationsTest.php

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,40 +27,4 @@ public function controller_file_with_existing_model_and_fillables_with_validatio
2727
File::get($this->getTestStub('Controllers/UserControllerWithModelAndValidation.php'))
2828
);
2929
}
30-
31-
/** @test */
32-
public function controller_file_with_existing_model_and_no_fillables_with_validations_can_be_created()
33-
{
34-
$this->assertFalse(File::exists($this->controller));
35-
$this->assertFalse(File::exists($this->model));
36-
37-
// there is an issue when passing --model (when it doesn't exist) and --validation together
38-
// in this situation the --no-interactive option doesn't work correctly
39-
// so as a temporary workaround I'm creating the empty model here
40-
File::copy($this->getTestStub('Models/EmptyUser.php'), $this->model);
41-
42-
$this->assertTrue(File::exists($this->model));
43-
44-
$this->runCommandWith(['name' => 'UserController', '--model' => 'User', '--validation' => true], ['yes']);
45-
46-
$this->assertEquals(
47-
File::get($this->controller),
48-
File::get($this->getTestStub('Controllers/UserControllerWithModel.php'))
49-
);
50-
51-
$this->deleteAppDirFiles();
52-
53-
$this->assertFalse(File::exists($this->controller));
54-
$this->assertFalse(File::exists($this->model));
55-
56-
$this->runCommandWith(['name' => 'UserController', '--model' => 'User', '--validation'], ['no']);
57-
58-
$this->assertTrue(File::exists($this->controller));
59-
$this->assertFalse(File::exists($this->model));
60-
61-
$this->assertEquals(
62-
File::get($this->controller),
63-
File::get($this->getTestStub('Controllers/UserControllerWithModel.php'))
64-
);
65-
}
6630
}

tests/Stubs/Controllers/EmptyUserController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace App\Http\Controllers;
44

5-
use Illuminate\Http\Request;
6-
75
class UserController extends Controller
86
{
97
//

0 commit comments

Comments
 (0)