Completed
Push — master ( 69e16e...69bb37 )
by Denis
01:15
created
src/Renderers/BaseRenderer.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -9,32 +9,32 @@
 block discarded – undo
9 9
 
10 10
 abstract class BaseRenderer
11 11
 {
12
-    use Configurable;
12
+	use Configurable;
13 13
 
14
-    /**
15
-     * @var GridView
16
-     */
17
-    public $gridView;
14
+	/**
15
+	 * @var GridView
16
+	 */
17
+	public $gridView;
18 18
 
19
-    /**
20
-     * BaseRenderer constructor.
21
-     * @param $config
22
-     * @throws GridViewConfigException
23
-     */
24
-    public function __construct($config)
25
-    {
26
-        $this->loadConfig($config);
27
-    }
19
+	/**
20
+	 * BaseRenderer constructor.
21
+	 * @param $config
22
+	 * @throws GridViewConfigException
23
+	 */
24
+	public function __construct($config)
25
+	{
26
+		$this->loadConfig($config);
27
+	}
28 28
 
29
-    /**
30
-     * @return array
31
-     */
32
-    protected function configTests(): array
33
-    {
34
-        return [
35
-            'gridView' => GridView::class,
36
-        ];
37
-    }
29
+	/**
30
+	 * @return array
31
+	 */
32
+	protected function configTests(): array
33
+	{
34
+		return [
35
+			'gridView' => GridView::class,
36
+		];
37
+	}
38 38
 
39
-    public abstract function render() : string;
39
+	public abstract function render() : string;
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
src/Renderers/DefaultRenderer.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
 
8 8
 class DefaultRenderer extends BaseRenderer
9 9
 {
10
-    /**
11
-     * @return string
12
-     * @throws \Throwable
13
-     */
14
-    public function render(): string
15
-    {
16
-        $filters = [];
17
-        foreach ($this->gridView->columns as $column) {
18
-            if ($column->filter) {
19
-                $filters[$column->filter->name] = $this->gridView->getRequest()->getFilterValue($column->filter->name);
20
-            }
21
-        }
10
+	/**
11
+	 * @return string
12
+	 * @throws \Throwable
13
+	 */
14
+	public function render(): string
15
+	{
16
+		$filters = [];
17
+		foreach ($this->gridView->columns as $column) {
18
+			if ($column->filter) {
19
+				$filters[$column->filter->name] = $this->gridView->getRequest()->getFilterValue($column->filter->name);
20
+			}
21
+		}
22 22
 
23
-        return view('woo_gridview::renderers.default', [
24
-            'grid' => $this->gridView,
25
-            'filters' => $filters,
26
-        ])->render();
27
-    }
23
+		return view('woo_gridview::renderers.default', [
24
+			'grid' => $this->gridView,
25
+			'filters' => $filters,
26
+		])->render();
27
+	}
28 28
 }
29 29
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/Actions/Action.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 
24 24
     /**
25 25
      * Action constructor.
26
-     * @param string|Closure $url
26
+     * @param string $url
27 27
      * @param string $content
28 28
      * @param string $method
29 29
      */
Please login to merge, or discard this patch.
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -6,63 +6,63 @@
 block discarded – undo
6 6
 
7 7
 class Action
8 8
 {
9
-    /**
10
-     * @var string
11
-     */
12
-    protected $url;
9
+	/**
10
+	 * @var string
11
+	 */
12
+	protected $url;
13 13
 
14
-    /**
15
-     * @var string
16
-     */
17
-    protected $content;
14
+	/**
15
+	 * @var string
16
+	 */
17
+	protected $content;
18 18
 
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $method;
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $method;
23 23
 
24
-    /**
25
-     * Action constructor.
26
-     * @param string|Closure $url
27
-     * @param string $content
28
-     * @param string $method
29
-     */
30
-    public function __construct($url, string $content, string $method = 'GET')
31
-    {
32
-        $this->url = $url;
24
+	/**
25
+	 * Action constructor.
26
+	 * @param string|Closure $url
27
+	 * @param string $content
28
+	 * @param string $method
29
+	 */
30
+	public function __construct($url, string $content, string $method = 'GET')
31
+	{
32
+		$this->url = $url;
33 33
 
34
-        $this->content = $content;
34
+		$this->content = $content;
35 35
 
36
-        $this->method = $method;
37
-    }
36
+		$this->method = $method;
37
+	}
38 38
 
39
-    protected function buildUrl($row)
40
-    {
41
-        if ($this->url instanceof Closure) {
42
-            return call_user_func($this->url, $row);
43
-        }
39
+	protected function buildUrl($row)
40
+	{
41
+		if ($this->url instanceof Closure) {
42
+			return call_user_func($this->url, $row);
43
+		}
44 44
 
45
-        return preg_replace_callback('/\{([\w\_]+)\}/', function($match) use ($row) {
45
+		return preg_replace_callback('/\{([\w\_]+)\}/', function($match) use ($row) {
46 46
 
47
-            $match = $match[1];
47
+			$match = $match[1];
48 48
 
49
-            if (isset($row->$match)) {
50
-                return $row->$match;
49
+			if (isset($row->$match)) {
50
+				return $row->$match;
51 51
 
52
-            } elseif (isset($row[$match])) {
53
-                return $row[$match];
54
-            }
52
+			} elseif (isset($row[$match])) {
53
+				return $row[$match];
54
+			}
55 55
 
56
-            return '';
57
-        }, $this->url);
58
-    }
56
+			return '';
57
+		}, $this->url);
58
+	}
59 59
 
60
-    public function render($row)
61
-    {
62
-        return view('woo_gridview::columns.action', [
63
-            'url' => $this->buildUrl($row),
64
-            'content' => $this->content,
65
-            'method' => $this->method,
66
-        ])->render();
67
-    }
60
+	public function render($row)
61
+	{
62
+		return view('woo_gridview::columns.action', [
63
+			'url' => $this->buildUrl($row),
64
+			'content' => $this->content,
65
+			'method' => $this->method,
66
+		])->render();
67
+	}
68 68
 }
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/ActionsColumn.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -6,87 +6,87 @@
 block discarded – undo
6 6
 
7 7
 class ActionsColumn extends BaseColumn
8 8
 {
9
-    /**
10
-     * By default is empty for this column
11
-     * @var string
12
-     */
13
-    public $title = '';
14
-
15
-    /**
16
-     * Value contains short codes for actions
17
-     * @var array
18
-     */
19
-    public $value = [];
20
-
21
-    /**
22
-     * @var bool
23
-     */
24
-    public $sortable = false;
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    public $formatters = [];
30
-
31
-    /**
32
-     * @var string
33
-     */
34
-    public $delimiter = ' ';
35
-
36
-    /**
37
-     * @var null
38
-     */
39
-    public $filter = null;
40
-
41
-    public function __construct(array $config)
42
-    {
43
-        parent::__construct($config);
44
-        $this->buildActions();
45
-    }
46
-
47
-    protected function buildActions()
48
-    {
49
-        foreach ($this->value as &$action) {
50
-            if (is_object($action)) {
51
-                continue;
52
-            }
53
-
54
-            if (is_string($action)) {
55
-                $tmp = explode(':', $action);
56
-
57
-                $action = [
58
-                    'class' => array_shift($tmp),
59
-                    'args' => $tmp,
60
-                ];
61
-            }
62
-
63
-            $className = GridViewHelper::resolveAlias('action', $action['class']);
64
-            $action = new $className(...$action['args']);
65
-        }
66
-    }
67
-
68
-    /**
69
-     * @return array
70
-     */
71
-    protected function configTests(): array
72
-    {
73
-        return array_merge(parent::configTests(), [
74
-            'value' => 'array',
75
-            'delimiter' => 'string',
76
-        ]);
77
-    }
78
-
79
-    /**
80
-     * @inheritdoc
81
-     */
82
-    public function _renderValue($row)
83
-    {
84
-        $result = [];
85
-
86
-        foreach ($this->value as $action) {
87
-            $result[] = $action->render($row);
88
-        }
89
-
90
-        return implode($this->delimiter, $result);
91
-    }
9
+	/**
10
+	 * By default is empty for this column
11
+	 * @var string
12
+	 */
13
+	public $title = '';
14
+
15
+	/**
16
+	 * Value contains short codes for actions
17
+	 * @var array
18
+	 */
19
+	public $value = [];
20
+
21
+	/**
22
+	 * @var bool
23
+	 */
24
+	public $sortable = false;
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	public $formatters = [];
30
+
31
+	/**
32
+	 * @var string
33
+	 */
34
+	public $delimiter = ' ';
35
+
36
+	/**
37
+	 * @var null
38
+	 */
39
+	public $filter = null;
40
+
41
+	public function __construct(array $config)
42
+	{
43
+		parent::__construct($config);
44
+		$this->buildActions();
45
+	}
46
+
47
+	protected function buildActions()
48
+	{
49
+		foreach ($this->value as &$action) {
50
+			if (is_object($action)) {
51
+				continue;
52
+			}
53
+
54
+			if (is_string($action)) {
55
+				$tmp = explode(':', $action);
56
+
57
+				$action = [
58
+					'class' => array_shift($tmp),
59
+					'args' => $tmp,
60
+				];
61
+			}
62
+
63
+			$className = GridViewHelper::resolveAlias('action', $action['class']);
64
+			$action = new $className(...$action['args']);
65
+		}
66
+	}
67
+
68
+	/**
69
+	 * @return array
70
+	 */
71
+	protected function configTests(): array
72
+	{
73
+		return array_merge(parent::configTests(), [
74
+			'value' => 'array',
75
+			'delimiter' => 'string',
76
+		]);
77
+	}
78
+
79
+	/**
80
+	 * @inheritdoc
81
+	 */
82
+	public function _renderValue($row)
83
+	{
84
+		$result = [];
85
+
86
+		foreach ($this->value as $action) {
87
+			$result[] = $action->render($row);
88
+		}
89
+
90
+		return implode($this->delimiter, $result);
91
+	}
92 92
 }
93 93
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/Actions/DeleteAction.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 class DeleteAction extends Action
6 6
 {
7
-    public function __construct(string $url, string $content = '<i class="fa fa-trash-alt"></i>')
8
-    {
9
-        parent::__construct($url, $content, 'DELETE');
10
-    }
7
+	public function __construct(string $url, string $content = '<i class="fa fa-trash-alt"></i>')
8
+	{
9
+		parent::__construct($url, $content, 'DELETE');
10
+	}
11 11
 }
12 12
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/Actions/ShowAction.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@
 block discarded – undo
6 6
 
7 7
 class ShowAction extends Action
8 8
 {
9
-    public function __construct(string $url, string $content = '<i class="fa fa-eye"></i>')
10
-    {
11
-        parent::__construct($url, $content, 'GET');
12
-    }
9
+	public function __construct(string $url, string $content = '<i class="fa fa-eye"></i>')
10
+	{
11
+		parent::__construct($url, $content, 'GET');
12
+	}
13 13
 }
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/Actions/EditAction.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@
 block discarded – undo
6 6
 
7 7
 class EditAction extends Action
8 8
 {
9
-    public function __construct(string $url, string $content = '<i class="fa fa-edit"></i>')
10
-    {
11
-        parent::__construct($url,  $content, 'GET');
12
-    }
9
+	public function __construct(string $url, string $content = '<i class="fa fa-edit"></i>')
10
+	{
11
+		parent::__construct($url,  $content, 'GET');
12
+	}
13 13
 }
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,6 +8,6 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(string $url, string $content = '<i class="fa fa-edit"></i>')
10 10
     {
11
-        parent::__construct($url,  $content, 'GET');
11
+        parent::__construct($url, $content, 'GET');
12 12
     }
13 13
 }
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
src/GridViewRequest.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,77 +7,77 @@
 block discarded – undo
