1. Go to this page and download the library: Download andrewdyer/filtering 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/ */
namespace App\Filters;
use Anddye\Filtering\Filter;
use Illuminate\Database\Eloquent\Builder;
class AccessFilter extends Filter
{
public function filter(Builder $builder, $value): Builder
{
return $builder->where('free', $value);
}
}
namespace App\Filterers;
use Anddye\Filtering\Filterer;
use App\Filters\AccessFilter;
class CourseFilterer extends Filterer
{
protected array $filters = [
'access' => AccessFilter::class,
];
}
namespace App\Models;
use App\Filterers\CourseFilterer;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
class Course extends Model
{
public function scopeFilter(Builder $builder, array $queryParams): Builder
{
return (new CourseFilterer())->filter($builder, $queryParams);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.