99 public function up (): void
1010 {
1111 $ tableNames = config ('taxonomy.table_names ' );
12+ $ tableNames = array_merge ([
13+ 'taxonomies ' => 'taxonomies ' ,
14+ 'taxonomables ' => 'taxonomables ' ,
15+ ], (array ) config ('taxonomy.table_names ' , []));
16+
1217 $ morphType = config ('taxonomy.morph_type ' , 'uuid ' );
1318
14- Schema::create ($ tableNames ['taxonomies ' ], function (Blueprint $ table ) {
19+ Schema::create ($ tableNames ['taxonomies ' ], function (Blueprint $ table ) use ( $ tableNames ) {
1520 $ table ->id ();
1621 $ table ->string ('name ' );
1722 $ table ->string ('slug ' );
1823 $ table ->string ('type ' )->index ();
1924 $ table ->text ('description ' )->nullable ();
20- $ table ->foreignId ('parent_id ' )->nullable ()->constrained ('taxonomies ' );
25+ $ table ->foreignId ('parent_id ' )->nullable ()->constrained ($ tableNames [ 'taxonomies ' ] );
2126 $ table ->integer ('sort_order ' )->default (0 );
2227 $ table ->unsignedInteger ('lft ' )->nullable ()->index ();
2328 $ table ->unsignedInteger ('rgt ' )->nullable ()->index ();
@@ -32,9 +37,9 @@ public function up(): void
3237 $ table ->index (['type ' , 'lft ' , 'rgt ' ]);
3338 });
3439
35- Schema::create ($ tableNames ['taxonomables ' ], function (Blueprint $ table ) use ($ morphType ) {
40+ Schema::create ($ tableNames ['taxonomables ' ], function (Blueprint $ table ) use ($ morphType, $ tableNames ) {
3641 $ table ->id ();
37- $ table ->foreignId ('taxonomy_id ' )->constrained ()->cascadeOnDelete ();
42+ $ table ->foreignId ('taxonomy_id ' )->constrained ($ tableNames [ ' taxonomies ' ] )->cascadeOnDelete ();
3843
3944 $ name = 'taxonomable ' ;
4045 switch ($ morphType ) {
@@ -55,6 +60,10 @@ public function up(): void
5560 public function down (): void
5661 {
5762 $ tableNames = config ('taxonomy.table_names ' );
63+ $ tableNames = array_merge ([
64+ 'taxonomies ' => 'taxonomies ' ,
65+ 'taxonomables ' => 'taxonomables ' ,
66+ ], (array ) config ('taxonomy.table_names ' , []));
5867
5968 Schema::dropIfExists ($ tableNames ['taxonomables ' ]);
6069 Schema::dropIfExists ($ tableNames ['taxonomies ' ]);
0 commit comments