connection = 'redis'; } /** * Execute the job. * * @return void */ public function handle() { //Get today's date $today = Carbon::now(); //If the date for a contract has expired, then purge it from the system $contracts = PublicContract::all(); //Check each contract to see if it has expired foreach($contracts as $contract) { //If the contract has expired, then delete the contract and all of it's items if($today->greaterThan($contract->date_expired)) { //Delete the contract PublicContract::where([ 'id' => $contract->id, ])->delete(); //Delete the items from the contract from the other table PublicContract::where([ 'contract_id' => $contract->id, ])->delete(); } } } }