Files
lelong/app/Console/Commands/kemaskiniCawanganLelong.php
T
ismailmasseran e29a5891c8 Bugfix/list clickup issue (#5)
Reviewed-on: #5
Co-authored-by: ISMAIL MASSERAN <ismail@koppkb.com>
Co-committed-by: ISMAIL MASSERAN <ismail@koppkb.com>
2026-10-19 13:30:36 +08:00

55 lines
1.2 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\CawanganLelong;
use App\Models\Lelong;
use App\Models\LelongBid;
use Illuminate\Console\Command;
class kemaskiniCawanganLelong extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'kemaskini:cawangan-lelong';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Kemaskini cawangan lelong, hapus bila surat sudah ditebus';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$lelong = Lelong::with('cawangan')->select('id')->get();
foreach ($lelong as $lel) {
foreach ($lel->cawangan as $caw) {
$lelong_bid = LelongBid::where('kodcaw', $caw->caw_code)->where('lelong_id', $lel->id)->first();
if ($lelong_bid == null) {
CawanganLelong::where('caw_id', $caw->id)->where('lelong_id', $lel->id)->delete();
}
}
}
}
}