Add new command kemaskiniCawanganLelong
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user