定制 thijsdemaa/laravel-crud 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thijsdemaa/laravel-crud

最新稳定版本:1.0.1

Composer 安装命令:

composer require thijsdemaa/laravel-crud

包简介

README 文档

README

This is a simple package for generating CRUD Models, Controllers and Views for a resource.

Installation

  1. Pull in through composer

composer require thijsdemaa/laravel-crud

  1. Add the service provider to config/app.php

LaravelCrud\CrudServiceProvider::class

Quick Start

In this example we will quickly create a model, migration, controller and viewsfor a Person resource, where we want the route to be admin/person, and the view-files to be put in the folder admin/resources.

Check the fields section to see which fields are available.

php artisan crud:model Person --fields="first_name:string, last_name:string, email:string, password:string, address:string, age:integer, active:boolean"

php artisan migrate

php artisan crud:controller Person --fields="first_name:string, last_name:string, email:email, password:string, address:string, age:integer, active:boolean" --view-path="admin.resources" --route-prefix="admin"
php artisan crud:view Person --fields="first_name:string, last_name:string, email:email, password:password, address:string, age:integer, active:boolean" --view-path="admin.resources" --route-prefix="admin"

If you have added the route to the routes.php like specified after running the controller-command, you are now ready to use your new crud-application by navigating to /admin/person.

Features

Creating:

  • Models
  • Migrations
  • Controllers
  • Views

Uses functions of Laravel like:

  • route() helper for all the routing.
  • str_plural() helper for migrations and views, so that person becomes people.
  • Pagination on the index page.

Documentation

Creating a Model

Command: php artisan crud:model

Description: This command will create a model and a migration file for the resource.

Option Description
Resource Specify the Model Name. Model will be created in app directory.
--fields Specify the attributes of the resource, for the migration. This will also set $fillable on the model file. Be sure to check the fields section.

Creating a Controller

Command: php artisan crud:controller

Description: This command will create a resource-controller for the resource, with built-in validation and pagination. It will create the following methods: index, create, store, show, edit, update, destroy, with corresponding PHPDoc.

Option Description
Resource Specify the resource name. The file will be created in app/Http/Controllers
--fields Specify the attributes of the resource. This will be used in validation. Be sure to check the fields section.
--route-prefix Optional. Specify the route prefix that will be used for the resource, using dot-notation. admin.resources will result in admin/resources/model route.
--view-path Optional. Specify the path inside the views folder to the views of the resource, using dot-notation. admin.resources will result in view('admin.resources.model.index')

Creating views

Command: php artisan crud:view

Description: This command will create the following view-files for the resource. It will also create a master-layout file, that all the views extend.

It will create the following files: create.blade.php, edit.blade.php, errors.blade.php, form.blade.php, index.blade.php, scripts.blade.php, show.blade.php. The package uses the Laravel illuminate/html package to create all the form-inputs, which as of Laravel 5 is no longer included by default in the Laravel framework.

Option Description
Resource Specify the resource name. The files will be created in the views-directory.
--fields Specify the attributes of the resource. This will be used to create the form. Be sure to check the fields section.
--route-prefix Optional. Specify the route prefix that will be used for the resource, using dot-notation. admin.resources will result in admin/resources/model route.
--view-path Optional. Specify the path inside the views folder to the views of the resource, using dot-notation. admin.resources will result in view('admin.resources.model.index')

Notes

When using the --route-prefix and/or the --view-path option, make sure they match on both the controller and the views.

Fields

Here is a list of the fields that are available.

Model/Migration Views/Controller
string text
char text
varchar text
decimal text
float text
double text
string password
string email
string date
string datetime
string datetime
string time
timestamp timestamp
text textarea
mediumtext textarea
longtext textarea
json textarea
jsonb textarea
binary file
number number
integer number
bigint number
mediumint number
smallint number
tinyint radio
boolean radio

统计信息

  • 总下载量: 779
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-11-01