瀏覽代碼

詳情增加html方法

lila 4 年之前
父節點
當前提交
f457a67e11
共有 2 個文件被更改,包括 30 次插入0 次删除
  1. 11 0
      src/Show.php
  2. 19 0
      src/Show/Html.php

+ 11 - 0
src/Show.php

@@ -7,6 +7,7 @@ use Dcat\Admin\Contracts\Repository;
 use Dcat\Admin\Show\AbstractTool;
 use Dcat\Admin\Show\Divider;
 use Dcat\Admin\Show\Field;
+use Dcat\Admin\Show\Html;
 use Dcat\Admin\Show\Newline;
 use Dcat\Admin\Show\Panel;
 use Dcat\Admin\Show\Relation;
@@ -510,6 +511,16 @@ class Show implements Renderable
         $this->fields->push(new Newline());
     }
 
+    /**
+     * Show the content of html.
+     *
+     * @param string $html
+     */
+    public function html($html = '')
+    {
+        $this->fields->push(new Html($html));
+    }
+
     /**
      * Disable `list` tool.
      *

+ 19 - 0
src/Show/Html.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace Dcat\Admin\Show;
+
+class Html extends Field
+{
+    public $html;
+
+    public function __construct($html, string $name = '', string $label = '')
+    {
+        $this->html = $html;
+        parent::__construct($name, $label);
+    }
+
+    public function render()
+    {
+        return $this->html;
+    }
+}