Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcosrjjunior/lvlgrid
:sparkles: Grid helper to your Laravel application. Filter, order and pagination ajax
https://github.com/marcosrjjunior/lvlgrid
datatables grid javascript laravel vuejs
Last synced: 3 months ago
JSON representation
:sparkles: Grid helper to your Laravel application. Filter, order and pagination ajax
- Host: GitHub
- URL: https://github.com/marcosrjjunior/lvlgrid
- Owner: marcosrjjunior
- Created: 2016-03-01T22:45:02.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-06T23:44:03.000Z (almost 9 years ago)
- Last Synced: 2024-04-14T05:01:52.661Z (9 months ago)
- Topics: datatables, grid, javascript, laravel, vuejs
- Language: PHP
- Homepage:
- Size: 9.77 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lvlGrid
## Documentation
* [Installation](#installation)
* [Getting started](#getting-started)
* [Get Data](#get-data)
* [Transformer](#transformer)___
#### Dependencies```js
```
#### InstallationFirst, pull in the package through Composer.
```
composer require mrjj/lvlgrid
```And then include the service provider within `app/config/app.php`.
```php
'providers' => [
Mrjj\LvlGrid\LvlGridServiceProvider::class
];
```#### Getting started
First, create add a route to grid method
```php
Route::get('countries/grid', '....Controller@grid');
```Use a trait and add a required informations in your controller
```php
use Mrjj\LvlGrid\LvlGrid;class ..Controller extends Controller
{
use LvlGridprotected $gridModel = \App\Models\Country::class;
protected $threshold = 30;
...
}```
Finally, add this @includes(lvlgrid::...) , lvlgrid component and fill your infos
```php
@extend('default')@section('scripts')
@include('lvlgrid::scripts')
@stop
@section('content')
lvlGrid
@include('lvlgrid::grid')
..
```#### Get Data
Add a gridData() method if you want to customize your query```php
public function gridData()
{
return DB::table('users')
->leftJoin('posts', 'users.id', '=', 'posts.user_id')
}
```
> @return \Illuminate\Database\Query\Builder#### Transformer
To transform your data you need add a gridTransformer() method and modify what you want
```php
public function gridTransformer($data)
{
foreach($data['items'] as $_grid) {
$_grid->status = trans('form.status.'.$_grid->status);
}
}
```
> In this example I'm changing the status for a friendly name like 'Active' and 'Inactive'If you need to modify the views, you can run:
```bash
php artisan vendor:publish --provider="Mrjj\LvlGrid\LvlGridServiceProvider"
```The package views will now be located in the `app/resources/views/vendor/mrjj/lvlgrid`