diff --git a/src/Controllers/Makers/FormMaker.php b/src/Controllers/Makers/FormMaker.php index 631422a..c8ee050 100644 --- a/src/Controllers/Makers/FormMaker.php +++ b/src/Controllers/Makers/FormMaker.php @@ -64,11 +64,17 @@ public function reset(string $label = 'شروع دوباره', string $color = ' return $this; } - protected function beforeRender() + /** return the view of the form */ + public function toView() { - $this->data['view'] = view('panel::form.index', [ + return view('panel::form.index', [ 'form' => (object)$this->form, 'groups' => $this->groups, ]); } + + protected function beforeRender() + { + $this->data['view'] = $this->toView(); + } } diff --git a/src/Controllers/Makers/TableMaker.php b/src/Controllers/Makers/TableMaker.php index 6f2ee46..0c6be5d 100644 --- a/src/Controllers/Makers/TableMaker.php +++ b/src/Controllers/Makers/TableMaker.php @@ -70,14 +70,20 @@ public function setPrimaryKey(string $key): TableMaker return $this; } - protected function beforeRender() + /** return the view of the table */ + public function toView() { - $this->data->put('view', view('panel::table', [ + return view('panel::table', [ 'headers' => $this->headers->toArray(), 'actions' => $this->actions?->toArray(), 'rows' => $this->rows, 'primaryKey' => $this->primaryKey, 'paginate' => $this->paginate, - ])); + ]); + } + + protected function beforeRender() + { + $this->data->put('view', $this->toView()); } }