1.创建controller:

php artisan make:controller Backend/IndexController --plain

1.添加路由:

Route::group(['namespace' => 'Backend', 'middleware' => ['auth']], function () {
Route::get('/', ['as' => 'index.index', 'uses' => 'IndexController@index']);
Route::resource('user', 'UserController');
Route::resource('menu', 'MenuController');
Route::resource('role', 'RoleController');
Route::resource('permission', 'PermissionController');
});//分组,中间件

1.引入css/js/image:

<link rel="stylesheet" href="{{asset('/assets/css/app.css')}}">
<script src="{{ asset ("/assets/js/app.js") }}" type="text/javascript"></script>
<img src="{{ asset("/assets/img/user2-160x160.jpg") }}" class="img-circle" alt="User Image"/>

1.页面链接:

<form class="form-horizontal" action="{{URL::to('user')}}" method="post" enctype="multipart/form-data"></form>
<a class="btn btn-default" href="{{route('user.index')}}">返回</a>
 

1.添加第三方:

compser require ****;参考对应文档进行设置。
controller可以通过use***;来使用。

1.添加表单验证:

php artisan make:request Form/UserForm,重写rules,重写message方法做提示。

1.使用model:

use App\Models\Menu;
$menus = Menu::paginate(25);//分页

1.第三方中有服务的以及中间件的,记得注册:

例如:"zizaco/entrust": "dev-laravel-5"权限管理第三方

1.1在文件config/app.phpproviders数组和aliase数组分别添加

// providers
Zizaco\Entrust\EntrustServiceProvider::class

// aliase
'Entrust' => Zizaco\Entrust\EntrustFacade::class,

1.2在文件app/Http/Kernel.php$routeMiddleware添加

'role' => Zizaco\Entrust\Middleware\EntrustRole::class,
'permission' => Zizaco\Entrust\Middleware\EntrustPermission::class,
'ability' => Zizaco\Entrust\Middleware\EntrustAbility::class,

1.3执行以下命令生成配置文件config/entrust.php

php artisan vendor:publish

1.composer生成自动加载:

composer dump-autoload

1.controller引入从写的表单验证:

public function store(RoleForm $request)

1.blade include extends:

 @include('backend.layout.message.tips',['field'=>'description'])
@extends('backend.layout.main')

在终端执行以下命令回滚并再次执行迁移,填充数据

php artisan migrate:refresh --seed

两个比较坑的地方:

在使用--seed的时候 提示:This cache store does not support tagging,此处讲cache 引擎修改为array即可,不使用默认的file以及database。

在创建migration,在执行的时候,提示表格不存在。这个是在创建迁移的时候参数不对,不要--table,这个是修改数据表的。要--create,这个是创建数据表的。

  1. It will use Schema::create instead of Schema::table.
  2. Artisan will add $table->increment('id') and $table->timestamps() by default as they are assumed to exist in every table by Eloquent ORM (this of course can be altered within the model).
  3. Artisan will even clean up after you by adding Schema::drop('users') within the down() method. How nice of Laravel to do that for you!