Kaynağa Gözat

wip - add Filter::view

jqh 4 yıl önce
ebeveyn
işleme
ad1d497852
2 değiştirilmiş dosya ile 13 ekleme ve 2 silme
  1. 1 1
      src/Grid.php
  2. 12 1
      src/Grid/Filter.php

+ 1 - 1
src/Grid.php

@@ -413,7 +413,7 @@ class Grid
     /**
      * @return void
      */
-    protected function callBuilder()
+    public function callBuilder()
     {
         if ($this->builder && ! $this->built) {
             call_user_func($this->builder, $this);

+ 12 - 1
src/Grid/Filter.php

@@ -681,6 +681,13 @@ class Filter implements Renderable
         return $this;
     }
 
+    public function view(string $view)
+    {
+        $this->view = $view;
+
+        return $this;
+    }
+
     /**
      * Get the string contents of the filter view.
      *
@@ -688,13 +695,17 @@ class Filter implements Renderable
      */
     public function render()
     {
+        $this->grid()->callBuilder();
+
         if (empty($this->filters)) {
             return '';
         }
 
         $this->callComposing();
 
-        $this->view = $this->mode === static::MODE_RIGHT_SIDE ? 'admin::filter.right-side-container' : 'admin::filter.container';
+        if (! $this->view) {
+            $this->view = $this->mode === static::MODE_RIGHT_SIDE ? 'admin::filter.right-side-container' : 'admin::filter.container';
+        }
 
         return view($this->view)->with([
             'action'             => $this->action ?: $this->urlWithoutFilters(),