1. Go to this page and download the library: Download patienceman/filtan 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/ */
patienceman / filtan example snippets
namespace App\Services\Filters;
use Patienceman\Filtan\QueryFilter;
class AirPlaneFilter extends QueryFilter {
/**
* public function query($query) {
* $this->builder->where('name', 'LIKE', '%' . . '%')
* }
*/
}
namespace App\Services\Filters;
use Patienceman\Filtan\QueryFilter;
class AirplaneFilter extends QueryFilter {
public function query(string $query){
$this->builder->where('name', 'LIKE', '%' . $query . '%');
}
}
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Patienceman\Filtan\Filterable;
class Airplane extends Model {
use HasFactory, Filterable;
}
namespace App\Http\Controllers\ApiControllers;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Services\Filters\CompanyFilter;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class AirplaneController extends Controller {
/**
* Display a listing of the resource.
*
* @return JsonResponse
*/
public function index(CompanyFilter $filter): JsonResponse {
$planes = Airplane::allPlanes()->filter($filter)->get();
return successResponse(
AirplaneResource::collection($planes),
AirplaneAlert::DISPLAY_MESSAGE
);
}
}
bash
php artisan make:cake BananaCake
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.