ahmed-aliraqi/artisan-scaffolding

v1.0.1 2017-07-24 13:36 UTC

This package is auto-updated.

Last update: 2024-11-29 04:52:20 UTC


README

This package adds some artisan commands to generate relations, helpers, scopes, concerns, mutators, transformers files and override the laravel original artisan commands as your like.

NOTE : the view artisan commands was forked from sven/artisan-view

Installation

Via composer:

composer require ahmed-aliraqi/artisan-scaffolding

Or add the package to your dependencies in composer.json and run composer update to download the package:

{
    "require": {
        "ahmed-aliraqi/artisan-scaffolding": "^1.0"
    }
}

Note: If you're using Laravel 5.5, you're done! The service provider is automatically registered in the container, thanks to auto-discovery.

Next, add the ServiceProvider to your providers array in config/app.php:

// config/app.php
'providers' => [
    ...
    Aliraqi\Artisan\Scaffolding\Providers\ServiceProvider::class,
];

Usage

If you now run php artisan you can see 8 new commands:

  • make:helper
  • make:mutator
  • make:relation
  • make:scope
  • make:concern
  • make:transformer
  • make:view
  • scrap:view

These commands was overrided by this package :

  • make:model : add the fillable as default.
  • make:controller : add generate request option and generate full resource, nested controller .
  • make:policy : add listing method and replace the user variable name to auther if the created policy file name is user
  • make:request : division the rules by method name and change the authorize method return to true by default.

If you want to change your project character run this command to publish the config file :

php artisan vendor:publish --provider=Aliraqi\Artisan\Scaffolding\Providers\ServiceProvider --tag=config
// config/artisan-scaffolding.php

<?php
return [
    /**
     * the default namespace for the models classes.
     *
     * if you change the default namespace you need to change user model namespace in these files :-
     * - config/auth.php
     * - config/services.php
     * - app/Http/Controllers/Auth/RegisterController.php
     * - database/factories/ModelFactory.php
     *
     */
    'models_default_namespace' => 'App',

    /**
     * the default namespace for the relations traits.
     *
     */
    'relations_default_namespace' => 'App\Relations',

    /**
     * the default namespace for the concerns traits.
     *
     */
    'concerns_default_namespace' => 'App\Concerns',

    /**
     * the default namespace for the mutators traits.
     *
     */
    'mutators_default_namespace' => 'App\Mutators',

    /**
     * the default namespace for the scopes traits.
     *
     */
    'scopes_default_namespace' => 'App\Scopes',

    /**
     * the default namespace for the helpers traits.
     *
     */
    'helpers_default_namespace' => 'App\Helpers',

    /**
     * the default namespace for the policies classes.
     *
     */
    'policies_default_namespace' => 'App\Policies',

    /**
     * the default namespace for the requests classes.
     *
     */
    'requests_default_namespace' => 'App\Http\Requests',

    /**
     * the default namespace for the controllers classes.
     *
     */
    'controllers_default_namespace' => 'App\Http\Controllers',

    /**
     * the default namespace for the transformer classes.
     *
     */
    'transformers_default_namespace' => 'App\Transformers',
];

If you want to change stubs files content run this command :

php artisan vendor:publish --provider=Aliraqi\Artisan\Scaffolding\Providers\ServiceProvider --tag=stubs

Now you can see the stubs files in this path app\Console\stubs

License

sven/artisan-view is licensed under the MIT License (MIT). Please see the license file for more information.