Wallogit.com
2017 © Pedro Peláez
A laravel generators package.
Only currently actively tested with Laravel 5.4. Previous version support to come..., (*1)
Contribution welcome., (*2)
Pull in the package using composer, (*3)
$ composer require joshralph/quick-gen "dev-master" --dev
Include the service provider within /config/app.php, (*4)
QuickGen\Providers\GeneratorServiceProvider::class,
You will need to run the command below to publish the stub files that ship with the package., (*5)
php artisan vendor:publish --tag=stubs
To run the generator run the below command. The example resource name given below should be replaced as you need., (*6)
php artisan quick-gen:generate cars
The package ships with a standard CRUD template that you can use to generate basic CRUD functionality., (*7)
To specify which template you wish to use, add the template flag to the command., (*8)
This template will generate the following files for you within the standard laravel directory structure:, (*9)
Of course you will likely want to create your own template files that are in keeping with your current view structure, and coding style., (*10)
To create a new template simply create a new folder within the resources/stubs/ directory. The folder name should be used when setting the --template argument., (*11)
You can then call the command below using the --template argument, (*12)
php artisan quick-gen:generate cars --template=my-template
Note all stub files should end in .stub, (*13)
The following variables are made available to stub files (both content and filename):, (*14)
name - The name of the resource as specified in the generate command, (*15)
baseNamespace - The namespace where the generated files will reside., (*16)
...and should be wrapped in the following way:, (*17)
Stub Contents, (*18)
namespace <<baseNamespace>>\Http\Controllers\Admin;
Filename, (*19)
__name__Controller.php.stub
You may wish to transform the case and formatting of variables within stub files. These can be used both within the file contents and the filename., (*20)
Filters can be added to variables using a . delimiter., (*21)
@foreach ($<<name.camel.plural>> as $<<name.camel.singular>>)
<tr>
<td>{{ $<<name.camel.singular>>->name }}</td>
</tr>
@endforeach
The following filters are available:, (*22)
camel - convert the variable to camel case., (*23)
studly - convert the variable to studly case., (*24)
snake - convert the variable to snake case., (*25)
plural - convert the variable to plural., (*26)
singular - convert the variable to singular., (*27)
lower - convert the variable to lowercase., (*28)
ucwords - upper case the first letter of each word in the variable (see words)., (*29)
words - convert the variable to space delimited words, (*30)
| Verb | Name | Method |
|---|---|---|
| GET | <<name.snake.plural>>.index | @index |
| GET | <<name.snake.plural>>.create | @create |
| POST | <<name.snake.plural>>.store | @store |
| GET | <<name.snake.plural>>.edit | @edit($id) |
| POST | <<name.snake.plural>>.update | @update($id) |
| GET | <<name.snake.plural>>.destroy | @destroy($id) |