Skip to content
Permalink
Browse files

Change Task Sheduler

  • Loading branch information...
Insax committed Oct 18, 2017
1 parent 11c14d7 commit a933b155a7526c6c2cd443e1893ef9137ea98fc8
Showing with 19 additions and 14 deletions.
  1. +16 −14 app/Console/Kernel.php
  2. +3 −0 app/Http/Controllers/StaticsController.php
@@ -26,22 +26,24 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
$data = DB::table('data')->where('created_at', '<', '(NOW() - INTERVAL 1 DAY)')->value('guid');
if ($data) {
foreach ($data as $e) {
Storage::delete($e);
Storage::delete('public/'.$e.'.mp4');
DB::table('data')->where('guid', '=', $e)->delete();
}
}
})->daily();
$schedule->call(function () {
$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);
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'))
Storage::delete('public/'.$e->guid.'.mp4');
DB::table('data')->where('guid', '=', $e)->delete();
}
}
})->daily();
}
/**
* Register the Closure based commands for the application.
*
* Register the Closure based commands for the application
* @return void
*/
protected function commands()
@@ -4,6 +4,9 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use DateTime;
class StaticsController extends Controller
{

0 comments on commit a933b15

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