Skip to content

Commit 1083255

Browse files
committed
Update README
1 parent 4d45add commit 1083255

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ when you need more time in others features and simple filters.
88

99
First, implement the `Trait` on your model, like this:
1010

11-
```
12-
use LeoCarmo\Traits\FilterableModel;
11+
```php
12+
use LeoCarmo\ModelFilter\Traits\FilterableModel;
1313
use Illuminate\Database\Eloquent\Model;
1414

1515
class YourModel extends Model
@@ -24,7 +24,7 @@ At now, you can use all available methods, we will pass thought later.
2424
But after this, some required attributes are required to use all features from this filter.
2525
---
2626
First attribute is `filterable`, with these you can set all allowed filters and the operator for this attribute. Like this:
27-
```
27+
```php
2828
class YourModel extends Model
2929
{
3030

@@ -45,7 +45,7 @@ The second is `filterable_select`, with these you set columns to select on query
4545
This is very important for fast queries. If this attribute is not present on model, all
4646
columns will be returned (`*` operator).
4747

48-
```
48+
```php
4949
class YourModel extends Model
5050
{
5151

@@ -59,7 +59,7 @@ class YourModel extends Model
5959
```
6060

6161
Now, all required configurations are set. You can start all your filters like this:
62-
```
62+
```php
6363
class YourController
6464
{
6565

@@ -94,7 +94,7 @@ This method will push new columns to the select query.
9494
---
9595
Example: on your model you defined `id` and `name`, but in a specific request you want to show the `age`, you can use this method.
9696

97-
```
97+
```php
9898
$model->pushFilterableSelect('age');
9999
// OR
100100
$model->pushFilterableSelect(['age', 'created_at']);
@@ -106,7 +106,7 @@ With this, you can push new columns to allowed filter or change the operator for
106106

107107
---
108108
If you push a column that was defined on model with the attribute `filterable` and an operator, the original value will be override with the new operator.
109-
```
109+
```php
110110
// this first example will not overide the original column if the default value has an operator seted, but will push to the allowed filters if was not defined
111111
$model->pushFilterable('age');
112112

@@ -118,7 +118,7 @@ $model->pushFilterable(['age' => '>']);
118118
#### changeDefaultOperator()
119119

120120
The default operator is `=` when no operator was defined on model. If you want, you can change this:
121-
```
121+
```php
122122
$model->changeDefaultOperator('LIKE');
123123
```
124124

0 commit comments

Comments
 (0)