ViewMaker make:parent-child Laravel Artisan Command Released

Access all tutorials in sprocket icon.

Published May 16, 2016 by Bill Keck.

The make:parent-child and make:child-of artisan commands from ViewMaker for Laravel 5.2

I’m happy to announce the release of a couple of new commands for ViewMaker. For the sake of anyone who is unfamiliar with ViewMaker, it’s an artisan plugin, available free from To install it:

composer require evercode1/view-maker

Then in your config/app.php providers array, add the following:


Now when you run:

php artisan list

You will see the following commands have been added to your list of artisan commands:

  • make:child-of
  • make:crud
  • make:master
  • make:foundation
  • make:parent-child
  • make:views

These will appear in alphabetical order in your commands list.

So even though the plugin is called ViewMaker, you can see it obviously does a lot more than just create views. For example, a make:foundation stands up the following:

  • model
  • controller
  • api controller (if it does not yet exist)
  • migration
  • test
  • appropriately-named view folder
  • index view
  • create view
  • edit view
  • show view

And the foundation command appends to:

  • routes.php
  • ModelFactory.php
  • ApiController (if it already exists)

You can get all of this instantly and this can really supercharge your workflow. After running the command, you migrate, run your unit test, and factory seed. The whole sequence can be done in under a minute and then you have a fully populated datagrid to play around with.

If you are just starting out with vue.js and want to see a working datagrid that gets its data from an ajax call, this is great way to learn, since it will stand that up for you instantly.

The exact requirements for the make:foundation command is on the Github site, so I won’t repeat it here, since we are moving on to discussing the new commands:

  • make:child-of
  • make:parent-child

I created these commands to cover situations when you want to create, for example, Category and Subcategory, and you want full UI to be able to add, edit and delete them easily. So the make:parent-child command let’s you define both the parent and the child in one go and stands up a foundation for each. In addition to that, it includes the relationships and the extra column on the datagrid for the child model to show the corresponding parent model. It’s a lot of code that goes up instantly.

If we follow this example, then the command would look like this:

php artisan make:parent-child Category Subcategory master vue

The parent comes first followed by the child. Then you indicate the name of your master page (I stick to master for that), and finally, the template type you want. In this case I have selected vue to get the datagrid built in vue.js, which features robust pagination, column sorting and search.

Don’t forget to run php artisan migrate after commands like make:foundation that have a migration, otherwise the datagrid is not going to work.

Now of course there are situations where you don’t think of the child model until after you have made the parent, and for that, we would use the make:child-of command, which would almost look the same as the previous command:

php artisan make:child-of Category Subcategory master vue

In this case, you will only modify the parent to add the has many relationship and it will create a foundation for the child, along with the extra code to relate it to the parent.

Remember that there are dependencies that the datagrid requires, and you easily get them by running the make:master command if you are starting with a fresh install of Laravel, which is the recommended way to play around with ViewMaker. You will have all your dependencies in place instantly.

If you want to use the make:foundation or any of the other commands with an existing Laravel app, then consult the Github page to make sure you have included the dependencies.

Well, that’s it for now. I have more planned for ViewMaker. I hope to be able to release more commands soon.

Click on the sprocket icon at the top of the page to see all my Laravel articles and tutorials. Please comment, share, like and review if you can, thanks.

I don’t have a donate button, but If you would like to support my work and learn more about Laravel, you can do so by buying one of my books, Laraboot: laravel 5.2 For Beginners, I really appreciate it.