/**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['formats' => 'required_if:type,0,1,2', 'start_date' => 'required|date', 'end_date' => 'required|date|after:start_date', 'url' => 'required_if:type,3']);
     $model = LaunchRes::find($id);
     if ($model == null) {
         return view('errors.404');
     }
     $model->url = $request->input('url');
     $model->start_date = $request->input('start_date');
     $model->end_date = $request->input('end_date');
     $model->active = $request->input('active') ? 1 : 0;
     if ($model->type == 3) {
         //home page html
         $model->format = '';
         $model->ext = 'html';
         $model->num = count(explode(';', $request->input('url')));
         $model->save();
         $ver = ResourceVer::where('resource_name', 'homepage')->first();
         if ($ver != null) {
             $ver->ver = time();
             $ver->save();
         }
     } else {
         $relativePathPrefix = Utils::getLaunchImgPath($model->type);
         $model->img = $relativePathPrefix;
         try {
             Common::handleFormats($request, $model, $relativePathPrefix);
         } catch (FunFangException $e) {
             return $this->getCreateView()->withErrors($e->getMessage());
         }
         $model->save();
         $ver = ResourceVer::where('resource_name', 'launch_ver')->first();
         if ($ver != null) {
             $ver->ver = time();
             $ver->save();
         }
     }
     return Redirect::to('res/launch');
 }
 /**
  * 获取编辑视图
  * @param $model
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 private function getEditView($model)
 {
     return view('property.customize.edit', ['model' => $model, 'formats' => Utils::getResFormats(), 'cats' => PropertyBiz::getCats()]);
 }
 private function getCreateView()
 {
     return view('res.banner.create', ['model' => BannerRes::getEmptyViewModel(), 'formats' => Utils::getResFormats()]);
 }