예제 #1
0
 /**
  * Manage media.
  *
  * @return void
  */
 protected function handleMediaFiles()
 {
     $this->comment("    Pruning media data...");
     $mediaOrphanLife = (int) Settings::get('epheMediaPrune', 0);
     if ($mediaOrphanLife) {
         $carbonLife = Carbon::now()->subDays($mediaOrphanLife);
         $files = FileStorage::whereOrphan()->where('last_uploaded_at', '<=', $carbonLife)->get();
         $affected = 0;
         foreach ($files as $file) {
             if ($file->hasFile()) {
                 ++$affected;
                 $file->deleteFile();
             }
         }
         $this->comment("      Pruned {$affected} file(s).");
     }
 }