InfyOmLabs / laravel-generator

API and Admin Panel CRUD Generator for Laravel.
https://www.infyom.com/open-source
MIT License
3.79k stars 812 forks source link

Modular App Package #371

Closed arieltoledo closed 5 years ago

arieltoledo commented 7 years ago

Hi, I wonder if the generator will work with [(https://github.com/nWidart/laravel-modules.)]

illuminate3 commented 7 years ago

I am currently working towards this.

Game plan:

  1. build all files in a regular laravel app setup
  2. redo all namespaces to file nWidart's module by hand

I do not think that this package will do that for you automatically ... however, please note that I have not tried changing any default settings in the config files. But still ... doing a search and replace in sublime is very easy.

arieltoledo commented 7 years ago

@illuminate3 ll,be nice if you write a small tutorial on this.

illuminate3 commented 7 years ago

HI,

I have finally had a chance to play around with my idea. I am not using the module package right now but you can change the config file for the generator.

'controller' => app_path('Http/Controllers/User/'),

I added the "User" to the end and then ran everything. I would think that to do this for a module you would have to create the module first and then change the config file to point to the all the directories in the module.

I haven't had a chance to move routes around but I'm thinking it should be really easy to do.

shemgp commented 6 years ago

Using melihovv/laravel-package-generator and changing laravel_generate.php to bellow enables generation of CRUD inside packages:

<?php
$package_path = 'packages/shemgp/rbac_manager/src/';
$package_namespace = 'shemgp\\rbac_manager\\';
return [

    /*
    |--------------------------------------------------------------------------
    | Paths
    |--------------------------------------------------------------------------
    |
    */

    'path' => [

        'migration'         => base_path($package_path.'database/migrations/'),

        'model'             => base_path($package_path.'app/Models/'),

        'datatables'        => base_path($package_path.'app/DataTables/'),

        'repository'        => base_path($package_path.'app/Repositories/'),

        'routes'            => base_path($package_path.'routes/web.php'),

        'api_routes'        => base_path($package_path.'routes/api.php'),

        'request'           => base_path($package_path.'app/Http/Requests/'),

        'api_request'       => base_path($package_path.'app/Http/Requests/API/'),

        'controller'        => base_path($package_path.'app/Http/Controllers/'),

        'api_controller'    => base_path($package_path.'app/Http/Controllers/API/'),

        'test_trait'        => base_path($package_path.'tests/traits/'),

        'repository_test'   => base_path($package_path.'tests/'),

        'api_test'          => base_path($package_path.'tests/'),

        'views'             => base_path($package_path.'resources/views/'),

        'schema_files'      => base_path($package_path.'resources/model_schemas/'),

        'templates_dir'     => base_path($package_path.'resources/infyom/infyom-generator-templates/'),

        'modelJs'           => base_path($package_path.'resources/assets/js/models/'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Namespaces
    |--------------------------------------------------------------------------
    |
    */

    'namespace' => [

        'model'             => $package_namespace.'App\Models',

        'datatables'        => $package_namespace.'App\DataTables',

        'repository'        => $package_namespace.'App\Repositories',

        'controller'        => $package_namespace.'App\Http\Controllers',

        'api_controller'    => $package_namespace.'App\Http\Controllers\API',

        'request'           => $package_namespace.'App\Http\Requests',

        'api_request'       => $package_namespace.'App\Http\Requests\API',
    ],

    /*
    |--------------------------------------------------------------------------
    | Templates
    |--------------------------------------------------------------------------
    |
    */

    'templates'         => 'adminlte-templates',

    'default_layout'    => 'back-project::layouts.admin',

    /*
    |--------------------------------------------------------------------------
    | Model extend class
    |--------------------------------------------------------------------------
    |
    */

    'model_extend_class' => env('ENABLE_USER_TRACKING_MODEL') == 'true' ? 'InfyOm\Generator\Model\UserTrackingBaseModel' : 'Eloquent',

    /*
    |--------------------------------------------------------------------------
    | API routes prefix & version
    |--------------------------------------------------------------------------
    |
    */

    'api_prefix'  => 'api',

    'api_version' => 'v1',

    /*
    |--------------------------------------------------------------------------
    | Options
    |--------------------------------------------------------------------------
    |
    */

    'options' => [

        'softDelete' => true,

        'tables_searchable_default' => false,

        'hidden_fields' => env('ENABLE_USER_TRACKING_MODEL') == 'true' ? [
            'user_id'
        ] : [],

        'excluded_fields' => [
            'created_at',
            'updated_at',
            'deleted_at',
            'id'
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Prefixes
    |--------------------------------------------------------------------------
    |
    */

    'prefixes' => [

        'route' => '',  // using admin will create route('admin.?.index') type routes

        'path' => '',

        'view' => '',  // using backend will create return view('backend.?.index') type the backend views directory

        'public' => '',
    ],

    /*
    |--------------------------------------------------------------------------
    | Add-Ons
    |--------------------------------------------------------------------------
    |
    */

    'add_on' => [

        'swagger'       => false,

        'tests'         => true,

        'datatables'    => false,

        'menu'          => [

            'enabled'       => true,

            'menu_file'     => 'layouts/menu.blade.php',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Timestamp Fields
    |--------------------------------------------------------------------------
    |
    */

    'timestamps' => [

        'enabled'       => true,

        'created_at'    => 'created_at',

        'updated_at'    => 'updated_at',

        'deleted_at'    => 'deleted_at',
    ],

    /*
    |--------------------------------------------------------------------------
    | Save model files to `App/Models` when use `--prefix`. see #208
    |--------------------------------------------------------------------------
    |
    */
    'ignore_model_prefix' => false,

];
karneaud commented 5 years ago

@mitulgolakiya @illuminate3 @arieltoledo @shemgp seems this guy may have a solutions https://github.com/dsielab/generator-module