4
4
5
5
use Illuminate \Console \Command ;
6
6
use Illuminate \Support \Facades \File ;
7
+ use Illuminate \Support \Facades \Artisan ;
7
8
8
9
class InstallPackageCommand extends Command
9
10
{
@@ -29,48 +30,55 @@ public function handle()
29
30
$ this ->info ("config published " );
30
31
}
31
32
33
+ if (!empty (File::glob (database_path ('migrations\*_create_attachmentables_tables.php ' )))) {
32
34
33
- // //migration
34
- // if (File::exists(database_path("migrations/"))) {
35
- // $confirm = $this->confirm("migration file already exist. Do you want to overwrite?");
36
- // if ($confirm) {
37
- // $this->publishMigration();
38
- // $this->info("migration overwrite finished");
39
- // } else {
40
- // $this->info("skipped migration publish");
41
- // }
42
- // } else {
43
- // $this->publishMigration();
44
- // $this->info("migration published");
45
- // }
46
-
47
- $ this ->publishMigration ();
48
-
49
- // $this->call('migrate');
50
-
51
-
35
+ $ list = File::glob (database_path ('migrations\*_create_attachmentables_tables.php ' ));
36
+ collect ($ list )->each (function ($ item ) {
37
+ File::delete ($ item );
38
+ });
52
39
40
+ $ this ->publishMigration ();
41
+ } else {
42
+ $ this ->publishMigration ();
43
+ }
53
44
54
45
$ this ->info ("Attachmentable Successfully Installed. \n" );
55
46
$ this ->info ("\t\tStar me on Github " );
56
47
}
57
48
58
- private function publishConfig ()
49
+ private function publishMigration ()
59
50
{
60
51
$ this ->call ('vendor:publish ' , [
61
52
'--provider ' => "Laravelir\Attachmentable\Providers\AttachmentableServiceProvider " ,
62
- '--tag ' => 'attachmentable-config ' ,
53
+ '--tag ' => 'attachmentable-migrations ' ,
63
54
'--force ' => true
64
55
]);
65
56
}
66
57
67
-
68
- private function publishMigration ()
58
+ private function publishConfig ()
69
59
{
70
60
$ this ->call ('vendor:publish ' , [
71
61
'--provider ' => "Laravelir\Attachmentable\Providers\AttachmentableServiceProvider " ,
72
- '--tag ' => 'attachmentable-migrations ' ,
62
+ '--tag ' => 'attachmentable-config ' ,
73
63
'--force ' => true
74
64
]);
75
65
}
66
+
67
+ // protected function publishMigrations()
68
+ // {
69
+ // if (empty(File::glob(database_path('migrations/*_create_attachmentables_tables.php')))) {
70
+
71
+ // $this->publishes([
72
+ // __DIR__ . '/../../database/migrations/create_attachmentables_table.stub.php' => database_path() . "/migrations//" . date('Y_m_d_His', time()) . "_create_attachmentables_tables.php",
73
+ // ], 'attachmentable-migrations');
74
+ // } else {
75
+ // $list = File::glob(database_path('migrations\*_create_attachmentables_tables.php'));
76
+ // collect($list)->each(function ($item) {
77
+ // File::delete($item);
78
+ // dd("delete");
79
+ // });
80
+
81
+ // Artisan::call('php artisan vendor:publish --provider=Laravelir\\Attachmentable\\Providers\\AttachmentableServiceProvider --tag=attachmentable-migrations --force');
82
+ // }
83
+ // }
76
84
}
0 commit comments