DataFilter

reset
ID Title Author Categories Date Body Edit
1 Article 1 Jhon Doe Category 1, Category 2 09/23/2017 Body of article 1
2 Article 2 Jhon Doe 09/23/2017 Body of article 2
3 Article 3 Jane Doe 09/23/2017 Body of article 3
4 Article 4 Jane Doe 09/23/2017 Body of article 4
5 Article 5 Jhon Doe 09/23/2017 Body of article 5
6 Article 6 Jane Doe 09/23/2017 Body of article 6
7 Article 7 Jane Doe 09/23/2017 Body of article 7
8 Article 8 Jane Doe 09/23/2017 Body of article 8
9 Article 9 Jane Doe 09/23/2017 Body of article 9
10 Article 10 Jhon Doe 09/23/2017 Body of article 10


class DemoController extends Controller

....

    public function 
getFilter()
    {
        
$filter = \DataFilter::source(Article::with('author','categories'));
        
$filter->add('title','Title''text');
        
$filter->add('categories.name','Categories','tags');
        
$filter->add('publication_date','publication date','daterange')->format('m/d/Y''en');
        
$filter->submit('search');
        
$filter->reset('reset');
        
$filter->build();

        
$grid = \DataGrid::source($filter);
        
$grid->attributes(array("class"=>"table table-striped"));
        
$grid->add('id','ID'true)->style("width:70px");
        
$grid->add('title','Title'true);
        
$grid->add('author.fullname','Author');
        
$grid->add('{{ implode(", ", $categories->lists("name")->all()) }}','Categories');
        
$grid->add('publication_date|strtotime|date[m/d/Y]','Date'true);
        
$grid->add('body|strip_tags|substr[0,20]','Body');
        
$grid->edit('/rapyd-demo/edit''Edit','modify|delete');
        
$grid->paginate(10);

        return  
view('rapyd::demo.filtergrid'compact('filter''grid'));
    }



@extends('rapyd::demo.demo')

@section('title','DataFilter')

@section('body')

    @include('rapyd::demo.menu_filter')

    <h1>DataFilter</h1>

    <p>
        {!! $filter !!}
        {!! $grid !!}
        
        
    </p>

@stop