Skip to content
Permalink
Browse files

Fix Auto Scheduler

  • Loading branch information...
Insax committed Feb 26, 2018
1 parent 77105e0 commit 0a476a4a01b633fe582e55ca675b675c809ef6c2
Showing with 9 additions and 6 deletions.
  1. +9 −6 app/Console/Kernel.php
@@ -6,6 +6,7 @@
use Illuminate\Support\Facades\Storage;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use DateTime;
class Kernel extends ConsoleKernel
{
@@ -27,17 +28,19 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
$date = new DateTime;
$date = new DateTime();
$date->modify('-1 day');
$formatted_date = $date->format('Y-m-d H:i:s');
$data = DB::table('data')->where('created_at', '<', $formatted_date)->get(); Storage::delete($e);
$data = DB::table('data')->where('created_at', '<', $formatted_date)->get();
if ($data) {
foreach ($data as $e) {
if(file_exists(storage_path().$e->guid))
Storage::delete($e->guid);
if(file_exists(storage_path().'public/'.$e->guid.'.mp4'))
if(file_exists(storage_path().'/app/'.$e->guid));
Storage::delete($e->guid);
if(file_exists(storage_path().'/app/public/'.$e->guid.'.mp4'))
Storage::delete('public/'.$e->guid.'.mp4');
DB::table('data')->where('guid', '=', $e)->delete();
DB::table('data')->where('guid', '=', $e->guid)->delete();
}
}
})->daily();

0 comments on commit 0a476a4

Please sign in to comment.
You can’t perform that action at this time.