dyjh vor 6 Jahren
Ursprung
Commit
31372741ce

+ 72 - 55
app/Http/Controllers/Admin/Album/CatController.php

xqd xqd xqd xqd xqd xqd xqd
@@ -20,19 +20,26 @@ class CatController extends Controller
 {
     private $repository;
 
-    public function __construct(CatRepository $repository) {
-        if(!$this->repository) $this->repository = $repository;
+    public function __construct(CatRepository $repository)
+    {
+        if (!$this->repository) {
+            $this->repository = $repository;
+        }
     }
 
-    function index(Request $request) {
-        //AlbumCatModel::where()->get();
+    /**
+     * @param Request $request
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+     */
+    function index(Request $request)
+    {
         $search['keyword'] = $request->input('keyword');
-        $query = $this->repository->pushCriteria(new CatWhere($search,0,$this->getStoreId()));
+        $query = $this->repository->pushCriteria(new CatWhere($search, 0, $this->getStoreId()));
 
-        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'));
+        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'));
         }
         $list = $query->paginate();
         foreach ($list as $key => $item) {
@@ -40,19 +47,23 @@ class CatController extends Controller
             $item->sonlist = AlbumCatModel::where([['parent_id',$item->id],['store_id',$this->getStoreId()]])->get();
         }
 //        dump($list);
-        return view('admin.album.cat.index',compact('list'));
+        return view('admin.album.cat.index', compact('list'));
     }
 
-
-    function check(Request $request) {
+    /**
+     * @param Request $request
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+     */
+    function check(Request $request)
+    {
         $request = $request->all();
         $search['keyword'] = $request->input('keyword');
         $orderby = array();
-        if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
+        if (isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
             $orderby[$request['sort_field']] = $request['sort_field_by'];
         }
-        $list = $this->repository->search($search,$orderby);
-        return view('admin.album.cat.check',compact('list'));
+        $list = $this->repository->search($search, $orderby);
+        return view('admin.album.cat.check', compact('list'));
     }
 
 
@@ -62,12 +73,12 @@ class CatController extends Controller
      */
     public function create(Request $request)
     {
-        if($request->method() == 'POST') {
+        if ($request->method() == 'POST') {
             return $this->_createSave();
         }
-        $cat = AlbumCatModel::where('parent_id',0)->get();
+        $cat = AlbumCatModel::where([['parent_id', 0],['store_id',$this->getStoreId()]])->get();
         $data['parent_id'] = null;
-        return view('admin.album.cat.edit',compact('data','cat'));
+        return view('admin.album.cat.edit', compact('data', 'cat'));
     }
 
     /**
@@ -76,17 +87,18 @@ class CatController extends Controller
     private function _createSave(){
         $data = (array) request('data');
         $data['store_id'] = $this->getStoreId();
-        if(!empty($data['pic_url']))
-        $data['pic_url'] = $this->formatImgUrl($data['pic_url']);
+        if (!empty($data['pic_url'])) {
+            $data['pic_url'] = $this->formatImgUrl($data['pic_url']);
+        }
 
         $id = $this->repository->create($data);
-        if($id) {
-            $url[] = array('url'=>U( 'Album/Cat/index'),'title'=>'返回列表');
-            $url[] = array('url'=>U( 'Album/Cat/create'),'title'=>'继续添加');
-            $this->showMessage('添加成功',$url);
-        }else{
-            $url[] = array('url'=>U( 'Album/Cat/index'),'title'=>'返回列表');
-            return $this->showWarning('添加失败',$url);
+        if ($id) {
+            $url[] = array('url' => U('Album/Cat/index'), 'title' => '返回列表');
+            $url[] = array('url' => U('Album/Cat/create'), 'title' => '继续添加');
+            $this->showMessage('添加成功', $url);
+        } else {
+            $url[] = array('url' => U('Album/Cat/index'), 'title' => '返回列表');
+            return $this->showWarning('添加失败', $url);
         }
     }
     
@@ -96,36 +108,41 @@ class CatController extends Controller
      * 
      * 
      */
-    public function update(Request $request) {
-        if($request->method() == 'POST') {
+    public function update(Request $request)
+    {
+        if ($request->method() == 'POST') {
             return $this->_updateSave();
         }
         $data = $this->repository->find($request->get('id'));
-        $cat = AlbumCatModel::where('parent_id',0)->get();
+        $cat = AlbumCatModel::where([['parent_id',0],['store_id',$this->getStoreId()]])->get();
 
-        return view('admin.album.cat.edit',compact('data','cat'));
+        return view('admin.album.cat.edit', compact('data', 'cat'));
     }
 
     /**
      * 保存修改
      */
-    private function _updateSave() {
+    private function _updateSave()
+    {
         $data = (array) request('data');
-        if(!empty($data['pic_url']))
-        $data['pic_url'] = $this->formatImgUrl($data['pic_url']);
-        $ok = $this->repository->update(request('id'),$data);
-        if($ok) {
-            $url[] = array('url'=>U( 'Album/Cat/index'),'title'=>'返回列表');
-            return $this->showMessage('操作成功',urldecode(request('_referer')));
-        }else{
-            $url[] = array('url'=>U( 'Album/Cat/index'),'title'=>'返回列表');
-            return $this->showWarning('操作失败',$url);
+        if (!empty($data['pic_url'])) {
+            $data['pic_url'] = $this->formatImgUrl($data['pic_url']);
+        }
+
+        $ok = $this->repository->update(request('id'), $data);
+        if ($ok) {
+            $url[] = array('url' => U('Album/Cat/index'), 'title' => '返回列表');
+            return $this->showMessage('操作成功', urldecode(request('_referer')));
+        } else {
+            $url[] = array('url' => U('Album/Cat/index'), 'title' => '返回列表');
+            return $this->showWarning('操作失败', $url);
         }
     }
 
-    public function view(Request $request) {
+    public function view(Request $request)
+    {
         $data = $this->repository->find(request('id'));
-        return view('admin.album.cat.view',compact('data'));
+        return view('admin.album.cat.view', compact('data'));
     }
 
 
@@ -134,12 +151,12 @@ class CatController extends Controller
      * 状态改变
      *
      */
-    public function status(Request $request) {
-
-        $ok = $this->repository->updateStatus(request('id'),request('status'));
-        if($ok) {
+    public function status(Request $request)
+    {
+        $ok = $this->repository->updateStatus(request('id'), request('status'));
+        if ($ok) {
             return $this->showMessage('操作成功');
-        }else{
+        } else {
             return $this->showWarning('操作失败');
         }
     }
@@ -147,17 +164,17 @@ class CatController extends Controller
     /**
      * 删除
      */
-    public function destroy(Request $request) {
-        //$bool = $this->repository->destroy($request->get('id'));
+    public function destroy(Request $request)
+    {
         $cat = AlbumCatModel::find($request->get('id'));
-        $son_cat = AlbumCatModel::where('parent_id',$cat->id)->delete();
-        if($son_cat){
-            //$son_cat->delete();
+        $son_cat = AlbumCatModel::where('parent_id', $cat->id)->delete();
+        if ($son_cat) {
+            $son_cat->delete();
         }
         $ok = $cat->delete();
-        if($ok) {
+        if ($ok) {
             return  $this->showMessage('操作成功');
-        }else{
+        } else {
             return  $this->showWarning("操作失败");
         }
     }

+ 40 - 28
app/Http/Controllers/Admin/Album/ProductController.php

xqd xqd xqd xqd xqd xqd
@@ -21,25 +21,32 @@ class ProductController extends Controller
 {
     private $repository;
 
-    public function __construct(ProductRepository $repository) {
-        if(!$this->repository) $this->repository = $repository;
+    /**
+     * ProductController constructor.
+     * @param ProductRepository $repository
+     */
+    public function __construct(ProductRepository $repository)
+    {
+        if (!$this->repository) {
+            $this->repository = $repository;
+        }
     }
 
-    function index(Request $request) {
+    function index(Request $request)
+    {
         $search['keyword'] = $request->input('keyword');
-        $query = $this->repository->pushCriteria(new ProductWhere($search,$this->getStoreId()));
+        $query = $this->repository->pushCriteria(new ProductWhere($search, $this->getStoreId()));
 
-        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'));
+        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'));
         }
         $list = $query->paginate();
         foreach ($list as $key => $item) {
-            $cat = AlbumCatModel::where('id',$item->cat_id)->first();
-            $style = AlbumProductStyleModel::where('id',$item->style)->first();
-            $item->cat_name = $cat['name'];
-            $item->style_name = $style['name'];
+            $cat = AlbumCatModel::where('id', $item->cat_id)->first();
+            $catParent = AlbumCatModel::where('id', $cat->parent_id)->first();
+            $item->cat_name = ($catParent->name ?? '') . '>' . $cat->name;
             $upload_img = json_decode($item->upload_img);
             $attr = json_decode($item->attr);
             $detail = json_decode($item->detail);
@@ -48,7 +55,7 @@ class ProductController extends Controller
             $list[$key]['detail'] = $detail[0];
         }
         //dd($list);
-        return view('admin.album.product.index',compact('list'));
+        return view('admin.album.product.index', compact('list'));
     }
 
     /**
@@ -172,22 +179,24 @@ class ProductController extends Controller
     /**
      * 保存修改
      */
-    private function _updateSave() {
+    private function _updateSave()
+    {
         $data = (array) request('data');
-        if(!empty($data['specifications_img']['url'])) {
-            foreach ($data['specifications_img']['url'] as $key=>$val) {
+        if (!empty($data['specifications_img']['url'])) {
+            foreach ($data['specifications_img']['url'] as $key => $val) {
                 $data['specifications_img']['url'][$key] = $this->formatImgUrl($val);
             }
             $data['specifications_img'] = json_encode($data['specifications_img']['url']);
         }
-        if(!empty($data['install_img']['url'])){
-            foreach ($data['install_img']['url'] as $key=>$val) {
+        if (!empty($data['install_img']['url'])) {
+            foreach ($data['install_img']['url'] as $key => $val) {
                 $data['install_img']['url'][$key] = $this->formatImgUrl($val);
             }
             $data['install_img'] = json_encode($data['install_img']['url']);
         }
-        if(!empty($data['cover_pic']))
+        if (!empty($data['cover_pic'])) {
             $data['cover_pic'] = $this->formatImgUrl($data['cover_pic']);
+        }
         if(!empty($data['thumb']))
             $data['thumb'] = $this->formatImgUrl($data['thumb']);
         if(!empty($data['detail']['url'])) {
@@ -209,9 +218,10 @@ class ProductController extends Controller
         }
     }
 
-    public function view(Request $request) {
+    public function view(Request $request)
+    {
         $data = $this->repository->find(request('id'));
-        return view('admin.album.product.view',compact('data'));
+        return view('admin.album.product.view', compact('data'));
     }
 
 
@@ -220,11 +230,12 @@ class ProductController extends Controller
      * 状态改变
      *
      */
-    public function status(Request $request) {
-        $ok = $this->repository->updateStatus(request('id'),request('status'));
-        if($ok) {
+    public function status(Request $request)
+    {
+        $ok = $this->repository->updateStatus(request('id'), request('status'));
+        if ($ok) {
             return $this->showMessage('操作成功');
-        }else{
+        } else {
             return $this->showWarning('操作失败');
         }
     }
@@ -232,13 +243,14 @@ class ProductController extends Controller
     /**
      * 删除
      */
-    public function destroy(Request $request) {
+    public function destroy(Request $request)
+    {
         //$bool = $this->repository->destroy($request->get('id'));
         $cat = AlbumProductModel::find($request->get('id'));
         $ok = $cat->delete();
-        if($ok) {
+        if ($ok) {
             return  $this->showMessage('操作成功');
-        }else{
+        } else {
             return  $this->showWarning("操作失败");
         }
     }

+ 13 - 12
app/Repositories/Album/Criteria/CatWhere.php

xqd xqd
@@ -14,17 +14,20 @@ namespace App\Repositories\Album\Criteria;
 use App\Repositories\Base\Criteria;
 use App\Repositories\Contracts\RepositoryInterface as Repository;
 
-class CatWhere extends Criteria {
+class CatWhere extends Criteria
+{
 
     private $search = [];
     private $pid;
     private $store_id;
+
     /**
-     * MultiWhere constructor.
+     * CatWhere constructor.
      * @param array $search
-     *
+     * @param int $pid
+     * @param int $store_id
      */
-    public function __construct(array $search,int $pid,int $store_id)
+    public function __construct(array $search, int $pid, int $store_id)
     {
         $this->search = $search;
         $this->pid = $pid;
@@ -33,17 +36,15 @@ class CatWhere extends Criteria {
 
     /**
      * @param $model
-     * @param RepositoryInterface $repository
-     * @return mixed
+     * @param Repository $repository
+     * @return Object
      */
     public function apply($model, Repository $repository)
     {
-        if(isset($this->search['keyword']) && $this->search['keyword']) {
-            $keyword = '%'.$this->search['keyword'].'%';
-            $model = $model->where([['name','like',$keyword],['parent_id',$this->pid],['store_id',$this->store_id]])
-                ->orwhere([['id','like',$keyword],['parent_id',$this->pid],['store_id',$this->store_id]]);
-        } else if(isset($this->search['updated_at']) && $this->search['updated_at']) {
-            $model = $model->where('updated_at',$this->search['updated_at']);
+        if (isset($this->search['keyword']) && $this->search['keyword']) {
+            $keyword = '%' . $this->search['keyword'] . '%';
+            $model = $model->where([['name','like',$keyword],['store_id',$this->store_id]])
+                ->orwhere([['id','like',$keyword],['store_id',$this->store_id]]);
         } else {
             $model = $model->where([['parent_id',0],['store_id',$this->store_id]]);
         }

+ 6 - 3
app/Repositories/Album/Criteria/MultiWhere.php

xqd
@@ -35,9 +35,12 @@ class MultiWhere extends Criteria {
     */
     public function apply($model, Repository $repository)
     {
-          if(isset($this->search['updated_at']) && $this->search['updated_at']) {
-                                    $model = $model->where('updated_at',$this->search['updated_at']);
-                                 }
+        if(isset($this->search['keyword']) && $this->search['keyword']) {
+            $keyword = '%'.$this->search['keyword'].'%';
+            $model = $model->where([['id','like',$keyword],['store_id',$this->store_id]])
+                ->orwhere([['store_id','like',$keyword],['store_id',$this->store_id]])
+                ->orwhere([['name','like',$keyword],['store_id',$this->store_id]]);
+        }
 
          return $model;
     }

+ 9 - 9
app/Repositories/Album/Criteria/ProductWhere.php

xqd xqd
@@ -14,16 +14,18 @@ namespace App\Repositories\Album\Criteria;
 use App\Repositories\Base\Criteria;
 use App\Repositories\Contracts\RepositoryInterface as Repository;
 
-class ProductWhere extends Criteria {
+class ProductWhere extends Criteria
+{
 
     private $search = [];
     private $store_id;
+
     /**
-     * MultiWhere constructor.
+     * ProductWhere constructor.
      * @param array $search
-     *
+     * @param int $store_id
      */
-    public function __construct(array $search,int $store_id)
+    public function __construct(array $search, int $store_id)
     {
         $this->search = $search;
         $this->store_id = $store_id;
@@ -31,17 +33,15 @@ class ProductWhere extends Criteria {
 
     /**
      * @param $model
-     * @param RepositoryInterface $repository
+     * @param Repository $repository
      * @return mixed
      */
     public function apply($model, Repository $repository)
     {
-        if(isset($this->search['keyword']) && $this->search['keyword']) {
-            $keyword = '%'.$this->search['keyword'].'%';
+        if (isset($this->search['keyword']) && $this->search['keyword']) {
+            $keyword = '%' . $this->search['keyword'] . '%';
             $model = $model->where([['name','like',$keyword],['store_id',$this->store_id]])
                 ->orwhere([['id','like',$keyword],['store_id',$this->store_id]]);
-        } else if(isset($this->search['updated_at']) && $this->search['updated_at']) {
-            $model = $model->where('updated_at',$this->search['updated_at']);
         } else {
             $model = $model->where([['store_id',$this->store_id]]);
         }

+ 1 - 1
resources/views/admin/album/banner/index.blade.php

xqd
@@ -18,7 +18,7 @@
 
                                 <div class="col-sm-4">
                                     <div class="input-group">
-                                        <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入关键词"
+                                        <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入ID/标题"
                                                name="keyword" class="input-sm form-control">
                                         <span class="input-group-btn">
 									<button type="submit" class="btn btn-sm btn-primary">搜索</button>

+ 1 - 1
resources/views/admin/album/cat/index.blade.php

xqd
@@ -19,7 +19,7 @@
 
 				        <div class="col-sm-4">
 				            <div class="input-group">
-								<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入关键词" name="keyword"class="input-sm form-control"> 
+								<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入ID/分类名称" name="keyword" class="input-sm form-control">
 								<span class="input-group-btn">
 									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
 								</span>

+ 1 - 1
resources/views/admin/album/comments/index.blade.php

xqd
@@ -18,7 +18,7 @@
 
                                 <div class="col-sm-4">
                                     <div class="input-group">
-                                        <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入关键词"
+                                        <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入ID/标题/用户ID/内容"
                                                name="keyword" class="input-sm form-control">
                                         <span class="input-group-btn">
 									<button type="submit" class="btn btn-sm btn-primary">搜索</button>

+ 1 - 1
resources/views/admin/album/info/cat/index.blade.php

xqd
@@ -18,7 +18,7 @@
 
 				        <div class="col-sm-4">
 				            <div class="input-group">
-								<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入关键词" name="keyword"class="input-sm form-control"> 
+								<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入ID/名称" name="keyword" class="input-sm form-control">
 								<span class="input-group-btn">
 									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
 								</span>

+ 1 - 1
resources/views/admin/album/information/index.blade.php

xqd
@@ -18,7 +18,7 @@
 
                                 <div class="col-sm-4">
                                     <div class="input-group">
-                                        <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入关键词"
+                                        <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入ID/标题/内容"
                                                name="keyword" class="input-sm form-control">
                                         <span class="input-group-btn">
 									<button type="submit" class="btn btn-sm btn-primary">搜索</button>

+ 1 - 1
resources/views/admin/album/manufacturer/index.blade.php

xqd
@@ -18,7 +18,7 @@
 
                                 <div class="col-sm-4">
                                     <div class="input-group">
-                                        <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入关键词"
+                                        <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入ID/商户ID/商户名"
                                                name="keyword" class="input-sm form-control">
                                         <span class="input-group-btn">
 									<button type="submit" class="btn btn-sm btn-primary">搜索</button>

+ 1 - 1
resources/views/admin/album/product/edit.blade.php

xqd
@@ -225,7 +225,7 @@
 
 
         getLevelSecondCategory();
-    
+
 
     function checkLevel(){
         var second = $('#data_cat_id').val();

+ 1 - 3
resources/views/admin/album/product/index.blade.php

xqd xqd xqd
@@ -18,7 +18,7 @@
 
 				        <div class="col-sm-4">
 				            <div class="input-group">
-								<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入关键词" name="keyword"class="input-sm form-control"> 
+								<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入ID/商品名" name="keyword" class="input-sm form-control">
 								<span class="input-group-btn">
 									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
 								</span>
@@ -42,7 +42,6 @@
             <th class="sorting" data-sort="price_default"> 默认价格 </th>
             <th class="sorting" data-sort="specifications_img"> 规格图片 </th>
             <th class="sorting" data-sort="install_img"> 安装图片 </th>
-            <th class="sorting" data-sort="style"> 风格 </th>
             <th class="sorting" data-sort="sort"> 排序 </th>
             <th class="sorting" data-sort="cover_pic"> 封面图片 </th>
         						<th width="22%">相关操作</th>
@@ -58,7 +57,6 @@
             <td>{{ $item->price_default }}</td>
             <td><img src="{{ $item->specifications_img }}" width="50"/></td>
             <td><img src="{{ $item->install_img }}" width="50"/></td>
-            <td>{{ $item->style_name }}</td>
             <td>{{ $item->sort }}</td>
             <td><img src="{{ $item->thumb }}" width="50"/></td>
 								<td>