From 3b2a9ceda2e675fe0c3d3f845433663ac416c97d Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 20 Aug 2017 19:09:58 +0800 Subject: [PATCH] Added Model class --- src/CrudMake.php | 39 +++++++++++++++++++++++++++++++++++++++ src/ServiceProvider.php | 25 +++++++++++++++++++++++++ tests/CrudMakeCommandTest.php | 30 ++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 src/CrudMake.php create mode 100644 src/ServiceProvider.php create mode 100644 tests/CrudMakeCommandTest.php diff --git a/src/CrudMake.php b/src/CrudMake.php new file mode 100644 index 0000000..62cdf7c --- /dev/null +++ b/src/CrudMake.php @@ -0,0 +1,39 @@ +argument('name'); + $pluralModel = str_plural($model); + + $this->callSilent('make:model', ['name' => $model]); + $this->info($model.' model generated.'); + + $this->info('CRUD files generated successfully!'); + } +} diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php new file mode 100644 index 0000000..9c62689 --- /dev/null +++ b/src/ServiceProvider.php @@ -0,0 +1,25 @@ +app->runningInConsole()) { + $this->commands([ + CrudMake::class, + ]); + } + } + + public function boot() + { + + } +} diff --git a/tests/CrudMakeCommandTest.php b/tests/CrudMakeCommandTest.php new file mode 100644 index 0000000..2253f8c --- /dev/null +++ b/tests/CrudMakeCommandTest.php @@ -0,0 +1,30 @@ +artisan('make:crud', ['name' => 'Test', '--no-interaction' => true]); + + $this->assertFileExists(app_path('Test.php')); + // $this->assertFileExists(app_path('Http/Controllers/TestsController.php')); + // $this->assertFileExists(resource_path('views/tests/index.blade.php')); + // $this->assertFileExists(resource_path('views/tests/forms.blade.php')); + // $this->assertFileExists(base_path('tests/Feature/ManageTestsTest.php')); + // $this->assertFileExists(base_path('tests/Unit/Models/TestTest.php')); + + exec('rm '.app_path('Test.php')); + // exec('rm -r '.app_path('Http/Controllers')); + // exec('rm -r '.resource_path('views/tests')); + // exec('rm '.base_path('tests/Feature/ManageTestsTest.php')); + // exec('rm '.base_path('tests/Unit/ModelsTestTest.php')); + } +}