7 7
 
8 8
 class GridViewRequest
9 9
 {
10
-    use Configurable;
11
-
12
-    public $page;
13
-
14
-    public $sortColumn;
15
-
16
-    public $sortOrder;
17
-
18
-    public $perPage;
19
-
20
-    public $filters = [];
21
-
22
-    private function __construct($config)
23
-    {
24
-        $this->loadConfig($config);
25
-    }
26
-
27
-    private static function gridField(int $gridId, string $field)
28
-    {
29
-        return $gridId == 0 ? $field : 'grid.' . $gridId . '.' . $field;
30
-    }
31
-
32
-    /**
33
-     * Allows to parse request information and making request instance
34
-     * @param int $gridId
35
-     * @return GridViewRequest
36
-     */
37
-    public static function parse(int $gridId)
38
-    {
39
-        $request = Request::instance();
40
-
41
-        $page = $request->input(self::gridField($gridId, 'page'), 1);
42
-        $sortColumn = $request->input(self::gridField($gridId, 'sort'), '');
43
-        $sortOrder = $request->input(self::gridField($gridId, 'order'), 'DESC');
44
-        $filters = $request->input(self::gridField($gridId, 'filters'), []);
45
-
46
-        if ($page <= 0) {
47
-            $page = 1;
48
-        }
49
-
50
-        if (!is_string($sortColumn)) {
51
-            $sortColumn = '';
52
-        }
53
-
54
-        if (!in_array($sortOrder, ['ASC', 'DESC'])) {
55
-            $sortOrder = 'DESC';
56
-        }
57
-
58
-        if (!is_array($filters)) {
59
-            $filters = [];
60
-        }
61
-
62
-        return new GridViewRequest([
63
-            'page' => $page,
64
-            'sortColumn' => $sortColumn,
65
-            'sortOrder' => $sortOrder,
66
-            'filters' => $filters,
67
-        ]);
68
-    }
69
-
70
-    public function getFilterValue(string $name)
71
-    {
72
-        return $this->filters[$name] ?? '';
73
-    }
74
-
75
-    /**
76
-     * Should specify tests
77
-     * @return array
78
-     */
79
-    protected function configTests(): array
80
-    {
81
-        return [];
82
-    }
10
+	use Configurable;
11
+
12
+	public $page;
13
+
14
+	public $sortColumn;
15
+
16
+	public $sortOrder;
17
+
18
+	public $perPage;
19
+
20
+	public $filters = [];
21
+
22
+	private function __construct($config)
23
+	{
24
+		$this->loadConfig($config);
25
+	}
26
+
27
+	private static function gridField(int $gridId, string $field)
28
+	{
29
+		return $gridId == 0 ? $field : 'grid.' . $gridId . '.' . $field;
30
+	}
31
+
32
+	/**
33
+	 * Allows to parse request information and making request instance
34
+	 * @param int $gridId
35
+	 * @return GridViewRequest
36
+	 */
37
+	public static function parse(int $gridId)
38
+	{
39
+		$request = Request::instance();
40
+
41
+		$page = $request->input(self::gridField($gridId, 'page'), 1);
42
+		$sortColumn = $request->input(self::gridField($gridId, 'sort'), '');
43
+		$sortOrder = $request->input(self::gridField($gridId, 'order'), 'DESC');
44
+		$filters = $request->input(self::gridField($gridId, 'filters'), []);
45
+
46
+		if ($page <= 0) {
47
+			$page = 1;
48
+		}
49
+
50
+		if (!is_string($sortColumn)) {
51
+			$sortColumn = '';
52
+		}
53
+
54
+		if (!in_array($sortOrder, ['ASC', 'DESC'])) {
55
+			$sortOrder = 'DESC';
56
+		}
57
+
58
+		if (!is_array($filters)) {
59
+			$filters = [];
60
+		}
61
+
62
+		return new GridViewRequest([
63
+			'page' => $page,
64
+			'sortColumn' => $sortColumn,
65
+			'sortOrder' => $sortOrder,
66
+			'filters' => $filters,
67
+		]);
68
+	}
69
+
70
+	public function getFilterValue(string $name)
71
+	{
72
+		return $this->filters[$name] ?? '';
73
+	}
74
+
75
+	/**
76
+	 * Should specify tests
77
+	 * @return array
78
+	 */
79
+	protected function configTests(): array
80
+	{
81
+		return [];
82
+	}
83 83
 }
84 84
\ No newline at end of file
Please login to merge, or discard this patch.
src/DataProviders/BaseDataProvider.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@
 block discarded – undo
6 6
 
7 7
 abstract class BaseDataProvider
8 8
 {
9
-    /**
10
-     * Should return total amount of rows
11
-     * @param GridViewRequest $request
12
-     * @return int
13
-     */
14
-    abstract public function getCount(GridViewRequest $request) : int;
9
+	/**
10
+	 * Should return total amount of rows
11
+	 * @param GridViewRequest $request
12
+	 * @return int
13
+	 */
14
+	abstract public function getCount(GridViewRequest $request) : int;
15 15
 
16
-    /**
17
-     * Should return a list of data for current page
18
-     * @param GridViewRequest $request
19
-     * @return mixed
20
-     */
21
-    abstract public function getData(GridViewRequest $request);
16
+	/**
17
+	 * Should return a list of data for current page
18
+	 * @param GridViewRequest $request
19
+	 * @return mixed
20
+	 */
21
+	abstract public function getData(GridViewRequest $request);
22 22
 }
23 23
\ No newline at end of file
Please login to merge, or discard this patch.