Files
lelong/app/Console/Commands/kemaskiniCawanganLelong.php
T
2023-02-06 13:07:26 +08:00

58 lines
1.3 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();
}
}
}
}
}