PHPackages                             lucianolima00/laravel-grid-view - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. lucianolima00/laravel-grid-view

ActiveLibrary[Templating &amp; Views](/categories/templating)

lucianolima00/laravel-grid-view
===============================

Grid view for laravel framework

1.0.20(2y ago)177MITPHPPHP &gt;=7.1.0

Since Apr 12Pushed 2y agoCompare

[ Source](https://github.com/lucianolima00/laravel-grid-view)[ Packagist](https://packagist.org/packages/lucianolima00/laravel-grid-view)[ RSS](/packages/lucianolima00-laravel-grid-view/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (1)Versions (10)Used By (0)

Laravel Grid View
=================

[](#laravel-grid-view)

[![Latest Stable Version](https://camo.githubusercontent.com/9c4ba9653ec64e60279e377e4adc28cdced06270daa18c06c4ea85670a15388c/68747470733a2f2f706f7365722e707567782e6f72672f6c756369616e6f6c696d6130302f6c61726176656c2d677269642d766965772f762f737461626c65)](https://packagist.org/packages/lucianolima00/laravel-grid-view)[![Latest Unstable Version](https://camo.githubusercontent.com/774bc62400a253582bb9602aab9bacb19f5ed1456b7f31b5e6ca3923a7ceb23b/68747470733a2f2f706f7365722e707567782e6f72672f6c756369616e6f6c696d6130302f6c61726176656c2d677269642d766965772f762f756e737461626c65)](https://packagist.org/packages/lucianolima00/laravel-grid-view)[![License](https://camo.githubusercontent.com/3309fb6f22c1974cd42daeba3e10ce783d7b750a0234b591271e4f21dc18c92f/68747470733a2f2f706f7365722e707567782e6f72672f6c756369616e6f6c696d6130302f6c61726176656c2d677269642d766965772f6c6963656e7365)](https://packagist.org/packages/lucianolima00/laravel-grid-view)[![Total Downloads](https://camo.githubusercontent.com/e2ab04dfa2535c65baf8a1197fcfe82da3c016f4f53e2c4e25f8c10babc7239e/68747470733a2f2f706f7365722e707567782e6f72672f6c756369616e6f6c696d6130302f6c61726176656c2d677269642d766965772f646f776e6c6f616473)](https://packagist.org/packages/lucianolima00/laravel-grid-view)[![Build Status](https://camo.githubusercontent.com/b527cf9d26b3c2bb3d16140167f2d777d07c965b6a65cf6e1e8777029976eb52/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c756369616e6f6c696d6130302f6c61726176656c2d677269642d766965772f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lucianolima00/laravel-grid-view/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f8871289e17b72ca971b1e8612a4a000078c1d7ec1c50cadc51dd49abcec3aa5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c756369616e6f6c696d6130302f6c61726176656c2d677269642d766965772f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lucianolima00/laravel-grid-view/?branch=master)

Introduction
------------

[](#introduction)

This package is to displaying the model data in a Grid table.

[![Grid view appearance](https://github.com/lucianolima00/laravel-grid-view/raw/master/laravel_grid_view_appearance_en.png)](https://github.com/lucianolima00/laravel-grid-view/blob/master/laravel_grid_view_appearance_en.png)

Requirements
------------

[](#requirements)

- laravel 5.5+ | 6+ | 7+ | 8+ | 9+ | 10+
- Bootstrap 4 for styling
- JQuery
- php &gt;= 7.1
- composer

Installation
------------

[](#installation)

### General from remote packagist repository

[](#general-from-remote-packagist-repository)

Run the composer command:

`composer require lucianolima00/laravel-grid-view "~1.0.19"`

### If you are testing this package from a local server directory

[](#if-you-are-testing-this-package-from-a-local-server-directory)

In application `composer.json` file set the repository, as in example:

```
"repositories": [
    {
        "type": "path",
        "url": "../laravel-grid-view",
        "options": {
            "symlink": true
        }
    }
],
```

Here,

**../laravel-grid-view** - directory path, which has the same directory level as application and contains Grid View package.

Then run command:

`composer require lucianolima00/laravel-grid-view:dev-master --prefer-source`

### Registration

[](#registration)

Register service provider in **config/app.php**

```
Lucianolima00\GridView\GridViewServiceProvider::class,
```

### Publish files (Not necessary)

[](#publish-files-not-necessary)

- To publish views run command:

    `php artisan grid_view:publish --only=views`

    It stores view files to `resources/views/vendor/grid_view` folder.
- To publish translations run command:

    `php artisan grid_view:publish --only=lang`

    It stores translation files to `resources/lang/vendor/grid_view` folder.
- To publish all parts run command without `only` argument:

    `php artisan grid_view:publish`

    Else you can use `--force` argument to rewrite already published files.

Usage
-----

[](#usage)

Make sure you use a **Bootstrap 4** for styling and **JQuery** in your application.

### Controller part

[](#controller-part)

Must use `EloquentDataProvider` to insert data in to the view template.

For `EloquentDataProvider` class constructor use a model query object.

Example:

```
namespace App\Http\Controllers;

use Lucianolima00\GridView\DataProviders\EloquentDataProvider;
```

```
class ExampleController extends Controller
{
    public function example()
    {
        $dataProvider = new EloquentDataProvider(ExampleModel::query());
        return view('example-view', [
            'dataProvider' => $dataProvider
        ]);
    }
}
```

### View template part

[](#view-template-part)

Use `@gridView()` directive with config array in a blade view template.

#### Simple quick usage

[](#simple-quick-usage)

You can simply set columns to display as **string** format in `columnFields` array.

Note:

There search filter fields are displayed automatically. By default **text** form field filters are used.

If you don't want to use search filters, set `useFilters` = **false**.

```
@php
$gridData = [
    'dataProvider' => $dataProvider,
    'title' => 'Panel title',
    'useFilters' => false,
    'columnFields' => [
        'id',
        'active',
        'icon',
        'created_at'
    ]
];
@endphp
```

```
@gridView($gridData)
```

Alternative variant without a blade directive:

```
{!! grid_view([
    'dataProvider' => $dataProvider,
    'useFilters' => false,
    'columnFields' => [
        'id',
        'active',
        'icon',
        'created_at'
    ]
]) !!}
```

#### Setting custom options

[](#setting-custom-options)

##### Main columns

[](#main-columns)

Simple example:

```
@gridView([
    'dataProvider' => $dataProvider,
    'columnFields' => [
        [
            'label' => 'First Name', // Column label.
            'attribute' => 'first_name', // Attribute, by which the row column data will be taken from a model.
        ],
        [
            'label' => 'Last Name',
            'value' => function ($row) {
                return $row->last_name;
            }
            'sort' => 'last_name' // To sort rows. Have to set if an 'attribute' is not defined for column.
        ],
    ]
])
```

##### Special columns

[](#special-columns)

Besides main columns, there can be the next special columns:

- `ActionColumn` - is for displaying Buttons to **view**, **edit** and **delete** rows.

    Set `'class' => Lucianolima00\GridView\Columns\ActionColumn::class` in column option

    There are the next required `actionTypes`:

    - **view** - makes a link for viewing. Default url scheme: `url()->current()  . '/' . $row->id . '/delete'`.
    - **edit** - makes a link for edition. Default url scheme: `url()->current()  . '/' . $row->id . '/edit'`.
    - **delete** - makes a link for deletion. Default url scheme: `url()->current()  . '/' . $row->id . '/delete'`.

    They can be simple **strings**, **arrays** or **callbacks**.

    For array format it is necessary set `class`. And optional: `url`, `htmlAttributes`.

    By **callback** you can change urls to your routes.

    Simple example for a column config:

    ```
    @gridView([
        'dataProvider' => $dataProvider,
        'columnFields' => [
            [
                'label' => 'Actions', // Optional
                'class' => Lucianolima00\GridView\Columns\ActionColumn::class, // Required
                'actionTypes' => [ // Required
                    'view',
                    'edit' => function ($data) {
                        return '/admin/pages/' . $data->id . '/edit';
                    },
                    [
                        'class' => Lucianolima00\GridView\Actions\Delete::class, // Required
                        'url' => function ($data) { // Optional
                            return '/admin/pages/' . $data->id . '/delete';
                        },
                        'htmlAttributes' => [ // Optional
                            'target' => '_blank',
                            'style' => 'color: yellow; font-size: 16px;',
                            'onclick' => 'return window.confirm("Are you sure you want to delete?");'
                        ]
                    ]
                ]
            ]
        ]
    ])
    ```
- `CheckboxColumn` - is for displaying Checkboxes to multiple choose the rows.

    Set `'class' => Lucianolima00\GridView\Columns\CheckboxColumn::class` in column option

    There are the next required options:

    - **field** - is for a `name` checkbox input attribute. It is rendered as an array `name="{{ $field }}[]"`.
    - **attribute** - is for a `value` checkbox input attribute. It is rendered as: `value="$row->{$this->attribute}"`.

    Simple example for a column config:

    ```
    @gridView([
        'dataProvider' => $dataProvider,
        'columnFields' => [
            [
                'class' => Lucianolima00\GridView\Columns\CheckboxColumn::class,
                'field' => 'delete',
                'attribute' => 'id'
            ]
        ]
    ])
    ```

##### Filters

[](#filters)

There are the next filter's variants:

- Column option to switch off the filter:

    ```
    'filter' => false
    ```
- `TextFilter` - is a default filter, which renders a text form field to search, using column attribute.
- `DropdownFilter` - is a filter, which renders `` html tag.

    Set the next as column option:

    ```
    @gridView([
        'dataProvider' => $dataProvider,
        'columnFields' => [
            [
                'attribute' => 'example_attribute',
                'filter' => [
                    'class' => Lucianolima00\GridView\Filters\DropdownFilter::class,
                    'data' => ['key' => 'value', 'key' => 'value'] // Array keys are for html  tag values, array values are for titles.
                ]
            ]
        ]
    ])
    ```

    If `attribute` is not defined for column or you want to set a special filter field name:

    ```
    @gridView([
        'dataProvider' => $dataProvider,
        'columnFields' => [
            [
                'filter' => [
                    'class' => Lucianolima00\GridView\Filters\DropdownFilter::class,
                    'name' => 'example_name',
                    'data' => ['key' => 'value', 'key' => 'value'] // Array keys are for html  tag values, array values are for titles.
                ]
            ]
        ]
    ])
    ```

##### Formatters

[](#formatters)

There are the next formatter keys:

- **html** - is for passing a row content with html tags.
- **image** - is for inserting a row data in to `src` attribute of `` tag.
- **text** - applies `strip_tags()` for a row data.
- **url** - is for inserting a row data in to `href` attribute of `` tag.

For that keys there are the next formatters:

- `HtmlFormatter`
- `ImageFormatter`
- `TextFormatter`
- `UrlFormatter`

Also you can set formatter with some addition options. See the next simple example:

```
@gridView([
    'dataProvider' => $dataProvider,
    'columnFields' => [
        [
            'attribute' => 'url',
            'format' => [
                'class' => Lucianolima00\GridView\Formatters\UrlFormatter::class,
                'title' => 'Source',
                'htmlAttributes' => [
                    'target' => '_blank'
                ]
            ]
        ],
        [
            'attribute' => 'content',
            'format' => 'html'
        ]
    ]
])
```

##### Existing form areas and main buttons

[](#existing-form-areas-and-main-buttons)

[![Grid view forms](https://github.com/lucianolima00/laravel-grid-view/raw/master/laravel_grid_view_forms_en.png)](https://github.com/lucianolima00/laravel-grid-view/blob/master/laravel_grid_view_forms_en.png)

There are two main form areas:

- `grid_view_filters_form`

    Two buttons affect search request submission:

    - **Search**. You can change a button label by option: `searchButtonLabel`.
    - **Reset**. You can change a button label by option: `resetButtonLabel`.

    If `useFilters` = **false**, these buttons will not be displayed.
- `grid_view_rows_form`

    You can set a specific `action` attribute value by option `rowsFormAction`.

    One button affect a main submit request:

    - **Send**. You can change a button label by option: `sendButtonLabel`.

        Note! This button will be displayed under one of two conditions:

        - There is a checkbox column.
        - Option `useSendButtonAnyway` = **true**.

##### Complex extended example

[](#complex-extended-example)

```
@php
$gridData = [
    'dataProvider' => $dataProvider,
    'paginatorOptions' => [ // Here you can set some options of paginator Illuminate\Pagination\LengthAwarePaginator, used in a package.
        'pageName' => 'p'
    ],
    'rowsPerPage' => 5, // The number of rows in one page. By default 10.
    'title' => 'Panel title', // It can be empty ''
    'strictFilters' => true, // If true, then a searching by filters will be strict, using an equal '=' SQL operator instead of 'like'.
    'rowsFormAction' => '/admin/pages/deletion', // Route url to send slected checkbox items for deleting rows, for example.
    'useSendButtonAnyway' => true, // If true, even if there are no checkbox column, the main send button will be displayed.
    'searchButtonLabel' => 'Find',
    'columnFields' => [
        [
            'attribute' => 'id', // REQUIRED if value is not defined. Attribute name to get row column data.
            'label' => 'ID', // Column label.
            'filter' => false, // If false, then column will be without a search filter form field.,
            'htmlAttributes' => [
                'width' => '5%' // Width of table column.
            ]
        ],
        [
            'label' => 'Active', // Column label.
            'value' => function ($row) { // You can set 'value' as a callback function to get a row data value dynamically.
                return '';
            },
            'filter' => [ // For dropdown it is necessary to set 'data' array. Array keys are for html  tag values, array values are for titles.
                'class' => Lucianolima00\GridView\Filters\DropdownFilter::class, // REQUIRED. For this case it is necessary to set 'class'.
                'name' => 'active', // REQUIRED if 'attribute' is not defined for column.
                'data' => [ // REQUIRED.
                    0 => 'No active',
                    1 => 'Active',
                ]
            ],
            'format' => 'html', // To render column content without lossless of html tags, set 'html' formatter.
            'sort' => 'active' // To sort rows. Have to set if an attribute is not defined for column.
        ],
        [
            'label' => 'Icon', // Column label.
            'value' => function ($row) { // You can set 'value' as a callback function to get a row data value dynamically.
                return $row->icon;
            },
            'filter' => false, // If false, then column will be without a search filter form field.
            'format' => [ // Set special formatter. If $row->icon value is a url to image, it will be inserted in to 'src' attribute of  tag.
                'class' => Lucianolima00\GridView\Formatters\ImageFormatter::class, // REQUIRED. For this case it is necessary to set 'class'.
                'htmlAttributes' => [ // Html attributes for  tag.
                    'width' => '100'
                ]
            ]
        ],
        'created_at', // Simple column setting by string.
        [ // Set Action Buttons.
            'class' => Lucianolima00\GridView\Columns\ActionColumn::class, // REQUIRED.
            'actionTypes' => [ // REQUIRED.
                'view',
                'edit' => function ($data) {
                    return '/admin/pages/' . $data->id . '/edit';
                },
                [
                    'class' => Lucianolima00\GridView\Actions\Delete::class, // REQUIRED
                    'url' => function ($data) {
                        return '/admin/pages/' . $data->id . '/delete';
                    },
                    'htmlAttributes' => [
                        'target' => '_blank',
                        'style' => 'color: yellow; font-size: 16px;',
                        'onclick' => 'return window.confirm("Sure to delete?");'
                    ]
                ]
            ]
        ],
        [
            // For this case checkboxes will be rendered according with:
            'class' => Lucianolima00\GridView\Columns\CheckboxColumn::class, // REQUIRED.
            'field' => 'delete', // REQUIRED.
            'attribute' => 'id' // REQUIRED.
            'display' => function ($row) {
                return {...condition to return true for displaying...};
            }
        ]
    ]
];
@endphp
```

```
@gridView($gridData)
```

License
-------

[](#license)

Copyright © 2020-2023 Andrey Girnik .

Licensed under the [MIT license](http://opensource.org/licenses/MIT). See LICENSE.txt for details.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Recently: every ~26 days

Total

9

Last Release

1018d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/351ec1962ee76be37dbed332fe371a8f7a5f7ab989c0783b4cbf3f9dd0c7e7fb?d=identicon)[lucianolima00](/maintainers/lucianolima00)

---

Top Contributors

[![itstructure](https://avatars.githubusercontent.com/u/31563329?v=4)](https://github.com/itstructure "itstructure (15 commits)")

---

Tags

laravelgridviewtablegridview

### Embed Badge

![Health badge](/badges/lucianolima00-laravel-grid-view/health.svg)

```
[![Health](https://phpackages.com/badges/lucianolima00-laravel-grid-view/health.svg)](https://phpackages.com/packages/lucianolima00-laravel-grid-view)
```

###  Alternatives

[itstructure/laravel-grid-view

Grid view for laravel framework

2546.6k2](/packages/itstructure-laravel-grid-view)[anourvalar/office

Generate documents from existing Excel &amp; Word templates | Export tables to Excel (Grids)

24085.2k](/packages/anourvalar-office)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

116.6k](/packages/tomshaw-electricgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
