File: /home/imensosw/www/mpl.imenso.co/app/Console/Kernel.php
<?php
namespace App\Console;
use App\Events\RadioShowEnded;
use App\Events\RadioShowUpdated;
use App\Models\ARCampaign;
use App\Models\RadioShow;
use App\Models\ReservedTicket;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
foreach (ReservedTicket::all() as $reserved_ticket) {
$now = \Carbon\Carbon::now();
if ($reserved_ticket->created_at < $now->subHour()) {
$reserved_ticket->order->setExpired();
$reserved_ticket->remove();
}
}
})->everyMinute();
$schedule->call(function () {
$show = RadioShow::currentShow();
if ($show == null) {
event(new RadioShowEnded());
} else {
event(new RadioShowUpdated($show));
}
})->everyThirtyMinutes();
// $schedule->call(function () {
// try {
// $vuforia = new Vuforia();
// $list = $vuforia->listMarkers();
// foreach (json_decode($list)->results as $tid) {
// $campaign = ARCampaign::where('target_id', $tid)->first();
// if (! $campaign) {
// $vuforia->removeMarker($tid);
// }
// }
// $files = glob(public_path('images/qrcodes/*.*'));
// foreach ($files as $file) {
// $fileArr = explode('-', basename($file));
// $marker_id = $fileArr[0].'-'.$fileArr[1];
// $campaign = ARCampaign::where('marker_id', $marker_id)->first();
// if (! $campaign) {
// $markers = glob(public_path('images/qrcodes/'.$marker_id.'*.*'));
// foreach ($markers as $marker) {
// unlink($marker);
// }
// }
// }
// } catch (\Exception $e) {
// \Log::error($e->getMessage());
// }
// })->daily();
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}