1. Go to this page and download the library: Download jeidison/model-filtrable 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/ */
jeidison / model-filtrable example snippets
...
use Jeidison\Filtrable\Filtrable;
class Professional extends Model
{
use Filtrable;
...
protected $fillable = [
//All fields filtrable;
];
...
public function places()
{
return $this->belongsToMany(Place::class, 'prof_place', 'id_prof', 'id_place');
}
public function specialties()
{
return $this->belongsToMany(Specialty::class, 'prof_spec', 'id_prof', 'id_spec');
}
}
...
use App\Models\Professional;
class ProfessionalService implements IProfessionalService
{
public function filter()
{
return Professional::filter(request()->all())->get();
// or
return Professional::filter(['field_one' => 'value1'])->get();
}
}