1 | <?php |
||
9 | class MigrationCreator extends \Illuminate\Database\Migrations\MigrationCreator |
||
10 | { |
||
11 | /** |
||
12 | * Get the migration stub file. |
||
13 | * |
||
14 | * @param string $table |
||
15 | * @param bool $create |
||
16 | * @return string |
||
17 | */ |
||
18 | protected function getStub($table, $create) |
||
22 | |||
23 | /** |
||
24 | * Populate the place-holders in the migration stub. |
||
25 | * |
||
26 | * @param string $name |
||
27 | * @param string $stub |
||
28 | * @param string $table |
||
29 | * @return string |
||
30 | */ |
||
31 | protected function populateStub($name, $stub, $table) |
||
32 | { |
||
33 | $stub = str_replace('DummyClass', $this->getClassName($name), $stub); |
||
34 | |||
35 | // Here we will replace the table place-holders with the table specified by |
||
36 | // the developer, which is useful for quickly creating a tables creation |
||
37 | // or update migration from the console instead of typing it manually. |
||
38 | if (! is_null($table)) { |
||
39 | $stub = str_replace('DummyTable', $table, $stub); |
||
40 | |||
41 | $referencesTable = Str::plural(str_replace('_'.$this->getTranslationSuffix(), '', $table)); |
||
42 | |||
43 | $stub = str_replace('DummyReferencesTable', $referencesTable, $stub); |
||
44 | |||
45 | $forignKey = Str::singular(str_replace('_'.$this->getTranslationSuffix(), '', $table)).'_id'; |
||
46 | |||
47 | $stub = str_replace('DummyForeign', $forignKey, $stub); |
||
48 | } |
||
49 | |||
50 | return $stub; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Defines the default 'Translation' class suffix. |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | protected function getTranslationSuffix() |
||
62 | |||
63 | /** |
||
64 | * Get the class name of a migration name. |
||
65 | * |
||
66 | * @param string $name |
||
67 | * @return string |
||
68 | */ |
||
69 | protected function getClassName($name) |
||
73 | |||
74 | /** |
||
75 | * Get the full path to the migration. |
||
76 | * |
||
77 | * @param string $name |
||
78 | * @param string $path |
||
79 | * @return string |
||
80 | */ |
||
81 | protected function getPath($name, $path) |
||
85 | |||
86 | /** |
||
87 | * Fire the registered post create hooks. |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | protected function firePostCreateHooks() |
||
97 | |||
98 | /** |
||
99 | * Register a post migration create hook. |
||
100 | * |
||
101 | * @param \Closure $callback |
||
102 | * @return void |
||
103 | */ |
||
104 | public function afterCreate(Closure $callback) |
||
108 | |||
109 | /** |
||
110 | * Get the path to the stubs. |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | public function stubPath() |
||
118 | } |
||
119 |