PHPackages                             binarycabin/laravel-reporting - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. binarycabin/laravel-reporting

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

binarycabin/laravel-reporting
=============================

Basic tools for building reports

1.0.0(8y ago)086MITPHP

Since Nov 20Pushed 8y agoCompare

[ Source](https://github.com/binarycabin/laravel-reporting)[ Packagist](https://packagist.org/packages/binarycabin/laravel-reporting)[ RSS](/packages/binarycabin-laravel-reporting/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Laravel-Reporting
=================

[](#laravel-reporting)

Basic tools for building reports

```
composer require binarycabin/laravel-reporting

```

Available Traits
----------------

[](#available-traits)

### \\BinaryCabin\\LaravelReporting\\Traits\\Sortable

[](#binarycabinlaravelreportingtraitssortable)

Provides a scope to pass sortable values to a query:

```
// (/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:

protected $sortFieldDefault = 'id'; protected $sortOrderDefault = 'ASC';

### \\BinaryCabin\\LaravelReporting\\Traits\\Filterable

[](#binarycabinlaravelreportingtraitsfilterable)

Provides scopes to add filtering to your query:

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

```

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

```
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

```
    protected $filterableGlobal = [
        'first_name',
        'company',
    ];

```

```
\App\User::filter(['global'=>'ABC Company'])->get();

```

Available Views
---------------

[](#available-views)

A sortable button is included to pass the "sort" and "sort\_order" request values when viewing a table:

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

```

Available Controllers
---------------------

[](#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:

```
