Skip to content

milwad-dev/laravel-crod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel crod


Laravel crod is a package for implementing CRUD faster & easier. You can create controllers, models, migrations, services, repositories, views and requests quickly. You can make automatically fillable for models, query for repositories & services, make resource functions for controllers.

Requirements


  • PHP >= 7.4
  • doctrine/dbal > 3.3
  • Laravel framework >= 7

Installation


composer require milwad/laravel-crod

After publish config files.

php artisan vendor:publish --provider="Milwad\LaravelCrod\LaravelCrodServiceProvider" --tag="config"

Check active commands

Run the command in cmd or terminal.

php artisan

You must see this command in the terminal. Crod commands

Make CRUD files

This command creates CRUD files, Run this command in the terminal.

php artisan crud:make {name} {--service} {--repo} {--test}

For example

php artisan crud:make Product --service --repo --test

  • When write service option add service file.
  • When write repo option add repository file.
  • When write test option add tests file.
  • ✅ After you can see crod creates files for crud

    CRUD query

    This command adds query & date to CRUD files.

    ** You must run the migrate command. **

    php artisan migrate

    Run this command in the terminal.

    php artisan crud:query {table_name} {model} {--id-controller}

    For example

    php artisan crud:query products Product

    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

    Run this command in the terminal, This command created CRUD file for module.

    php artisan crud:make-module {module_name} {--service} {--repo} {--test}

    For example

    php artisan crud:make-module Product --service --repo --test

    CRUD query from module

    This command adds query & date to CRUD files for module.

    ** You must run your migration file. **

    php artisan crud:query-module {table_name} {model} {--id-controller}
    

    For example

    php artisan crud:query-module products Product

    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.

    Custom path

    You can custom file path in config file. config/laravel-crod.php

    <?php
    
    return [
        /**
         * Modules config.
         *
         * You can make custom modules with special folders ...
         */
        'modules' => [
            'module_namespace' => 'Modules',
            'repository_namespace' => 'Repo',
    
            'model_path' => 'Entities',
            'migration_path' => 'Database\Migrations',
            'controller_path' => 'Http\Controllers',
            'request_path' => 'Http\Requests',
            'view_path' => 'Resources\Views',
            'service_path' => 'Services',
            'repository_path' => 'Repositories',
            'feature_test_path' => 'Tests\Feature',
            'unit_test_path' => 'Tests\Unit',
        ],
    
        /**
         * Queries.
         */
        'queries' => [
            'except_columns_in_fillable' => [
                'id', 'updated_at', 'created_at'
            ]
        ]
    ];

    This config file is very helpful to custom path or latest name file.

    License

    • This package is created and modified by Milwad Khosravi for Laravel >= 7 and is released under the MIT License.

    Testing

    Run the tests with:

    vendor/bin/phpunit
    composer test
    composer coverage

    Contributing

    This project exists thanks to all the people who contribute. CONTRIBUTING

    Security

    If you've found a bug regarding security please mail milwad.dev@gmail.com instead of using the issue tracker.