修改理由:

代码格式化

此投稿已在 4年前 合并。

内容修改:

红色背景 为原始内容

绿色背景 为新增或者修改的内容

OldNewDifferences
55使用它就像这样:
66
77```
8 use App\Http\Traits\BrandsTrait;class YourController extends Controller {   use BrandsTrait;   public function addProduct() {
9        $brands = $this->brandsAll();
10    }
 8use App\Http\Traits\BrandsTrait;
 9
 10class YourController extends Controller {
 11       use BrandsTrait;
 12       
 13       public function addProduct() {
 14           $brands = $this->brandsAll();
 15       }
1116}
1217```
1318
 
1520
1621```
1722<?php
18 namespace App\Http\Traits;use App\Brand;trait BrandsTrait {
 23namespace App\Http\Traits;
 24
 25use App\Brand;trait BrandsTrait {
1926   public function brandsAll() {
2027       // 从品牌表中获取所有品牌.
21        $brands = Brand::all();       return $brands;
 28       $brands = Brand::all();
 29       
 30       return $brands;
2231   }
2332}
2433```