1. Go to this page and download the library: Download mehdirajabi/filterable 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/ */
mehdirajabi / filterable example snippets
use Mehdirajabi\Filterable\Filterable;
class User extends Model
{
use Filterable;
}
class UserController extends Controller
{
public function index()
{
return User::filter()->actived()->get();
}
}
use Mehdirajabi\Filterable\Filterable;
class User extends Model
{
use Filterable;
public function profile()
{
return $this->hasOne(UserProfile::class);
}
}
use Mehdirajabi\Filterable\Operators\FilterEqual;
class User extends Model
{
protected $filterMode = [
'status' => FilterEqual::class
];
}
use Mehdirajabi\Filterable\Operators\FilterBetween;
class UserController extends Controller
{
public function index()
{
return User::filter(['id' => FilterBetween::class])->paginate(100);
}
}
use Mehdirajabi\Filterable\Operators\FilterBetween;
class User extends Model
{
protected $filterMode = [
'created_at' => FilterBetween::class
];
}