2017 © Pedro Peláez
 

library laravel-reporting

Basic tools for building reports

image

binarycabin/laravel-reporting

Basic tools for building reports

  • Monday, November 20, 2017
  • by binarycabin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 44 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 57 % Grown

The README.md

Laravel-Reporting

Basic tools for building reports, (*1)

composer require binarycabin/laravel-reporting

Available Traits

\BinaryCabin\LaravelReporting\Traits\Sortable

Provides a scope to pass sortable values to a query:, (*2)

// (/users?sort=last_name&sort_order=ASC)
$users = \App\User::sort($request->all())->get();

On your model, add the properties below to set the default sorting when none is passed:, (*3)

protected $sortFieldDefault = 'id'; protected $sortOrderDefault = 'ASC';, (*4)

\BinaryCabin\LaravelReporting\Traits\Filterable

Provides scopes to add filtering to your query:, (*5)

\App\User::filter($request->all())->get();

On your model, add a filterable property to determine all columns allowed to be filtered:, (*6)

protected $filterable = [
        'first_name',
        'last_name',
        'global',
];

If a scope with the filterable name exists, it will be used in the filter. A scope "global" is provided in the trait. This will look through all fields in your "filterableGlobal" array for the passed query, (*7)

    protected $filterableGlobal = [
        'first_name',
        'company',
    ];
\App\User::filter(['global'=>'ABC Company'])->get();

Available Views

A sortable button is included to pass the "sort" and "sort_order" request values when viewing a table:, (*8)

<th>@include('reporting::components.sort-button',['sortField'=>'created_at']) Date Created</th>

Available Controllers

An extendable controller is also available, which provides basic CRUD operation, along with default Sort/Filter functionality. To use this controller, simply create a controller extending it and passing available properties shown below:, (*9)

<?php

namespace App\Http\Controllers\Manage\Users;

use BinaryCabin\LaravelReporting\Http\Controllers\BaseManageController;

class UserController extends BaseManageController
{

    protected $modelClass = \App\User::class;
    protected $baseTitlePlural = 'Users';
    protected $baseTitleSingular = 'User';
    protected $variableNamePlural = 'users';
    protected $variableNameSingular = 'user';
    protected $baseRoute = 'manage/user';
    protected $viewIndex = 'manage.user.index';
    protected $viewCreate='manage.user.create';
    protected $viewEdit='manage.user.edit';

}

The Versions

20/11 2017

dev-master

9999999-dev

Basic tools for building reports

  Sources   Download

MIT

20/11 2017

1.0.0

1.0.0.0

Basic tools for building reports

  Sources   Download

MIT