with('stationType')->where('batch_type',$batch['type']) ->where('owner_id',$batch['owner_id']) ->first(); }); } function getStationType_toBeTask(Batch $batch): ?StationType{ $stationRuleBatch=$this->getByBatch($batch); if(!$stationRuleBatch)return null; return $stationRuleBatch['stationType']; } /** * @param Batch[] $batches * @return Collection */ function getBatches_canProcess(array $batches): Collection { $batches_toProcess=collect(); foreach ($batches as $batch){ $stationRuleBatch=$this->getByBatch($batch); if($stationRuleBatch) $batches_toProcess->push($batch); } return $batches_toProcess; } }