Hello developers in this tutorial we will discuss about how to create custom artisan command and how to create dynamic view in laravel
What are Artisan commands?
Artisan commands are similar to commands on CMD or commands which we enter in terminal to make changes, Laravel comes with an inbuilt command line interface that name is Artisan, by the use artisan command we can make jobs, model, controller, migration and many more with the artisan command
Create new artisan command for view
For creating new custom artisan for creating view , simply open the terminal and hit the below command with respective to file name.
Copy for creating artisan command
php artisan make:command createViewFile
Inside app/console/Commands/ you can see createViewFile.php
Code for command view file
createViewFile.php code:
Here protected $signature = 'make:view {view}'; represents how to start this command and {view} means what should be name of our view file after that in handle() function consist of main logic behind the command to be executable.
Entering artisan command
php artisan make:view front/aboutUs