Completed
Push — master ( 00c698...474cb3 )
by Denis
01:57
created
src/GridViewServiceProvider.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,17 +19,17 @@
 block discarded – undo
19 19
 
20 20
 		require_once __DIR__ . '/functions.php';
21 21
 
22
-        \Blade::directive('grid', function ($expression) {
23
-            return "<?php echo grid($expression) ?>";
24
-        });
22
+		\Blade::directive('grid', function ($expression) {
23
+			return "<?php echo grid($expression) ?>";
24
+		});
25 25
 
26
-        $this->publishes([
27
-            __DIR__ . '/../public' => 'public/vendor/grid-view',
28
-        ], 'public');
26
+		$this->publishes([
27
+			__DIR__ . '/../public' => 'public/vendor/grid-view',
28
+		], 'public');
29 29
 
30
-        if (!File::isDirectory(public_path('vendor/grid-view'))) {
31
-            Artisan::call('vendor:publish', ['--tag' => 'public', '--force']);
32
-        }
30
+		if (!File::isDirectory(public_path('vendor/grid-view'))) {
31
+			Artisan::call('vendor:publish', ['--tag' => 'public', '--force']);
32
+		}
33 33
 	}
34 34
 
35 35
 	public function register()
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
 		require_once __DIR__ . '/functions.php';
21 21
 
