Всего по немногу

Need Yii’s gridview in Laravel?

It was a pleasure to work with this flexible and powerful component in yii! But, when I started coding on laravel, I was unable to find a good analog. I spend some time on the previous job with customizing and setting up gridview component and I explored how good is its architecture! That’s why I decided to develop my own package which will implement main gridview functionality for laravel.

So, how it works?
Currently, there is a single dataprovider which allows reading data from eloquent. For sure, there will be more dataproviders in the future.
The difference with yii’s gridview is that gridview could be used by calling function grid() which accepts grid configuration.
Config format is pretty similar to yii’s one, but there is a list of features that currently not supported:
1) Passing callback into htmlOptions
2) htmlOptions for tr tag
3) caption
4) filters
5) formatters – I have different thoughts about this, probably it will be different columns classes, without yii’s notation created_at:datetime
6) layout – it is fully replaced with the renderer.

In the latest point I noticed that there is a renderer. What does it mean? Yii’s gridview use Html::* for building the view, in my package, there was added such notion as renderer. Renderer is just a class with single method render(GridView $grid), which is inherited from the interface. Currently, there is a single renderer – it just passes grid to view file and makes it rendering in html layout. But, you may add your custom renderer – in case of some extra features in rendering are needed. That’s why I added `$renderer` as a property into gridview, with prefilled value: Woo\GridView\Renderers\DefaultRenderer::class;