Filter Not Found
Closed this issue · 2 comments
TNDJX commented
So i am using this Eloquent Builder
https://github.com/mohammad-fouladgar/eloquent-builder
And i am trying to do some filtering, but whenever i try to define filter, i get error:
i am just copying and pasting the code that is already there on github
Here is my ModelFilter.php:
```php
<?php
namespace App\EloquentFilters\Listings;
use Fouladgar\EloquentBuilder\Support\Foundation\Contracts\Filter;
use Illuminate\Database\Eloquent\Builder;
class ModelFilter extends Filter
{
/**
* Apply gender condition on query builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @param mixed $value
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function apply(Builder $builder, $value): Builder
{
return $builder->where('model', $value);
}
}
Here is my controller (name is test, since i just want to test this for now):
```php
<?php
namespace App\Http\Controllers;
use App\Model\Listing\Listing;
use EloquentBuilder;
use Illuminate\Http\Request;
class test extends Controller
{
public function index(Request $request)
{
$users = EloquentBuilder::to(
Listing::class,
$request->filter
);
// Use the API Resources for api response or return result within a view.
return response()->json(['data' => $users->get()], 200);
}
}
And my route is like this:
Route::get('/test', 'test@index')->name('test');
So basicly if i just go on route /test , i will get all the listings, thats fine, but if i enter route like this /test?filter[model]=48, i will get the error:
Not found the filter: ModelFilter
mohammad-fouladgar commented
mohammad-fouladgar commented
I close this issue, But you can reopen if you need.