Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use artisan to make views in laravel 5.1

Tags:

I have been looking in the docs for a solution to make views with basic CURD operations but without much success.

I guess this might be pretty simple, but am missing something or not looking hard enough.

i can make models and controllers using the below artisan commands

php artisan make:model modelName  php artisan make:controller controllerName 

But how do we make the basic CURD views. something like

 php artisan make:views 

cant find any doc for this. Please help

like image 615
Scrappy Cocco Avatar asked Aug 11 '15 07:08

Scrappy Cocco


People also ask

What is the use of artisan in Laravel?

Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. It is driven by the powerful Symfony Console component.

How do I load a view in Laravel?

Loading a view in the controller is easy. You just need to add `view('viewname')` method while returning from the controller method. `view()` is a global helper in Laravel. In this method, you just need to pass the name of the view.

How do I return a view from a controller in Laravel?

Return data to view using route::view method in Laravel You can use Route::view() method in web. php file while defining the web route and return to view (passed as second agruments to route::view method) without any callback function with data which is passed as third arguments to route definition.


2 Answers

At the time of writing, there isn't a way to create views via artisan without writing your own command or using a third party package. You could write your own as already suggested or use sven/artisan-view.

like image 196
Sven Avatar answered Oct 06 '22 23:10

Sven


if you are using laravel 5.1 or 5.2 this gist can help you make:view command just create command copy and paste the code from gist.

Step 1:

php artisan make:command MakeViewCommand

Step 2:

copy class from this gist

https://gist.github.com/umefarooq/ebc617dbf88260db1448

like image 41
umefarooq Avatar answered Oct 07 '22 00:10

umefarooq