| xqd
@@ -10,6 +10,7 @@ namespace App\Http\Controllers\Admin\Album;
|
|
|
use App\Http\Controllers\Admin\Controller;
|
|
|
use App\Models\AlbumCatModel;
|
|
|
use App\Models\AlbumProductModel;
|
|
|
+use App\Models\AlbumProductPriceModel;
|
|
|
use App\Models\AlbumProductStyleModel;
|
|
|
use App\Repositories\Album\Criteria\ProductWhere;
|
|
|
use Illuminate\Http\Request;
|
| xqd
@@ -118,41 +119,48 @@ class ProductController extends Controller
|
|
|
/**
|
|
|
* 保存修改
|
|
|
*/
|
|
|
- private function _createSave(){
|
|
|
+ private function _createSave()
|
|
|
+ {
|
|
|
$data = (array) request('data');
|
|
|
$data['store_id'] = $this->getStoreId();
|
|
|
- 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']))
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($data['thumb'])) {
|
|
|
$data['thumb'] = $this->formatImgUrl($data['thumb']);
|
|
|
- if(!empty($data['detail']['url'])) {
|
|
|
- foreach ($data['detail']['url'] as $key=>$val) {
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($data['detail']['url'])) {
|
|
|
+ foreach ($data['detail']['url'] as $key => $val) {
|
|
|
$data['detail']['url'][$key] = $this->formatImgUrl($val);
|
|
|
}
|
|
|
$data['detail'] = json_encode($data['detail']['url']);
|
|
|
}
|
|
|
- if(!empty($data['detail_pic']))
|
|
|
+ if (!empty($data['detail_pic'])) {
|
|
|
$data['detail_pic'] = $this->formatImgUrl($data['detail_pic']);
|
|
|
+ }
|
|
|
+
|
|
|
$id = $this->repository->create($data);
|
|
|
- if($id) {
|
|
|
- $url[] = array('url'=>U( 'Album/Product/index'),'title'=>'返回列表');
|
|
|
- $url[] = array('url'=>U( 'Album/Product/create'),'title'=>'继续添加');
|
|
|
- $this->showMessage('添加成功',$url);
|
|
|
- }else{
|
|
|
- $url[] = array('url'=>U( 'Album/Product/index'),'title'=>'返回列表');
|
|
|
- return $this->showWarning('添加失败',$url);
|
|
|
+ if ($id) {
|
|
|
+ $url[] = array('url' => U('Album/Product/index'), 'title' => '返回列表');
|
|
|
+ $url[] = array('url' => U('Album/Product/create'), 'title' => '继续添加');
|
|
|
+ $this->showMessage('添加成功', $url);
|
|
|
+ } else {
|
|
|
+ $url[] = array('url' => U('Album/Product/index'), 'title' => '返回列表');
|
|
|
+ return $this->showWarning('添加失败', $url);
|
|
|
}
|
|
|
}
|
|
|
|
| xqd
@@ -197,24 +205,32 @@ class ProductController extends Controller
|
|
|
if (!empty($data['cover_pic'])) {
|
|
|
$data['cover_pic'] = $this->formatImgUrl($data['cover_pic']);
|
|
|
}
|
|
|
- if(!empty($data['thumb']))
|
|
|
+ if (!empty($data['thumb'])) {
|
|
|
$data['thumb'] = $this->formatImgUrl($data['thumb']);
|
|
|
- if(!empty($data['detail']['url'])) {
|
|
|
- foreach ($data['detail']['url'] as $key=>$val) {
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($data['detail']['url'])) {
|
|
|
+ foreach ($data['detail']['url'] as $key => $val) {
|
|
|
$data['detail']['url'][$key] = $this->formatImgUrl($val);
|
|
|
}
|
|
|
$data['detail'] = json_encode($data['detail']['url']);
|
|
|
}
|
|
|
- if(!empty($data['detail_pic']))
|
|
|
+ if (!empty($data['detail_pic'])) {
|
|
|
$data['detail_pic'] = $this->formatImgUrl($data['detail_pic']);
|
|
|
+ }
|
|
|
// dd($data);
|
|
|
- $ok = $this->repository->update(request('id'),$data);
|
|
|
- if($ok) {
|
|
|
- $url[] = array('url'=>U( 'Album/Product/index'),'title'=>'返回列表');
|
|
|
- return $this->showMessage('操作成功',urldecode(request('_referer')));
|
|
|
- }else{
|
|
|
- $url[] = array('url'=>U( 'Album/Product/index'),'title'=>'返回列表');
|
|
|
- return $this->showWarning('操作失败',$url);
|
|
|
+ $price = AlbumProductPriceModel::where('product_id', request('id'))->get();
|
|
|
+ foreach ($price as $p) {
|
|
|
+ $p->cat_id = $data['cat_id'];
|
|
|
+ $p->name = $data['name'];
|
|
|
+ }
|
|
|
+ $ok = $this->repository->update(request('id'), $data);
|
|
|
+ if ($ok) {
|
|
|
+ $url[] = array('url' => U('Album/Product/index'), 'title' => '返回列表');
|
|
|
+ return $this->showMessage('操作成功', urldecode(request('_referer')));
|
|
|
+ } else {
|
|
|
+ $url[] = array('url' => U('Album/Product/index'), 'title' => '返回列表');
|
|
|
+ return $this->showWarning('操作失败', $url);
|
|
|
}
|
|
|
}
|
|
|
|