wesley преди 7 години
родител
ревизия
99d49c3513

+ 1 - 1
app/Http/Controllers/Admin/Product/CategoryController.php

xqd
@@ -28,7 +28,7 @@ class CategoryController extends Controller
         if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
         $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
         }else{
-            $query = $query->pushCriteria(new OrderBy('id','DESC'));
+            $query = $query->pushCriteria(new OrderBy('id','DESC'))->pushCriteria(new OrderBy('sort','DESC'));
         }
         $list = $query->paginate(10);
         return view('admin.product.category.index',compact('list'));

+ 1 - 1
app/Http/Controllers/Admin/Product/InfoController.php

xqd
@@ -29,7 +29,7 @@ class InfoController extends Controller
         if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
         $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
         }else{
-            $query = $query->pushCriteria(new OrderBy('id','DESC'));
+            $query = $query->pushCriteria(new OrderBy('id','DESC'))->pushCriteria(new OrderBy('sort','DESC'));
         }
         $list = $query->paginate();
         return view('admin.product.info.index',compact('list'));

+ 1 - 1
app/Http/Controllers/Api/V1/HomeController.php

xqd
@@ -158,7 +158,7 @@ class HomeController extends Controller
      */
     public function getProducts()
     {
-        $products = ProductCategoryModel::OrderBy('id', 'desc')->get(['id', 'name', 'img']);
+        $products = ProductCategoryModel::OrderBy('sort', 'desc')->get(['id', 'name', 'img']);
         return $this->api($products);
     }
 

+ 2 - 1
app/Models/ProductCategoryModel.php

xqd
@@ -38,7 +38,8 @@ class ProductCategoryModel extends BaseModel
     protected $fillable = [
         'name',
         'img',
-        'detail'
+        'detail',
+        'sort'
     ];
 
     public function spec(){

+ 2 - 1
app/Models/ProductInfoModel.php

xqd
@@ -41,7 +41,8 @@ class ProductInfoModel extends BaseModel
         'origin_price',
         'current_price',
         'deposit',
-        'service_time'
+        'service_time',
+        'sort'
     ];
 
     public function catename(){

+ 32 - 0
database/migrations/2018_09_14_110219_add_sort_product_category_table.php

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddSortProductCategoryTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('product_category', function (Blueprint $table) {
+            $table->integer('sort')->after('detail')->nullable()->comment('排序');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('product_category', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 32 - 0
database/migrations/2018_09_14_110333_add_sort_product_info_table.php

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddSortProductInfoTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('product_info', function (Blueprint $table) {
+            $table->integer('sort')->after('service_time')->nullable()->comment('排序');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('product_info', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 13 - 0
resources/views/admin/product/category/edit.blade.php

xqd
@@ -73,6 +73,19 @@
 
                                 </div>
 
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">排序:越大越靠前</label>
+
+                                    <div class="col-sm-9">
+                                        <input id="data_sort" name="data[sort]" class="form-control"
+                                               value="{{ $data['sort'] or ''}}"
+                                               placeholder="">
+
+                                    </div>
+
+                                </div>
+
                                 <div class="form-group">
                                     <label class="control-label col-sm-3">&nbsp;</label>
                                     <div class="col-sm-9">

+ 13 - 0
resources/views/admin/product/info/edit.blade.php

xqd
@@ -108,6 +108,19 @@
 
                                 </div>
 
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">排序:越大越靠前</label>
+
+                                    <div class="col-sm-9">
+                                        <input id="data_sort" name="data[sort]" class="form-control"
+                                               value="{{ $data['sort'] or ''}}"
+                                               placeholder="">
+
+                                    </div>
+
+                                </div>
+
                                 <div class="form-group">
                                     <label class="control-label col-sm-3">&nbsp;</label>
                                     <div class="col-sm-9">