PHPackages                             mhamzeh/presenter-filter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mhamzeh/presenter-filter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mhamzeh/presenter-filter
========================

0.1(5y ago)1120MITPHPPHP ^7.3

Since Dec 12Pushed 5y ago2 watchersCompare

[ Source](https://github.com/mohammadHamzeh/laravel-presenter-filter)[ Packagist](https://packagist.org/packages/mhamzeh/presenter-filter)[ Docs](https://github.com/mohammadHamzeh/laravel-presenter-filter)[ RSS](/packages/mhamzeh-presenter-filter/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Presenter-Filter Laravel
------------------------

[](#presenter-filter-laravel)

Introduction
------------

[](#introduction)

The package allows you to create two types of classes: filter class and presenter class

### Filter

[](#filter)

This package allows you to easily handle database filtering through query strings.

example: /users?status=1&amp;name='kami'

### Presenter

[](#presenter)

Sometimes our models get too fat, and that can make our development a lot harder. In this case, we use a second class that has the same function as the model and is used as a second model, and the Harrow method can be included in this class.

Installation
------------

[](#installation)

you can install the package via composer:

```
composer require mhamzeh/presenter-filter
```

You Must by publishing configuration by issuing following artisan command `php artisan vendor:publish`.

Usage
-----

[](#usage)

You have access to two commands and you can use them to create your own filter and presenter classes

#### make:filter command

[](#makefilter-command)

You can use the following command to create a new filter.

`php artisan make:filter UserFilter`

This will create a new filter in the app/Filters directory.

options:

1-You can add the model to the command

‍‍‍‍‍‍`php artisan make:filter UserFilter --model=User`

Used by default Models folder If you have saved models elsewhere, change the config Modules of this folder

#### make:presenter Command

[](#makepresenter-command)

You can use the following command to create a new Presenter

`php artisan make:presenter UserPresenter`

options:

1- You can add the model to command

`php artisan make:presenter UserPresenter --model=User`

Example With Filter
-------------------

[](#example-with-filter)

Let's say you want to use filterable on User model. You will have to create the filter class App/Filters/PostFilter.php (`php artisan make:filter PostFilter --model=Post`)

If you use the --model option, filterable will be added directly to the model

```
