2017 © Pedro Peláez
 

library laravel-table-view

An API-based table view for Laravel. Based on Vue.js and Element-UI.

image

lykegenes/laravel-table-view

An API-based table view for Laravel. Based on Vue.js and Element-UI.

  • Wednesday, August 16, 2017
  • by Lykegenes
  • Repository
  • 1 Watchers
  • 2 Stars
  • 281 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 5 % Grown

The README.md

Laravel Table View

Latest Version on Packagist Software License Build Status Code Coverage Total Downloads, (*1)

Installation

Composer

Execute the following command to get the latest version of the package:, (*2)

composer require lykegenes/laravel-table-view

Laravel

In your config/app.php add Lykegenes\TableView\Providers\TableViewServiceProvider::class, to the end of the providers array:, (*3)

'providers' => [
    ...
    Lykegenes\TableView\Providers\TableViewServiceProvider::class,
],

Usage

Create a Table View

Create a Table View class; it will allow you to configure your table., (*4)

<?php

namespace App\TableViews;

use Lykegenes\TableView\AbstractTableView;

class DemoTableView extends AbstractTableView
{
    public function getApiUrl()
    {
        return '/demo-api';
    }

    public function build()
    {
        $this->addColumn('Nom', 'name', [
                'sortable',
            ])
            ->addColumn('Adresse', 'address', [
                'sortable',
            ])
            ->addColumn('Date', 'date', [
                'sortable',
            ])
            ->addTemplateColumn('Tag', 'columns.locationTags')
            ->addTemplateColumn('Operation', 'columns.operations');

        $this->setDefaultSort('date');
    }
}

Displaying the table in a view

Calling the render() method on a TableView instance will compile it and render it. You should call this method inside one of your app's Blade views with the {!! !!} blade statement, in order not to escape the Html. Here is an example of a complete Blade template, (*5)

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Demo</title>

        <!-- Element-UI Stylesheet -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/element-ui/1.1.6/theme-default/index.css" />
    </head>
    <body>
        <div id="app" class="content">

            {!! $demoTableView->render() !!}

        </div>

        <!-- Include Vue, Element-UI and Axios -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/element-ui/1.1.6/index.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.15.3/axios.min.js"></script>

        <!-- The table scripts will be added to this stack -->
        @stack('table-view-templates')
        @stack('table-view-scripts')

        <!-- Your Vue instance for this page -->
        <script type="text/javascript">
            new Vue({
                el: '#app',
            });
        </script>

    </body>
</html>

Setting-up the API endpoint

A few steps are required to support the searching and sorting features. To achieve this, we use the "Laravel 5 Repositories" by Andersao., (*6)

class ApiDemoController extends Controller
{
    protected $users;

    public function __construct(UserRepository $users)
    {
        $this->users = $users;
        $this->users->setPresenter(UserPresenter::class);
    }

    public function demoApi(Request $request)
    {
        $sort = $request->input('sort', 'name');
        $order = $request->input('order', 'asc');

        $this->users->orderBy($sort, $order);

        if ($request->has('search')) {
            $this->users->pushCriteria(new \Lykegenes\TableView\Criteria\SearchCriteria(['name', 'email'], $request->input('search')));
        }

        return $this->users->paginate($request->input('limit', 15));
    }
}

Credits

License

The MIT License (MIT). Please see License File for more information., (*7)

The Versions

16/08 2017

dev-master

9999999-dev https://github.com/Lykegenes/laravel-table-view

An API-based table view for Laravel. Based on Vue.js and Element-UI.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel datatable

16/08 2017

v1.1.3

1.1.3.0 https://github.com/Lykegenes/laravel-table-view

An API-based table view for Laravel. Based on Vue.js and Element-UI.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel datatable

28/04 2017

v1.1.2

1.1.2.0 https://github.com/Lykegenes/laravel-table-view

An API-based table view for Laravel. Based on Vue.js and Element-UI.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel datatable

28/04 2017

v1.1.1

1.1.1.0 https://github.com/Lykegenes/laravel-table-view

An API-based table view for Laravel. Based on Vue.js and Element-UI.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel datatable

23/02 2017

1.1.1

1.1.1.0 https://github.com/Lykegenes/laravel-table-view

An API-based table view for Laravel. Based on Vue.js and Element-UI.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel datatable

13/02 2017

v1.1.0

1.1.0.0 https://github.com/Lykegenes/laravel-table-view

An API-based table view for Laravel. Based on Vue.js and Element-UI.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel datatable

05/02 2017

v1.0.0

1.0.0.0 https://github.com/Lykegenes/laravel-table-view

An API-based table view for Laravel. Based on Vue.js and Element-UI.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel datatable