Browse Source

视频分类

moshaorui 5 months ago
parent
commit
fc4a073466

+ 0 - 5
app/Admin/Controllers/BaseProductController.php

@@ -3,7 +3,6 @@
 namespace App\Admin\Controllers;
 
 use App\Admin\Repositories\BaseProduct;
-use App\Models\BaseProduct as baseProductModel;
 use Dcat\Admin\Admin;
 use Dcat\Admin\Form;
 use Dcat\Admin\Form\NestedForm;
@@ -55,8 +54,6 @@ class BaseProductController extends AdminController
         });
     }
 
-
-
     /**
      * Make a show builder.
      *
@@ -89,7 +86,6 @@ class BaseProductController extends AdminController
                     $table .= '</table>';
                     return $table;
                 }
-
                 return ''; // 当没有数组数据时
             })->unescape();
             $show->field('images')->as(function ($images) {
@@ -144,7 +140,6 @@ class BaseProductController extends AdminController
                     return $paths;
                 });
             $form->editor('content');
-            //$form->number('order');
             $form->switch('is_pinned')->default(0);
             $form->switch('enabled')->default(1);
             //插入JS

+ 2 - 2
app/Admin/Controllers/BaseVideoController.php

@@ -32,7 +32,7 @@ class BaseVideoController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new BaseVideo(), function (Grid $grid) {
+        return Grid::make(BaseVideo::with(['baseVideoCategory']), function (Grid $grid) {
             $grid->column('id')->sortable();
             $grid->column('title');
             $grid->column('base_video_category.name','Category Name');
@@ -66,7 +66,7 @@ class BaseVideoController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, BaseVideo::with(['']), function (Show $show) {
+        return Show::make($id, BaseVideo::with(['baseVideoCategory']), function (Show $show) {
             $show->field('id');
             $show->field('title');
             $show->field('base_video_category.name','Category Name');

+ 0 - 3
app/Models/BaseProduct.php

@@ -40,7 +40,4 @@ class BaseProduct extends Model implements Sortable
         return $this->hasMany(BaseProductImage::class, 'product_id');
     }
 
-
-
-
 }

+ 3 - 7
app/Traits/SortableTraitPinned.php

@@ -15,7 +15,7 @@ use Spatie\EloquentSortable\Sortable;
  */
 trait SortableTraitPinned
 {
-    public static function bootSortableTrait()
+    public static function bootSortableTraitPinned()
     {
         static::creating(function ($model) {
             if ($model instanceof Sortable && $model->shouldSortWhenCreating()) {
@@ -111,7 +111,6 @@ trait SortableTraitPinned
         $swapWithModel = $this->buildSortQuery()->limit(1)
             ->orderBy('is_pinned', 'desc')->orderBy('order', 'desc')
             ->where($orderColumnName, '<', $this->$orderColumnName)
-            ->where('is_pinned', '=', $this->is_pinned)
             ->first();
 
         if (! $swapWithModel) {
@@ -129,17 +128,14 @@ trait SortableTraitPinned
         $orderColumnName = $this->determineOrderColumnName();
 
         $swapWithModel = $this->buildSortQuery()->limit(1)
-            ->orderBy('is_pinned', 'desc')->orderBy('order', 'asc')
+            ->orderBy('is_pinned', 'asc')->orderBy('order', 'asc')
             ->where($orderColumnName, '>', $this->$orderColumnName)
-            ->where('is_pinned', '=', $this->is_pinned)
             ->first();
 
         if (! $swapWithModel) {
             return $this;
         }
-//        var_dump($this->is_pinned, $swapWithModel->is_pinned);
-//        var_dump($this->id, $swapWithModel->id);
-//        exit;
+
         if (($this->is_pinned == 1 && $swapWithModel->is_pinned == 0)
             || ($this->is_pinned == 0 && $swapWithModel->is_pinned == 1)) {
             throw new \Exception('No sorting allowed');