Skip to content

Commit 502f774

Browse files
committed
Add CleanTemp command to remove temporary files from storage
1 parent 80ec74d commit 502f774

File tree

5 files changed

+51
-2
lines changed

5 files changed

+51
-2
lines changed

app/Console/Commands/CleanTemp.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Support\Facades\File;
7+
8+
class CleanTemp extends Command
9+
{
10+
/**
11+
* The name and signature of the console command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'simpede:clean-temp';
16+
17+
/**
18+
* The console command description.
19+
*
20+
* @var string
21+
*/
22+
protected $description = 'Clean temporary files';
23+
24+
/**
25+
* Execute the console command.
26+
*/
27+
public function handle()
28+
{
29+
30+
$folderPath = storage_path('app/filepond/temp');
31+
32+
// Hapus semua isi folder (file dan subfolder)
33+
File::deleteDirectory($folderPath);
34+
35+
$this->info("Temporary files in '{$folderPath}' cleaned successfully.");
36+
}
37+
}

app/Console/Commands/ClearActionEventsLogs.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ public function handle()
2929
DB::table('action_events')
3030
->where('status', 'finished')
3131
->delete();
32+
33+
$this->info('Finished action events logs cleared successfully.');
3234
}
3335
}

app/Console/Commands/SendReminder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ public function handle()
3131
foreach ($reminders as $reminder) {
3232
Helper::sendReminder($reminder);
3333
}
34+
35+
$this->info('Scheduled reminders sent successfully.');
3436
}
3537
}

app/Console/Commands/SimpedeBackup.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@ public function handle()
2828
{
2929
$action = $this->argument('action');
3030

31+
$backupDisks = config('backup.backup.destination.disks', []);
32+
3133
if ($action === 'create') {
3234
$this->call('action-events:clear');
3335
$this->call('backup:run');
3436
$this->call('backup:clean');
35-
Storage::disk('google')->getAdapter()->emptyTrash([]);
37+
foreach ($backupDisks as $disk) {
38+
Storage::disk($disk)->getAdapter()->emptyTrash([]);
39+
}
3640
} elseif ($action === 'clean') {
3741
$this->call('backup:clean');
38-
Storage::disk('google')->getAdapter()->emptyTrash([]);
42+
foreach ($backupDisks as $disk) {
43+
Storage::disk($disk)->getAdapter()->emptyTrash([]);
44+
}
3945
} else {
4046
$this->error('Invalid action. Use "create" or "clean".');
4147
}

app/Console/Commands/SimpedeCache.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,7 @@ public function handle()
8585
User::cache()->updateAll();
8686
UserEksternal::cache()->updateAll();
8787
WhatsappGroup::cache()->updateAll();
88+
89+
$this->info('All cache updated successfully.');
8890
}
8991
}

0 commit comments

Comments
 (0)