dyjh 6 år sedan
förälder
incheckning
9143cdb131

+ 22 - 0
app/Http/Controllers/Admin/Album/AgentController.php

xqd xqd xqd
@@ -8,6 +8,7 @@
  */
 namespace App\Http\Controllers\Admin\Album;
 use App\Http\Controllers\Admin\Controller;
+use App\Models\AgentBannerModel;
 use App\Models\AlbumAgentModel;
 use App\Models\AlbumProductPriceModel;
 use App\Models\AlbumUserModel;
@@ -83,6 +84,16 @@ class AgentController extends Controller
      */
     private function _createSave(){
         $data = (array) request('data');
+        $agent_banner = $data['banner_agent'];
+        unset($data['banner_agent']);
+        if($agent_banner){
+            foreach($agent_banner as $key=>$val){
+                $add['url'] = $this->formatImgUrl($val);
+                $add['agent_id'] = request('id');
+                $add['type'] = 0;
+                AgentBannerModel::create($add);
+            }
+        }
         $id = $this->repository->create($data);
         if($id) {
             $url[] = array('url'=>U( 'Album/Agent/index'),'title'=>'返回列表');
@@ -113,6 +124,17 @@ class AgentController extends Controller
      */
     private function _updateSave() {
         $data = (array) request('data');
+        $id = request('id');
+        AgentBannerModel::where('agent_id',$id)->delete();
+        if(!empty($data['banner'])){
+            foreach($data['banner']['url'] as $key=>$val){
+                $add['image'] = $this->formatImgUrl($val);
+                $add['mark_id'] = $id;
+                $add['sort'] = 0;
+                AgentBannerModel::create($add);
+            }
+
+        }
         $ok = $this->repository->update(request('id'),$data);
         if($ok) {
             $url[] = array('url'=>U( 'Album/Agent/index'),'title'=>'返回列表');

+ 34 - 0
app/Models/AgentBannerModel.php

xqd
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 思维定制
+ * Date: 2018/11/27
+ * Time: 9:45
+ */
+
+namespace App\Models;
+
+
+class AgentBannerModel extends BaseModel
+{
+    protected $table = 'agent_banner';
+
+    /**
+    主键
+     */
+    protected $primaryKey = 'id';
+
+    //分页
+    protected $perPage = PAGE_NUMS;
+
+    /**
+     * 可以被集体附值的表的字段
+     *
+     * @var string
+     */
+    protected $fillable = [
+        'agent_id',
+        'url',
+        'type',
+    ];
+}

+ 34 - 0
database/migrations/2018_11_27_094259_create_table_agent_banner.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateTableAgentBanner extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('agent_banner', function (Blueprint $table) {
+            $table->increments('id');
+            $table->unsignedInteger('agent_id');
+            $table->string('url',255)->comment('路径');
+            $table->unsignedInteger('type')->comment('0 图片 1 视频');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('agent_banner');
+    }
+}

+ 7 - 0
resources/views/admin/album/agent/edit.blade.php

xqd
@@ -66,6 +66,13 @@
                      <input id="data_name" name="data[name]" class="form-control" value="{{ $data['name'] or ''}}" required="" aria-required="true"  placeholder="">
                     </div>
                                 
+                </div>
+                <div class="form-group">
+                    <label class="control-label col-sm-3">经销商画报</label>
+                    <div class="col-sm-9">
+                        {{--     //{!! ueditor('') !!}--}}
+                        {!!  widget('Tools.ImgUpload')->multi2('/upload/agent_banner','agent_banner',"data[agent_banner]",  isset($data['agent_banner'])? $data['agent_banner'] : '') !!}
+                    </div>
                 </div>
                                 
                                 <div class="form-group">