/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $item = static::queryAll()->withTrashed()->find($id);
     $this->fireCMSControllerEvent('showing', [$item, $id]);
     $panels = $this->_show($item);
     $this->layout->content = View::make('laravel-cms::cms/panels')->with('panels', $panels);
     $url = \HTMLize::create($item)->url();
     if ('javascript:;' != $url && $url) {
         $shortcut = new \stdClass();
         $shortcut->url = $url;
         $shortcut->title = '网页中查看';
         $this->layout->shortcuts[] = $shortcut;
     }
     try {
         $url = URL::action(static::$action . '.edit.form', [$id]);
     } catch (\InvalidArgumentException $e) {
         $url = null;
     }
     if ($url) {
         $shortcut = new \stdClass();
         $shortcut->url = $url;
         $shortcut->title = '打开编辑';
         $this->layout->shortcuts[] = $shortcut;
     }
     $this->layout->title = static::$name . '详情';
 }
    /**
     * @param $item
     * @return string
     */
    public static function block_btn_preview($item)
    {
        $url = \HTMLize::create($item)->url();
        if ('javascript:;' != $url && $url) {
            return <<<HTML
<a class="btn btn-sm btn-warning gofarms-btn-actions" href="{$url}" target="_blank"><span class="glyphicon glyphicon-arrow-right" data-toggle="tooltip" data-placement="top" title="在网站中查看..."></span></a>
HTML;
        } else {
            return '';
        }
    }
 /**
  * 保存编辑数据
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $item = static::queryAll()->find($id);
     if (null === $item) {
         KMessager::push('找不到对应的数据', KMessager::ERROR);
         return Redirect::action(static::$action . '.show.index');
     }
     $form = $this->_form($id, $item);
     if ($form->validation()) {
         // validate ok
         $this->fireCMSControllerEvent('updating', [$form, $item, $id]);
         $this->_store($form, $item, $id);
         $link = '';
         try {
             $link .= HTML::link(URL::action(static::$action . '.show.detail', [$item->id]), '&nbsp;查看详情&nbsp;', ['target' => '_blank']);
         } catch (InvalidArgumentException $e) {
             $link .= '';
         }
         $url = \HTMLize::create($item)->url();
         if ('javascript:;' != $url && $url) {
             $link .= HTML::link($url, '&nbsp;查看网页&nbsp;', ['target' => '_blank']);
         }
         try {
             $url = URL::action(static::$action . '.edit.form', [$item->id]);
         } catch (InvalidArgumentException $e) {
             $url = null;
         }
         if ($url) {
             $link .= HTML::link($url, '&nbsp;重新编辑&nbsp;', ['target' => '_blank']);
         }
         KMessager::push('更新记录成功' . $link);
         return Redirect::action(static::$action . '.show.index');
     } else {
         // 以下方式会导致chrome崩溃掉...
         //Session::flash( 'flashdata_create_form' , $form );
         //return Redirect::action( static::$action . '.create' );
         $this->layout->content = View::make('laravel-cms::cms/form')->with('form', $form);
     }
 }