Generator

Our Products

InfyChatInfyHMSInfyJobsInfyProjects

Generator Commands

TABLE OF CONTENT
  1. Rollback
  2. Migration
  3. Model
  4. Repository
  5. API Controller
  6. API Requests
  7. Tests
  8. Scaffold Controller
  9. Scaffold Requests
  10. Views
  11. Default Users Model CRUD
  12. Email Verification

The Generator has various commands to generate files in a group or individually. Sometimes you need to generate/re-generate individual files after making some manual changes to some files and you don't want the generator to override your changes.

Also, it has command to rollback all generated files.

Rollback Command

To rollback all generated files, we have the following command,

php artisan infyom:rollback $MODEL_NAME$ $COMMAND_TYPE

Where,

$MODEL_NAME - Its a model name for which you want to delete files

$COMMAND_TYPE - Command type from api, scaffold or scaffold_api

If you have run migration on database, then better you rollback that migration first and then run infyom:rollback command, since it will delete migration file as well. Otherwise laravel can throw error about missing migration files.

To rollback specific views of given modal,

php artisan infyom:rollback $MODEL_NAME $COMMAND_TYPE --views=edit,create,index,show

Migration Generator Command

php artisan infyom:migration $MODEL_NAME

Model Generator Command

php artisan infyom:model $MODEL_NAME

Repository Generator Command

php artisan infyom:repository $MODEL_NAME

API Controller Generator Command

php artisan infyom.api:controller $MODEL_NAME

API Requests Generator Command

php artisan infyom.api:requests $MODEL_NAME

Tests Generator Command

php artisan infyom.api:tests $MODEL_NAME

Scaffold Controller Generator Command

php artisan infyom.scaffold:controller $MODEL_NAME

Scaffold Requests Generator Command

php artisan infyom.scaffold:requests $MODEL_NAME

Views Generator Command

php artisan infyom.scaffold:views $MODEL_NAME

Default Users Model CRUD

If you want to publish default Users model CRUD, you can use this command. You can also skip repository pattern by changing repositoryPattern option to false if you want.

php artisan infyom.publish:user

Following files will be generated after executing this command:

  • App\Http\Controllers\UserController
  • app\Http\Requests

    • CreateUserRequest
    • UpdateUserRequest
  • App\Http\Repository\UserRepository
  • resources\views\users

    • create.blade.php
    • edit.blade.php
    • index.blade.php
    • fields.blade.php
    • show_fields.blade.php
    • table.blade.php
  • Routes added to web.php
  • menu.blade.php updated with "Users" menu

Email Verification

By default we are publishing, verify.blade.php file when you setup generator and publish layouts, but if you want to enable email verification in your existing project then you need to run following command :

php artisan infyom.publish:layout

Following file will be generated after executing above command:

  • resources\auth\verify.blade.php

Now you have to implement User model from MustVerifyEmail, as per below e.g :

use Illuminate\Contracts\Auth\MustVerifyEmail; class User extends Authenticatable implements MustVerifyEmail { use Notifiable; .... }

And now add middleware verified to your routes. for e.g :

Route::get('/home', 'HomeController@index')->middleware('verified'); .... OR .... Route::middleware(['verified'])->group(function () { Route::get('/home', 'HomeController@index'); });