22
-        \Blade::directive('grid', function ($expression) {
22
+        \Blade::directive('grid', function($expression) {
23 23
             return "<?php echo grid($expression) ?>";
24 24
         });
25 25
 
Please login to merge, or discard this patch.
src/GridView.php 1 patch
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -15,220 +15,220 @@
 block discarded – undo
15 15
 
16 16
 class GridView
17 17
 {
18
-    use Configurable;
19
-
20
-    /**
21
-     * Counter for ids
22
-     * @var int
23
-     */
24
-    private static $counter = 0;
25
-
26
-    /**
27
-     * Grid id (used for request handling, for
28
-     * @var int
29
-     */
30
-    private $id;
31
-
32
-    /**
33
-     * DataProvider provides gridview with the data for representation
34
-     * @var BaseDataProvider
35
-     */
36
-    public $dataProvider;
37
-
38
-    /**
39
-     * Columns config. You may specify array or GridColumn instance
40
-     * @var BaseColumn[]
41
-     */
42
-    public $columns = [];
43
-
44
-    /**
45
-     * Common options for all columns, will be appended to all columns configs
46
-     * @var array
47
-     */
48
-    public $columnOptions = [
49
-        'class' => AttributeColumn::class,
50
-    ];
51
-
52
-    /**
53
-     * Renders the final UI
54
-     * @var string|BaseRenderer
55
-     */
56
-    public $renderer = DefaultRenderer::class;
57
-
58
-    /**
59
-     * Allows to pass some options into renderer/customize rendered behavior
60
-     * @var array
61
-     */
62
-    public $rendererOptions = [];
63
-
64
-    /**
65
-     * Controls amount of data per page
66
-     * @var int
67
-     */
68
-    public $rowsPerPage = 25;
69
-
70
-    /**
71
-     * Allows to tune the <table> tag with html options
72
-     * @var array
73
-     */
74
-    public $tableHtmlOptions = [
75
-        'class' => 'table table-bordered gridview-table',
76
-    ];
77
-
78
-    /**
79
-     * Indicate if filters will be shown or not
80
-     * @var bool
81
-     */
82
-    public $showFilters = true;
83
-
84
-    /**
85
-     * @var Paginator
86
-     */
87
-    protected $pagination;
88
-
89
-    /**
90
-     * @var GridViewRequest
91
-     */
92
-    protected $request;
93
-
94
-    /**
95
-     * GridView constructor.
96
-     * @param array $config
97
-     * @throws Exceptions\GridViewConfigException
98
-     */
99
-    public function __construct(array $config)
100
-    {
101
-        $this->id = self::$counter++;
102
-
103
-        $this->loadConfig($config);
104
-
105
-        /**
106
-         * Making renderer
107
-         */
108
-        if (!is_object($this->renderer)) {
109
-            $className = GridViewHelper::resolveAlias('renderer', $this->renderer);
110
-            $this->renderer = new $className(array_merge(
111
-                $this->rendererOptions, [
112
-                    'gridView' => $this,
113
-                ]
114
-            ));
115
-        }
116
-
117
-        /**
118
-         * Build columns from config
119
-         */
120
-        $this->buildColumns();
121
-
122
-        $this->request = GridViewRequest::parse($this->id);
123
-        $this->request->perPage = $this->rowsPerPage;
124
-
125
-        $this->pagination = new LengthAwarePaginator(
126
-            $this->dataProvider->getData($this->request),
127
-            $this->dataProvider->getCount($this->request),
128
-            $this->rowsPerPage,
129
-            $this->request->page
130
-        );
131
-    }
132
-
133
-    /**
134
-     * @return array
135
-     */
136
-    protected function configTests(): array
137
-    {
138
-        return [
139
-            'dataProvider' => BaseDataProvider::class,
140
-            'columns' => 'array',
141
-            'renderer' => BaseRenderer::class,
142
-            'rowsPerPage' => 'int',
143
-            'tableHtmlOptions' => 'array',
144
-            'showFilters' => 'boolean',
145
-        ];
146
-    }
147
-
148
-    /**
149
-     * Build columns into objects
150
-     */
151
-    protected function buildColumns()
152
-    {
153
-        foreach ($this->columns as $key => &$columnOptions) {
154
-
155
-            /**
156
-             * In case of when column is already build
157
-             */
158
-            if (is_object($columnOptions)) {
159
-                continue;
160
-            }
161
-
162
-            /**
163
-             * When only attribute name/value passed
164
-             */
165
-            if (is_string($columnOptions)) {
166
-                $columnOptions = [
167
-                    'value' => $columnOptions,
168
-                ];
169
-            }
170
-
171
-            if ($columnOptions instanceof Closure) {
172
-                $columnOptions = [
173
-                    'class' => CallbackColumn::class,
174
-                    'value' => $columnOptions,
175
-                    'title' => GridViewHelper::columnTitle($key),
176
-                ];
177
-            }
178
-
179
-            /**
180
-             * Inline column declaration detector
181
-             */
182
-            if (is_string($columnOptions['value']) && strpos($columnOptions['value'], 'view:') === 0) {
183
-                $columnOptions['class'] = 'view';
184
-                $columnOptions['value'] = str_replace('view:', '', $columnOptions['value']);
185
-            }
186
-
187
-            $columnOptions = array_merge($this->columnOptions, $columnOptions);
188
-
189
-            $className = GridViewHelper::resolveAlias('column', $columnOptions['class']);
190
-            $columnOptions = new $className($columnOptions);
191
-        }
192
-    }
193
-
194
-    /**
195
-     * Draws widget and return html code
196
-     * @return string
197
-     */
198
-    public function render()
199
-    {
200
-        return $this->renderer->render($this);
201
-    }
202
-
203
-    /**
204
-     * @return LengthAwarePaginator|Paginator
205
-     */
206
-    public function getPagination()
207
-    {
208
-        return $this->pagination;
209
-    }
210
-
211
-    /**
212
-     * @return GridViewRequest
213
-     */
214
-    public function getRequest()
215
-    {
216
-        return $this->request;
217
-    }
218
-
219
-    /**
220
-     * @return int
221
-     */
222
-    public function getId() : int
223
-    {
224
-        return $this->id;
225
-    }
226
-
227
-    /**
228
-     * @return string
229
-     */
230
-    public function compileTableHtmlOptions() : string
231
-    {
232
-        return GridViewHelper::htmlOptionsToString($this->tableHtmlOptions);
233
-    }
18
+	use Configurable;
19
+
20
+	/**
21
+	 * Counter for ids
22
+	 * @var int
23
+	 */
24
+	private static $counter = 0;
25
+
26
+	/**
27
+	 * Grid id (used for request handling, for
28
+	 * @var int
29
+	 */
30
+	private $id;
31
+
32
+	/**
33
+	 * DataProvider provides gridview with the data for representation
34
+	 * @var BaseDataProvider
35
+	 */
36
+	public $dataProvider;
37
+
38
+	/**
39
+	 * Columns config. You may specify array or GridColumn instance
40
+	 * @var BaseColumn[]
41
+	 */
42
+	public $columns = [];
43
+
44
+	/**
45
+	 * Common options for all columns, will be appended to all columns configs
46
+	 * @var array
47
+	 */
48
+	public $columnOptions = [
49
+		'class' => AttributeColumn::class,
50
+	];
51
+
52
+	/**
53
+	 * Renders the final UI
54
+	 * @var string|BaseRenderer
55
+	 */
56
+	public $renderer = DefaultRenderer::class;
57
+
58
+	/**
59
+	 * Allows to pass some options into renderer/customize rendered behavior
60
+	 * @var array
61
+	 */
62
+	public $rendererOptions = [];
63
+
64
+	/**
65
+	 * Controls amount of data per page
66
+	 * @var int
67
+	 */
68
+	public $rowsPerPage = 25;
69
+
70
+	/**
71
+	 * Allows to tune the <table> tag with html options
72
+	 * @var array
73
+	 */
74
+	public $tableHtmlOptions = [
75
+		'class' => 'table table-bordered gridview-table',
76
+	];
77
+
78
+	/**
79
+	 * Indicate if filters will be shown or not
80
+	 * @var bool
81
+	 */
82
+	public $showFilters = true;
83
+
84
+	/**
85
+	 * @var Paginator
86
+	 */
87
+	protected $pagination;
88
+
89
+	/**
90
+	 * @var GridViewRequest
91
+	 */
92
+	protected $request;
93
+
94
+	/**
95
+	 * GridView constructor.
96
+	 * @param array $config
97
+	 * @throws Exceptions\GridViewConfigException
98
+	 */
99
+	public function __construct(array $config)
100
+	{
101
+		$this->id = self::$counter++;
102
+
103
+		$this->loadConfig($config);
104
+
105
+		/**
106
+		 * Making renderer
107
+		 */
108
+		if (!is_object($this->renderer)) {
109
+			$className = GridViewHelper::resolveAlias('renderer', $this->renderer);
110
+			$this->renderer = new $className(array_merge(
111
+				$this->rendererOptions, [
112
+					'gridView' => $this,
113
+				]
114
+			));
115
+		}
116
+
117
+		/**
118
+		 * Build columns from config
119
+		 */
120
+		$this->buildColumns();
121
+
122
+		$this->request = GridViewRequest::parse($this->id);
123
+		$this->request->perPage = $this->rowsPerPage;
124
+
125
+		$this->pagination = new LengthAwarePaginator(
126
+			$this->dataProvider->getData($this->request),
127
+			$this->dataProvider->getCount($this->request),
128
+			$this->rowsPerPage,
129
+			$this->request->page
130
+		);
131
+	}
132
+
133
+	/**
134
+	 * @return array
135
+	 */
136
+	protected function configTests(): array
137
+	{
138
+		return [
139
+			'dataProvider' => BaseDataProvider::class,
140
+			'columns' => 'array',
141
+			'renderer' => BaseRenderer::class,
142
+			'rowsPerPage' => 'int',
143
+			'tableHtmlOptions' => 'array',
144
+			'showFilters' => 'boolean',
145
+		];
146
+	}
147
+
148
+	/**
149
+	 * Build columns into objects
150
+	 */
151
+	protected function buildColumns()
152
+	{
153
+		foreach ($this->columns as $key => &$columnOptions) {
154
+
155
+			/**
156
+			 * In case of when column is already build
157
+			 */
158
+			if (is_object($columnOptions)) {
159
+				continue;
160
+			}
161
+
162
+			/**
163
+			 * When only attribute name/value passed
164
+			 */
165
+			if (is_string($columnOptions)) {
166
+				$columnOptions = [
167
+					'value' => $columnOptions,
168
+				];
169
+			}
170
+
171
+			if ($columnOptions instanceof Closure) {
172
+				$columnOptions = [
173
+					'class' => CallbackColumn::class,
174
+					'value' => $columnOptions,
175
+					'title' => GridViewHelper::columnTitle($key),
176
+				];
177
+			}
178
+
179
+			/**
180
+			 * Inline column declaration detector
181
+			 */
182
+			if (is_string($columnOptions['value']) && strpos($columnOptions['value'], 'view:') === 0) {
183
+				$columnOptions['class'] = 'view';
184
+				$columnOptions['value'] = str_replace('view:', '', $columnOptions['value']);
185
+			}
186
+
187
+			$columnOptions = array_merge($this->columnOptions, $columnOptions);
188
+
189
+			$className = GridViewHelper::resolveAlias('column', $columnOptions['class']);
190
+			$columnOptions = new $className($columnOptions);
191
+		}
192
+	}
193
+
194
+	/**
195
+	 * Draws widget and return html code
196
+	 * @return string
197
+	 */
198
+	public function render()
199
+	{
200
+		return $this->renderer->render($this);
201
+	}
202
+
203
+	/**
204
+	 * @return LengthAwarePaginator|Paginator
205
+	 */
206
+	public function getPagination()
207
+	{
208
+		return $this->pagination;
209
+	}
210
+
211
+	/**
212
+	 * @return GridViewRequest
213
+	 */
214
+	public function getRequest()
215
+	{
216
+		return $this->request;
217
+	}
218
+
219
+	/**
220
+	 * @return int
221
+	 */
222
+	public function getId() : int
223
+	{
224
+		return $this->id;
225
+	}
226
+
227
+	/**
228
+	 * @return string
229
+	 */
230
+	public function compileTableHtmlOptions() : string
231
+	{
232
+		return GridViewHelper::htmlOptionsToString($this->tableHtmlOptions);
233
+	}
234 234
 }
235 235
\ No newline at end of file
Please login to merge, or discard this patch.
src/functions.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,5 +7,5 @@
 block discarded – undo
7 7
  * @throws \Woo\GridView\Exceptions\GridViewConfigException
8 8
  */
9 9
 function grid(array $config) {
10
-    return (new \Woo\GridView\GridView($config))->render();
10
+	return (new \Woo\GridView\GridView($config))->render();
11 11
 }
12 12
\ No newline at end of file
Please login to merge, or discard this patch.