| |

PHP Advanced Datatable in Laravel >= 5.0


The datatable class contians "addfilter(filed_name,'select',label,operator,array of data)" method to add new select filter

IDUsernameFirstnameLastnameEmail




You can add a text filter by call "addfilter(filed_name,'select',label,operator,array of data)" from datatable object that was created in the action of your controller as shown below:



    $dt->addfilter(filed_name,'select',label,operator,array of data);

    operator takes the following values:    =
                                            <
                                            >
                                            >=
                                            <=
                                            !=
                                            like

For example:
in the action of your controller put the following code:

    $dt = new Your/Datatable/Class(
            array(
                'firstname' => 'Firstname',
                'lastname' => 'Lastname'
            ));
     $dt->addfilter('id','select','UserID','=',array(1=>'S3400',2=>'S400',4=>'S200'));
    return $dt->display('Your/Blade/Template',$request);

in your blade template where you want your datatable appears put the following code:
	@include('phpdt::datatable_view')
	@section('datatable_section')
		@parent
	@show
        

Note:

The argument filed_name passed in "addfilter" must be declared in the select statement of your datatable class.


By: Mohammad Alaa Aldeen
Git: https://github.com/mhdalaaaldeen