Skip to content

Commit 0a88cb7

Browse files
authored
Merge pull request #15 from arthurpar06/filamentSystem
Add new system
2 parents 2befeda + 2f892ab commit 0a88cb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1294
-1932
lines changed

app/Database/seeds/ShieldSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function run(): void
1818
static::makeRolesWithPermissions($rolesWithPermissions);
1919
static::makeDirectPermissions($directPermissions);
2020

21-
$this->command->info('Shield Seeding Completed.');
21+
$this->command?->info('Shield Seeding Completed.');
2222
}
2323

2424
protected static function makeRolesWithPermissions(string $rolesWithPermissions): void

app/Database/seeds/base.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
#
22
# Initial minimal data required. You probably don't want to modify or erase any of this here
33
#
4-
5-
roles:
6-
id_column: id
7-
ignore_if_exists: true
8-
data:
9-
- id: 1
10-
name: admin
11-
display_name: Administrators
12-
read_only: true
13-
disable_activity_checks: true
14-
154
ranks:
165
id_column: id
176
ignore_if_exists: true

app/Filament/Pages/Maintenance.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace App\Filament\Pages;
44

55
use App\Repositories\KvpRepository;
6+
use App\Services\Installer\InstallerService;
7+
use App\Services\Installer\MigrationService;
68
use App\Services\Installer\SeederService;
79
use App\Services\VersionService;
810
use App\Support\Utils;
@@ -173,4 +175,47 @@ public function optimizeApp(): Action
173175
->send();
174176
});
175177
}
178+
179+
public function update(): Action
180+
{
181+
return Action::make('update')
182+
->icon('heroicon-o-arrow-path')
183+
->color('success')
184+
->label('Update App')
185+
->visible(fn (): bool => app(InstallerService::class)->isUpgradePending())
186+
->action(function () {
187+
Log::info('Update: run_migrations');
188+
189+
$migrationSvc = app(MigrationService::class);
190+
$seederSvc = app(SeederService::class);
191+
192+
$migrationsPending = $migrationSvc->migrationsAvailable();
193+
$dataMigrationsPending = $migrationSvc->dataMigrationsAvailable();
194+
195+
if (count($migrationsPending) === 0 && count($dataMigrationsPending) === 0) {
196+
$seederSvc->syncAllSeeds();
197+
Notification::make()
198+
->title('Application updated successfully')
199+
->body('See logs for details')
200+
->success()
201+
->send();
202+
return;
203+
}
204+
205+
if (count($migrationsPending) !== 0) {
206+
$migrationSvc->runAllMigrations();
207+
}
208+
$seederSvc->syncAllSeeds();
209+
210+
if (count($dataMigrationsPending) !== 0) {
211+
$migrationSvc->runAllDataMigrations();
212+
}
213+
214+
Notification::make()
215+
->title('Application updated successfully')
216+
->body('See logs for details')
217+
->success()
218+
->send();
219+
});
220+
}
176221
}

0 commit comments

Comments
 (0)