DataFilter

reset
ID Title Author Categories Date Body Edit
1 Article 1 Jhon Doe Category 1, Category 2 05/24/2019 Body of article 1
10 Article 10 Jhon Doe 05/24/2019 Body of article 10
11 Article 11 Jane Doe 05/24/2019 Body of article 11
12 Article 12 Jhon Doe 05/24/2019 Body of article 12
13 Article 13 Jhon Doe 05/24/2019 Body of article 13
14 Article 14 Jhon Doe 05/24/2019 Body of article 14
15 Article 15 Jane Doe 05/24/2019 Body of article 15
16 Article 16 Jhon Doe 05/24/2019 Body of article 16
17 Article 17 Jane Doe 05/24/2019 Body of article 17
18 Article 18 Jhon Doe 05/24/2019 Body of article 18


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->pluck("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