我正在通过数组(如地址)形式的2表获取数据,并在另一个表中查找特定的密码,这是我用来查找和匹配结果并执行税收的2模型功能例如如果一个表具有数组a.b,c,d,则第二个表具有在其中查找值存储的值。如果a = 1如果b = 2这样,这是我的代码想法,试图实现但没有成功
try
{
$toltax = toltax::wheresource('LIKE','%'.$s_address.'%')->get();
$tsource = $toltax->source;
$tdestination = $toltax->destination;
if(!empty($toltax = toltax::where($s_address, 'LIKE' ,"%$tsource%")
->where($d_address,'LIKE',"%$tdestination%")
->get('tax')
)
){
Log::info("toll tax".$toltax->tax);
$Tax = $Tax + $toltax->tax;
}
}catch(ModelNotFoundException $e) {
return false;
}
答案 0 :(得分:0)
尝试这个,希望对您有帮助
$tax = DB::table('toltax as latest')
->whereSource('LIKE','%'.$s_address.'%')
->whereNotExists(function ($query) {
$query->select(DB::raw(1))
->from('toltax')
->whereRaw('source LIKE latest.source')
->whereRaw('destination LIKE latest.destination');
})
->get(['tax']);