PHP code example of larasquad / filter

1. Go to this page and download the library: Download larasquad/filter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

larasquad / filter example snippets



namespace  App\Filters;

use Larasquad\Filter\Filter;

class  UserFilter  extends  Filter
{

    /**
     *  Whitelisted request filterable attributes
     *
     * @return array
     */
    protected $filterable = [];

}

    protected $filterable = ["first_name", "last_name", "email"];

    protected $filterable = ["first_name", "last_name", "email", "from", "to" ];

    public function from($value)
    {
        $this->query->whereDate('date', '>', $value);
    }

    public function to($value)
    {
        $this->query->whereDate('to', '>', $value);
    }


public  function  index(Request $request)
{
	//
}


public  function  index(UserFilter $filter)
{
	//
}

use Larasquad\Filter\Traits\Filterable;

class  User  extends  Authenticatable
{
	use Filterable;
}


public  function  index(UserFilter $filter)
{
	$users = User::filter($filter)->get();
	return  view('pages.users.index', compact('users'));
}

/**
* Filters the first_name column of the resource
*
* @return  void
*/
public  function  firstName($value)
{
	$this->query->where('first_name', 'like', "%{$value}%");
}