|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace Dcat\Admin;
|
|
namespace Dcat\Admin;
|
|
|
|
|
|
|
|
+use Closure;
|
|
use Dcat\Admin\Contracts\Repository;
|
|
use Dcat\Admin\Contracts\Repository;
|
|
use Dcat\Admin\Show\AbstractTool;
|
|
use Dcat\Admin\Show\AbstractTool;
|
|
use Dcat\Admin\Show\Divider;
|
|
use Dcat\Admin\Show\Divider;
|
|
@@ -9,6 +10,7 @@ use Dcat\Admin\Show\Field;
|
|
use Dcat\Admin\Show\Newline;
|
|
use Dcat\Admin\Show\Newline;
|
|
use Dcat\Admin\Show\Panel;
|
|
use Dcat\Admin\Show\Panel;
|
|
use Dcat\Admin\Show\Relation;
|
|
use Dcat\Admin\Show\Relation;
|
|
|
|
+use Dcat\Admin\Show\Row;
|
|
use Dcat\Admin\Show\Tools;
|
|
use Dcat\Admin\Show\Tools;
|
|
use Dcat\Admin\Traits\HasBuilderEvents;
|
|
use Dcat\Admin\Traits\HasBuilderEvents;
|
|
use Illuminate\Contracts\Support\Arrayable;
|
|
use Illuminate\Contracts\Support\Arrayable;
|
|
@@ -85,6 +87,10 @@ class Show implements Renderable
|
|
* @var Panel
|
|
* @var Panel
|
|
*/
|
|
*/
|
|
protected $panel;
|
|
protected $panel;
|
|
|
|
+ /**
|
|
|
|
+ * @var \Illuminate\Support\Collection
|
|
|
|
+ */
|
|
|
|
+ protected $rows;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Show constructor.
|
|
* Show constructor.
|
|
@@ -108,7 +114,7 @@ class Show implements Renderable
|
|
default:
|
|
default:
|
|
$this->setKey($id);
|
|
$this->setKey($id);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ $this->rows = new Collection();
|
|
$this->builder = $builder;
|
|
$this->builder = $builder;
|
|
|
|
|
|
$this->initModel($model);
|
|
$this->initModel($model);
|
|
@@ -679,6 +685,11 @@ class Show implements Renderable
|
|
|
|
|
|
$this->fields->each->fill($model);
|
|
$this->fields->each->fill($model);
|
|
$this->relations->each->model($model);
|
|
$this->relations->each->model($model);
|
|
|
|
+ $this->rows->each(function ($row) {
|
|
|
|
+ $row->getFields()->each(function ($field) {
|
|
|
|
+ $field['element']->fill($this->model());
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
|
|
$this->callComposing();
|
|
$this->callComposing();
|
|
|
|
|
|
@@ -693,6 +704,27 @@ class Show implements Renderable
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Add a row in Show.
|
|
|
|
+ *
|
|
|
|
+ * @param Closure $callback
|
|
|
|
+ *
|
|
|
|
+ * @return $this
|
|
|
|
+ */
|
|
|
|
+ public function row(Closure $callback)
|
|
|
|
+ {
|
|
|
|
+ $this->rows->push(new Row($callback, $this));
|
|
|
|
+ return $this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return \Illuminate\Support\Collection
|
|
|
|
+ */
|
|
|
|
+ public function rows()
|
|
|
|
+ {
|
|
|
|
+ return $this->rows;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Add a model field to show.
|
|
* Add a model field to show.
|
|
*
|
|
*
|