Skip to content

Commit 7b58837

Browse files
author
Nicolas Boisvert
committed
Updated README for new filter table feature
1 parent 5cc67ee commit 7b58837

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,31 @@ class ProdImport extends Import
6767
}
6868
```
6969

70+
#### Table filter
71+
72+
Sometimes you may need to filter tables to get only certain items like, for instance, only the last 6 months of work. This may be achieved by adding table filters.
73+
74+
Let say I have a table called `orders` where I only need the last 6 months items.
75+
76+
```
77+
namespace Foo\Console\Commands;
78+
79+
use Nicklayb\LaravelDbImport\Import;
80+
81+
class ProdImport extends Import
82+
{
83+
protected $sourceConnection = 'source';
84+
protected $destinationConnection = 'mysql';
85+
86+
public function filterUsers($query)
87+
{
88+
return $query->where('created_at', '>', Carbon::now()->subMonths(6));
89+
}
90+
}
91+
```
92+
93+
You will receive the base query in parameter and you should return the modified query.
94+
7095
### Registering import
7196

7297
Since you published the vendor's file, you'll notice that you have a brand new `dbimport.php` in your config file. In this file you will register all of you import classes you want to use.

0 commit comments

Comments
 (0)