File: /home/u435929562/domains/butanking.com/public_html/app/Http/Controllers/CronController.php
<?php
namespace App\Http\Controllers;
use App\Models\Draw;
use App\Models\PriceList;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use DateInterval;
use DateTime;
use Exception;
use FurtherInformationTable;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\DB;
class CronController extends Controller
{
public function newData()
{
$today = Carbon::today();
Draw::increment('draw_number');
$draws = Draw::get();
foreach ($draws as $d) {
$price = new PriceList();
$price->draw_id = $d->id;
$price->draw_number = $d->draw_number;
$price->draw_date = $today;
$price->draw_time = $d->draw_time;
$price->save();
}
return true;
}
public function fakeData()
{
$from = date('2021-11-01');
$to = date('2021-12-15');
$draws = Draw::get();
$begin = new DateTime("2022-01-01");
$end = new DateTime("2022-04-19");
for ($i = $begin; $i <= $end; $i->modify('+1 day')) {
$today = $i->format("Y-m-d") . "<br/>";
foreach ($draws as $d) {
$random_no = rand(0, 999);
$price = new PriceList();
$price->draw_id = $d->id;
$price->draw_number = $random_no;
$price->draw_date = $today;
$price->draw_time = $d->draw_time;
$price->first_price = rand(100, 999);
$price->save();
}
}
return true;
}
}