1 | <?php namespace Nwidart\DbExporter; |
||
3 | class DbExportHandler |
||
4 | { |
||
5 | /** |
||
6 | * @var DbMigrations |
||
7 | */ |
||
8 | protected $migrator; |
||
9 | |||
10 | /** |
||
11 | * @var DbSeeding |
||
12 | */ |
||
13 | protected $seeder; |
||
14 | |||
15 | /** |
||
16 | * Inject the DbMigrations class |
||
17 | * @param DbMigrations $DbMigrations |
||
18 | * @param DbSeeding $DbSeeding |
||
19 | */ |
||
20 | function __construct(DbMigrations $DbMigrations, DbSeeding $DbSeeding) |
||
|
|||
21 | { |
||
22 | $this->migrator = $DbMigrations; |
||
23 | $this->seeder = $DbSeeding; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Create migrations from the given DB |
||
28 | * @param String null $database |
||
29 | * @return $this |
||
30 | */ |
||
31 | public function migrate($database = null) |
||
32 | { |
||
33 | $this->migrator->convert($database)->write(); |
||
34 | |||
35 | return $this; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @param null $database |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function seed($database = null) |
||
43 | { |
||
44 | $this->seeder->convert($database)->write(); |
||
45 | |||
46 | return $this; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Helper function to generate the migration and the seed in one command |
||
51 | * @param null $database |
||
52 | * @return $this |
||
53 | */ |
||
54 | public function migrateAndSeed($database = null) |
||
55 | { |
||
56 | // Run the migrator generator |
||
57 | $this->migrator->convert($database)->write(); |
||
58 | |||
59 | // Run the seeder generator |
||
60 | $this->seeder->convert($database)->write(); |
||
61 | |||
62 | return $this; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Add tables to the ignore array |
||
67 | * @param $tables |
||
68 | * @return $this |
||
69 | */ |
||
70 | public function ignore($tables) |
||
71 | { |
||
72 | DbExporter::$ignore = array_merge(DbExporter::$ignore, (array)$tables); |
||
73 | |||
74 | return $this; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @return mixed |
||
79 | */ |
||
80 | public function getMigrationsFilePath() |
||
84 | |||
85 | public function uploadTo($remote) |
||
86 | { |
||
87 | DbExporter::$remote = $remote; |
||
88 | |||
89 | return $this; |
||
91 | |||
92 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.