代码格式化
小李世界
4年前
修改理由:
此投稿已在 4年前 合并。
内容修改:
Old | New | Differences |
---|---|---|
5 | 5 | 使用它就像这样: |
6 | 6 | |
7 | 7 | ``` |
8 | use App\Http\Traits\BrandsTrait;class YourController extends Controller { use BrandsTrait; public function addProduct() { | |
9 | $brands = $this->brandsAll(); | |
10 | } | |
8 | use App\Http\Traits\BrandsTrait; | |
9 | ||
10 | class YourController extends Controller { | |
11 | use BrandsTrait; | |
12 | ||
13 | public function addProduct() { | |
14 | $brands = $this->brandsAll(); | |
15 | } | |
11 | 16 | } |
12 | 17 | ``` |
13 | 18 | … | … |
15 | 20 | |
16 | 21 | ``` |
17 | 22 | <?php |
18 | namespace App\Http\Traits;use App\Brand;trait BrandsTrait { | |
23 | namespace App\Http\Traits; | |
24 | ||
25 | use App\Brand;trait BrandsTrait { | |
19 | 26 | public function brandsAll() { |
20 | 27 | // 从品牌表中获取所有品牌. |
21 | $brands = Brand::all(); return $brands; | |
28 | $brands = Brand::all(); | |
29 | ||
30 | return $brands; | |
22 | 31 | } |
23 | 32 | } |
24 | 33 | ``` |