Laravel - Create automated CRUD?

主宰稳场 提交于 2019-12-02 14:35:40

create the code of a CRUD

 No!

But if you want the CRUD methods copied from a properly defined stub use

php artisan make:controller EntityController -r

where the -r flag means a resourceful controller for the model Entity with create, show, index, store, update, edit, and delete methods

The methods uses the proper parameters and apply convenient Dependency Injection and are named according to

Route::resource('Entity', 'EntityController');

However you must write your own implementation

php artisan make:model Entity -mrc

It create a model & migration file & a resource Controller name EntityController.

To create only a resource controller,

php artisan make:controller EntityController --resource

This command will generate a controller at app/Http/Controllers/EntityController.php

In here you have 7 functions

1.index(to show all data)

2.create(to get the blade file creation)

3.store(to store data into database)

4.show(to show specific data)

5.edit(to get the edit blade file )

6.update(to update that specific data into database)

7.destroy(to delete data)

Next, you may register a resourceful route to the controller:
Route::resource('entities', 'EntityController');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!