| xqd
@@ -8,8 +8,10 @@
|
|
|
*/
|
|
|
namespace App\Http\Controllers\Admin\Album;
|
|
|
use App\Http\Controllers\Admin\Controller;
|
|
|
+use App\Models\AgentBannerModel;
|
|
|
use App\Models\AlbumManufacturerModel;
|
|
|
use App\Models\AlbumUserModel;
|
|
|
+use App\Services\OSS;
|
|
|
use Illuminate\Http\Request;
|
|
|
use App\Repositories\Base\Criteria\OrderBy;
|
|
|
use App\Repositories\Album\Criteria\MultiWhere;
|
| xqd
@@ -49,6 +51,13 @@ class ManufacturerController extends Controller
|
|
|
if ($data) {
|
|
|
$data['banner'] = json_decode($data['banner'], true);
|
|
|
}
|
|
|
+ $banner = AgentBannerModel::where([['store_id',$this->getStoreId()],['type',0]])->get();
|
|
|
+ $imgs = array();
|
|
|
+ foreach($banner as $key=>$val){
|
|
|
+ $imgs[] = $val['url'];
|
|
|
+ }
|
|
|
+ $data->agent_banner = $imgs;
|
|
|
+ $video = AgentBannerModel::where([['agent_id',$request->get('id')],['type',1]])->first();
|
|
|
return view('admin.album.manufacturer.edit',compact('data'));
|
|
|
}
|
|
|
|
| xqd
@@ -57,6 +66,7 @@ class ManufacturerController extends Controller
|
|
|
if ($request->method() == 'POST') {
|
|
|
return $this->_createSave();
|
|
|
}
|
|
|
+
|
|
|
return view('admin.album.manufacturer.edit');
|
|
|
}
|
|
|
|
| xqd
@@ -178,4 +188,53 @@ class ManufacturerController extends Controller
|
|
|
return $this->showWarning("操作失败");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public function uploadVideo(Request $request)
|
|
|
+ {
|
|
|
+ $video = $request->file('video');
|
|
|
+// 判断图片有效性
|
|
|
+ if (!$video) {
|
|
|
+ return back()->withErrors('上传视频无效..');
|
|
|
+ }
|
|
|
+ $agentid = $request->input('agent_id');
|
|
|
+ $check = AgentBannerModel::where([['agent_id',$agentid],['type',1]])->first();
|
|
|
+ if($check) OSS::publicDeleteObject(config('alioss.BucketName'),$check->oss_key);
|
|
|
+// 获取图片在临时文件中的地址
|
|
|
+ $videoPath = $video->getRealPath();
|
|
|
+
|
|
|
+// 制作文件名
|
|
|
+ $ex = $video->getClientOriginalExtension();
|
|
|
+ $key = time() . rand(10000, 99999999) . '.' . $ex;
|
|
|
+
|
|
|
+//阿里 OSS 文件上传
|
|
|
+ $result = OSS::publicUpload(config('alioss.BucketName'),$key, $videoPath);
|
|
|
+ if ($result) {
|
|
|
+ $data['name'] = $video->getClientOriginalName();
|
|
|
+ $data['type'] = 1;
|
|
|
+ $data['agent_id'] = $agentid;
|
|
|
+ $data['oss_key'] = $key;
|
|
|
+ $data['url'] = config('alioss.FileUrl').$key;
|
|
|
+ $video = AgentBannerModel::create($data);
|
|
|
+ if(!$video){
|
|
|
+ return back()->withErrors('上传视频失败..');
|
|
|
+ }
|
|
|
+ return $this->showMessage('上传成功');
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return back()->withErrors('上传视频失败..');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function videoDel(Request $request)
|
|
|
+ {
|
|
|
+ $check = AgentBannerModel::find($request->get('id'));
|
|
|
+ if($check) $osskey = $check->oss_key;
|
|
|
+ if(!$check) return $this->showWarning("操作失败");
|
|
|
+ $bool = AgentBannerModel::where('id',$request->get('id'))->delete();
|
|
|
+ if($bool) {
|
|
|
+ OSS::publicDeleteObject(config('alioss.BucketName'),$osskey);
|
|
|
+ return $this->showMessage('操作成功');
|
|
|
+ }else{
|
|
|
+ return $this->showWarning("操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|