Skip to content

Generator Commands

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

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

sh
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,

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

Migration Generator

sh
php artisan infyom:migration $MODEL_NAME

Model Generator

sh
php artisan infyom:model $MODEL_NAME

Repository Generator

sh
php artisan infyom:repository $MODEL_NAME

API Controller Generator

sh
php artisan infyom.api:controller $MODEL_NAME

API Requests Generator

sh
php artisan infyom.api:requests $MODEL_NAME

Tests Generator

sh
php artisan infyom.api:tests $MODEL_NAME

Scaffold Controller Generator

sh
php artisan infyom.scaffold:controller $MODEL_NAME

Scaffold Requests Generator

sh
php artisan infyom.scaffold:requests $MODEL_NAME

Views Generator

sh
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.

sh
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 :

sh
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 :

sh
use Illuminate\Contracts\Auth\MustVerifyEmail;

class User extends Authenticatable implements MustVerifyEmail
{
    use Notifiable;
    ....
}

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

sh
Route::get('/home', 'HomeController@index')->middleware('verified');

.... OR ....

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