PHP code example of zaratesystems / laravel-filterable
1. Go to this page and download the library: Download zaratesystems/laravel-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/ */
zaratesystems / laravel-filterable example snippets
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Zarate\Filterable\Filterable;
class User extends Model
{
use Filterable;
}
namespace App\Filters;
use Zarate\Filterable\QueryFilters;
class UserFilter extends QueryFilters
{
/**
* @param string $name
* @return \Illuminate\Database\Eloquent\Builder
*/
public function name(string $name)
{
return $this->builder->where('name', $name);
}
}
namespace App\Http\Controllers;
use App\Filters\UserFilter;
use App\Models\User;
class UserController extends Controller
{
public function index(UserFilter $filters)
{
$users = User::filter($filters)->simplePaginate();
return view('users.index', compact('users'));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.