From 1d3b2ddc1cbfcb58708504b9a93caa4db73d790b Mon Sep 17 00:00:00 2001 From: Milwad Khosravi Date: Sat, 1 Jun 2024 16:52:28 +0330 Subject: [PATCH 01/13] add `all_files_are_exists_with_correct_data` test --- tests/Commands/MakeQueryCommandTest.php | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/Commands/MakeQueryCommandTest.php diff --git a/tests/Commands/MakeQueryCommandTest.php b/tests/Commands/MakeQueryCommandTest.php new file mode 100644 index 0000000..ed2372b --- /dev/null +++ b/tests/Commands/MakeQueryCommandTest.php @@ -0,0 +1,59 @@ +artisan('crud:make', ['name' => 'Product']) + ->expectsQuestion('Do you want something extra?', 0) + ->assertSuccessful() + ->expectsOutput('Crud files successfully generated...'); + + // Model + $this->assertFileContains([ + 'assertFileContains([ + 'assertFileContains([ + 'assertFileContains([ + 'assertFileContains(['{{-- Start to write code - milwad-dev --}}'], 'resources/views/products/index.blade.php'); + $this->assertFileContains(['{{-- Start to write code - milwad-dev --}}'], 'resources/views/products/create.blade.php'); + $this->assertFileContains(['{{-- Start to write code - milwad-dev --}}'], 'resources/views/products/edit.blade.php'); + } +} \ No newline at end of file From f3a371e7df4bf78f9d8dd720f31c8c250c81d33f Mon Sep 17 00:00:00 2001 From: Milwad Khosravi Date: Sat, 1 Jun 2024 16:54:05 +0330 Subject: [PATCH 02/13] Update MakeQueryCommandTest.php --- tests/Commands/MakeQueryCommandTest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/Commands/MakeQueryCommandTest.php b/tests/Commands/MakeQueryCommandTest.php index ed2372b..9ded921 100644 --- a/tests/Commands/MakeQueryCommandTest.php +++ b/tests/Commands/MakeQueryCommandTest.php @@ -21,6 +21,14 @@ public function all_files_are_exists_with_correct_data(): void ->assertSuccessful() ->expectsOutput('Crud files successfully generated...'); + $this->ensureCrudFilesExistsWithCorrectData(); + } + + /** + * Ensure all crud files exists with correct data. + */ + protected function ensureCrudFilesExistsWithCorrectData(): void + { // Model $this->assertFileContains([ 'assertFileContains(['{{-- Start to write code - milwad-dev --}}'], 'resources/views/products/index.blade.php'); $this->assertFileContains(['{{-- Start to write code - milwad-dev --}}'], 'resources/views/products/create.blade.php'); $this->assertFileContains(['{{-- Start to write code - milwad-dev --}}'], 'resources/views/products/edit.blade.php'); From 9c6acf75770be031e9b7fe6f711b12aab91ea0f5 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi Date: Sat, 1 Jun 2024 16:56:18 +0330 Subject: [PATCH 03/13] Update MakeQueryCommandTest.php --- tests/Commands/MakeQueryCommandTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/Commands/MakeQueryCommandTest.php b/tests/Commands/MakeQueryCommandTest.php index 9ded921..3f5c309 100644 --- a/tests/Commands/MakeQueryCommandTest.php +++ b/tests/Commands/MakeQueryCommandTest.php @@ -2,6 +2,7 @@ namespace Milwad\LaravelCrod\Tests\Commands; +use Illuminate\Support\Facades\Artisan; use Milwad\LaravelCrod\Tests\TestCase; use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles; use PHPUnit\Framework\Attributes\Test; @@ -21,6 +22,13 @@ public function all_files_are_exists_with_correct_data(): void ->assertSuccessful() ->expectsOutput('Crud files successfully generated...'); + Artisan::call('migrate'); + + $this->artisan('crud:query', ['table_name' => 'products', 'model' => 'Product']) + ->expectsQuestion('Do you want something extra?', 0) + ->assertSuccessful() + ->expectsOutput('Crud files successfully generated...'); + $this->ensureCrudFilesExistsWithCorrectData(); } From 8fdaac242a9ac1b097e89d8eb41e79fbbf891641 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi Date: Sat, 1 Jun 2024 17:01:55 +0330 Subject: [PATCH 04/13] set getEnvironmentSetUp --- tests/Commands/MakeQueryCommandTest.php | 1 + tests/TestCase.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/tests/Commands/MakeQueryCommandTest.php b/tests/Commands/MakeQueryCommandTest.php index 3f5c309..ec3d7ce 100644 --- a/tests/Commands/MakeQueryCommandTest.php +++ b/tests/Commands/MakeQueryCommandTest.php @@ -3,6 +3,7 @@ namespace Milwad\LaravelCrod\Tests\Commands; use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\File; use Milwad\LaravelCrod\Tests\TestCase; use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles; use PHPUnit\Framework\Attributes\Test; diff --git a/tests/TestCase.php b/tests/TestCase.php index 2e0bed4..406d857 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,6 +2,7 @@ namespace Milwad\LaravelCrod\Tests; +use Illuminate\Encryption\Encrypter; use Milwad\LaravelCrod\LaravelCrodServiceProvider; class TestCase extends \Orchestra\Testbench\TestCase @@ -19,4 +20,25 @@ protected function getPackageProviders($app) LaravelCrodServiceProvider::class, ]; } + + /** + * Define environment setup. + * + * @param \Illuminate\Foundation\Application $app + */ + protected function getEnvironmentSetUp($app) + { + // Set default database to use sqlite :memory: + $app['config']->set('database.default', 'testing'); + $app['config']->set('database.connections.testing', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); + + // Set app key + $app['config']->set('app.key', 'base64:'.base64_encode( + Encrypter::generateKey(config()['app.cipher']) + )); + } } From aecaf7efbd59e92f2814dd84b5cebd0349f7672e Mon Sep 17 00:00:00 2001 From: Milwad Khosravi Date: Sun, 2 Jun 2024 10:04:06 +0330 Subject: [PATCH 05/13] Delete MakeQueryCommandTest.php --- tests/Commands/MakeQueryCommandTest.php | 76 ------------------------- 1 file changed, 76 deletions(-) delete mode 100644 tests/Commands/MakeQueryCommandTest.php diff --git a/tests/Commands/MakeQueryCommandTest.php b/tests/Commands/MakeQueryCommandTest.php deleted file mode 100644 index ec3d7ce..0000000 --- a/tests/Commands/MakeQueryCommandTest.php +++ /dev/null @@ -1,76 +0,0 @@ -artisan('crud:make', ['name' => 'Product']) - ->expectsQuestion('Do you want something extra?', 0) - ->assertSuccessful() - ->expectsOutput('Crud files successfully generated...'); - - Artisan::call('migrate'); - - $this->artisan('crud:query', ['table_name' => 'products', 'model' => 'Product']) - ->expectsQuestion('Do you want something extra?', 0) - ->assertSuccessful() - ->expectsOutput('Crud files successfully generated...'); - - $this->ensureCrudFilesExistsWithCorrectData(); - } - - /** - * Ensure all crud files exists with correct data. - */ - protected function ensureCrudFilesExistsWithCorrectData(): void - { - // Model - $this->assertFileContains([ - 'assertFileContains([ - 'assertFileContains([ - 'assertFileContains([ - 'assertFileContains(['{{-- Start to write code - milwad-dev --}}'], 'resources/views/products/index.blade.php'); - $this->assertFileContains(['{{-- Start to write code - milwad-dev --}}'], 'resources/views/products/create.blade.php'); - $this->assertFileContains(['{{-- Start to write code - milwad-dev --}}'], 'resources/views/products/edit.blade.php'); - } -} \ No newline at end of file From f372a607f18af10facef483e0d637b2aebf2d4e6 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi <98118400+milwad-dev@users.noreply.github.com> Date: Sun, 2 Jun 2024 10:22:06 +0330 Subject: [PATCH 06/13] Update README.md --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 90abc22..8e58b74 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,9 @@ [![PHP Version Require](http://poser.pugx.org/milwad/laravel-crod/require/php)](https://packagist.org/packages/milwad/laravel-crod) *** -Laravel crod is a package for implementing CRUD faster and easier.
-You can create controllers, models, migrations, services, repositories, views and requests quickly.
-You can make automatically fillable for models, query for repositories and services, make resource functions for -controllers, and a lot of options. +Laravel crod is a package for implementing CRUD faster and easier. +You can create controllers, models, migrations, services, repositories, views and requests quickly. +You can make automatically fillable for models, query for repositories and services, make resource controllers, and a lot of options. Docs: https://github.com/milwad-dev/laravel-crod/wiki @@ -24,12 +23,13 @@ Docs: https://github.com/milwad-dev/laravel-crod/wiki - `Laravel framework: ^9` - `doctrine/dbal: ^3.6` -| Crod | L7 | L8 | L9 | L10 | -|------|--------------------|--------------------|--------------------|--------------------| -| 1.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | -| 1.1 | :x: | :x: | :white_check_mark: | :white_check_mark: | -| 1.2 | :x: | :x: | :white_check_mark: | :white_check_mark: | -| 1.3 | :x: | :x: | :white_check_mark: | :white_check_mark: | +| Crod | L7 | L8 | L9 | L10 | L11 | +|------|--------------------|--------------------|--------------------|--------------------|--------------------| +| 1.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | +| 1.1 | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| 1.2 | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| 1.3 | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| 1.4 | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | # Installation @@ -39,7 +39,7 @@ Docs: https://github.com/milwad-dev/laravel-crod/wiki composer require milwad/laravel-crod ``` -After publish config files.
+After installation, you need to publish config files.
```bash php artisan vendor:publish --provider="Milwad\LaravelCrod\LaravelCrodServiceProvider" --tag="laravel-crod-config" @@ -47,7 +47,7 @@ php artisan vendor:publish --provider="Milwad\LaravelCrod\LaravelCrodServiceProv # Check active commands -Run the command in cmd or terminal.
+When you install the `Laravel Crod`, a series of commands will be activated for you. For see these commands, you can run below command:
```bash php artisan @@ -55,12 +55,12 @@ php artisan
-You must see this command in the terminal. +You must see this command in your terminal: ![Crod commands](https://s6.uupload.ir/files/carbon_(1)_tqmq.png "Crod commands") # Make CRUD files -This command creates CRUD files, Run this command in the terminal.
+For creating crud files, you need to run the `crud:make` command in your terminal:
```bash php artisan crud:make {name} @@ -76,7 +76,7 @@ php artisan crud:make Product When you execute this command, after creating the files, you will see a list of options that will create a series of additional files for you, which of course are optional, you can choose and if you need, it will create additional files for you such as `seeder`, `factory`, `repository`, etc. -✅ After you can see crod creates files for crud +✅ After, you can see `Laravel Crod` creates crud files such as `Model`, `Controller`, `Form-Requests`, `Migrations` etc. # CRUD query From c8bc57953d69a3b8c1109e685ae642fa91770f0b Mon Sep 17 00:00:00 2001 From: Milwad Khosravi Date: Sun, 2 Jun 2024 11:37:33 +0330 Subject: [PATCH 07/13] Update README.md --- README.md | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8e58b74..663e5e2 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You can make automatically fillable for models, query for repositories and servi Docs: https://github.com/milwad-dev/laravel-crod/wiki -# Requirements +## Requirements *** @@ -31,7 +31,7 @@ Docs: https://github.com/milwad-dev/laravel-crod/wiki | 1.3 | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 1.4 | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -# Installation +## Installation *** @@ -45,7 +45,7 @@ After installation, you need to publish config files.
php artisan vendor:publish --provider="Milwad\LaravelCrod\LaravelCrodServiceProvider" --tag="laravel-crod-config" ``` -# Check active commands +## Check active commands When you install the `Laravel Crod`, a series of commands will be activated for you. For see these commands, you can run below command:
@@ -53,12 +53,9 @@ When you install the `Laravel Crod`, a series of commands will be activated for php artisan ``` -
- -You must see this command in your terminal: ![Crod commands](https://s6.uupload.ir/files/carbon_(1)_tqmq.png "Crod commands") -# Make CRUD files +## Make CRUD files For creating crud files, you need to run the `crud:make` command in your terminal:
@@ -78,9 +75,9 @@ When you execute this command, after creating the files, you will see a list of ✅ After, you can see `Laravel Crod` creates crud files such as `Model`, `Controller`, `Form-Requests`, `Migrations` etc. -# CRUD query +## CRUD query -This command adds query and date to CRUD files.
+
** You must run the migrate command. **
@@ -104,7 +101,7 @@ When write `--id-controller` option add function without route model binding. After you can see add query to service, repository, controller, model, etc. -# CRUD for module +## CRUD for module Run this command in the terminal, This command created CRUD file for module. @@ -120,7 +117,7 @@ php artisan crud:make-module Product When you execute this command, after creating the files, you will see a list of options that will create a series of additional files for you, which of course are optional, you can choose and if you need, it will create additional files for you such as `seeder`, `factory`, `repository`, etc. -# CRUD query from module +## CRUD query from module This command adds query and date to CRUD files for module.
From 324fa40c9288477db1a4acd8e945b6647e415e98 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi Date: Sun, 2 Jun 2024 11:46:24 +0330 Subject: [PATCH 08/13] Update README.md --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 663e5e2..bee08da 100644 --- a/README.md +++ b/README.md @@ -75,31 +75,38 @@ When you execute this command, after creating the files, you will see a list of ✅ After, you can see `Laravel Crod` creates crud files such as `Model`, `Controller`, `Form-Requests`, `Migrations` etc. -## CRUD query +## CRUD Query -
+If you run `crud:query` command, the result is: -** You must run the migrate command. **
+- Add `index`, `create`, `store`, `edit`, `update`, `destroy` function to your controller +- Get all migration columns and move it to your model fillable +- Add `index`, `findById`, `delete` functions to your repositories +- Add `store`, `update` functions to your services +- Add resource route (SOON) + +** You must run the migrate command, before `crud:query` command. **
```bash php artisan migrate ``` -Run this command in the terminal.
+For using automatic query, you can run below command: ```bash php artisan crud:query {table_name} {model} {--id-controller} ``` -For example +For example: ```bash php artisan crud:query products Product ``` When write `--id-controller` option add function without route model binding. +When you add `--id-controller` option, the `Laravel Crod` create crud functions without [Route Model Binding](https://laravel.com/docs/routing#route-model-binding) in controller. -After you can see add query to service, repository, controller, model, etc. +After you can see `Laravel Crod` added query to service, repository, controller, model, etc. ## CRUD for module From da38f47783a45c049f2b0db54820e6992bbc7de3 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi Date: Sun, 2 Jun 2024 11:48:50 +0330 Subject: [PATCH 09/13] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bee08da..ae81cc1 100644 --- a/README.md +++ b/README.md @@ -110,13 +110,13 @@ After you can see `Laravel Crod` added query to service, repository, controller, ## CRUD for module -Run this command in the terminal, This command created CRUD file for module. +If you are using Modular Architecture, you are able to run `crud:make-module` command. This command create a new module and create the default crud files such as `Model`, `Controller`, `Migration`, etc: ```bash php artisan crud:make-module {module_name} ``` -For example +For example: ```bash php artisan crud:make-module Product From e6d86bb8db13fd894ed9c8ebf82a87ae56ab69b1 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi Date: Sun, 2 Jun 2024 11:52:06 +0330 Subject: [PATCH 10/13] Update README.md --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ae81cc1..6655d47 100644 --- a/README.md +++ b/README.md @@ -103,12 +103,11 @@ For example: php artisan crud:query products Product ``` -When write `--id-controller` option add function without route model binding. When you add `--id-controller` option, the `Laravel Crod` create crud functions without [Route Model Binding](https://laravel.com/docs/routing#route-model-binding) in controller. After you can see `Laravel Crod` added query to service, repository, controller, model, etc. -## CRUD for module +## CRUD for Module If you are using Modular Architecture, you are able to run `crud:make-module` command. This command create a new module and create the default crud files such as `Model`, `Controller`, `Migration`, etc: @@ -124,17 +123,18 @@ php artisan crud:make-module Product When you execute this command, after creating the files, you will see a list of options that will create a series of additional files for you, which of course are optional, you can choose and if you need, it will create additional files for you such as `seeder`, `factory`, `repository`, etc. -## CRUD query from module +## CRUD Query for Module -This command adds query and date to CRUD files for module.
+This command adds query and date to CRUD files for module. +This command is similar to `crud:query` command, but this command is for module. if you have a modular you can write your module name and `Laravel Crod` find it automatically. -** You must run your migration file. **
+** You must run your migration file ** ``` php artisan crud:query-module {table_name} {model} {--id-controller} ``` -For example +For example: ```bash php artisan crud:query-module products Product @@ -146,10 +146,9 @@ OR php artisan crud:query-module products Product --id-controller ``` -When write --id-controller option add function without route model binding. - -After you can see add query to service, repository, controller, model, etc for module. +When you add `--id-controller` option, the `Laravel Crod` create crud functions without [Route Model Binding](https://laravel.com/docs/routing#route-model-binding) in controller. +After you can see `Laravel Crod` added query to service, repository, controller, model, ... for your module. ## Custom path You can custom file path in config file. ```config/laravel-crod.php``` From 346f1b61f5f0cf08beefb4211bd47f0c11fdce68 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi Date: Sun, 2 Jun 2024 11:55:06 +0330 Subject: [PATCH 11/13] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6655d47..7f0d489 100644 --- a/README.md +++ b/README.md @@ -149,9 +149,13 @@ php artisan crud:query-module products Product --id-controller When you add `--id-controller` option, the `Laravel Crod` create crud functions without [Route Model Binding](https://laravel.com/docs/routing#route-model-binding) in controller. After you can see `Laravel Crod` added query to service, repository, controller, model, ... for your module. + ## Custom path -You can custom file path in config file. ```config/laravel-crod.php``` +You can custom file path in config file. `````` + +With `Laravel Crod` config, you can customize the commands, for example you want to set the route file name. +This config file exists in `config/laravel-crod.php`: ```php Milwad Khosravi From f82244a2eb3433057071c752a5081d410486c60e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:46:51 +0000 Subject: [PATCH 12/13] Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 2.1.0 to 2.2.0. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v2.1.0...v2.2.0) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/dependabot-auto-merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index c09678f..9db8ce3 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -13,7 +13,7 @@ jobs: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v2.1.0 + uses: dependabot/fetch-metadata@v2.2.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" compat-lookup: true From 98ea8f66a9bb323afc151dfbde2da1e34bfc098f Mon Sep 17 00:00:00 2001 From: Ali Salehi <111766206+alisalehi1380@users.noreply.github.com> Date: Sun, 4 Aug 2024 13:21:46 +0330 Subject: [PATCH 13/13] fix badges --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7f0d489..276633a 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,16 @@ -[![Latest Stable Version](http://poser.pugx.org/milwad/laravel-crod/v)](https://packagist.org/packages/milwad/laravel-crod) -[![Total Downloads](http://poser.pugx.org/milwad/laravel-crod/downloads)](https://packagist.org/packages/milwad/laravel-crod) -[![License](http://poser.pugx.org/milwad/laravel-crod/license)](https://packagist.org/packages/milwad/laravel-crod) +[![PHP Version Require](https://img.shields.io/packagist/dependency-v/milwad/laravel-crod/php.svg)](https://packagist.org/packages/milwad/laravel-crod) +[![Latest Stable Version](https://img.shields.io/packagist/v/milwad/laravel-crod.svg)](https://packagist.org/packages/milwad/laravel-crod) +[![Total Downloads](https://img.shields.io/packagist/dt/milwad/laravel-crod.svg)](https://packagist.org/packages/milwad/laravel-crod) +[![License](https://img.shields.io/packagist/l/milwad/laravel-crod.svg)](https://packagist.org/packages/milwad/laravel-crod) [![Passed Tests](https://github.com/milwad-dev/laravel-crod/actions/workflows/run-tests.yml/badge.svg)](https://github.com/milwad-dev/laravel-crod/actions/workflows/run-tests.yml) -[![PHP Version Require](http://poser.pugx.org/milwad/laravel-crod/require/php)](https://packagist.org/packages/milwad/laravel-crod) *** Laravel crod is a package for implementing CRUD faster and easier. -You can create controllers, models, migrations, services, repositories, views and requests quickly. -You can make automatically fillable for models, query for repositories and services, make resource controllers, and a lot of options. +You can quickly create controllers, models, migrations, services, repositories, views and requests. +You can make it automatically fillable for models, query for repositories and services, make resource controllers, and have a lot of options. Docs: https://github.com/milwad-dev/laravel-crod/wiki