0

I'm getting data through the 2 table in form of array (like address) and one to find particular pin code in another table here is the 2 model that i'm using to find and match the result and perform the tax function eg. if one table have the array a.b,c,d the second table have the value to find the value store in it eg. if a = 1 if b=2 like that here is my code idea trying to implement but no success

    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;
}
Mohammad
  • 652
  • 1
  • 7
  • 18

1 Answers1

0

try this i hope help you

$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']);
Mohammad
  • 652
  • 1
  • 7
  • 18
  • no out put in the value of tax, eg the source have the sender address(s_address) abc,def,ghi and receiver address(d_address) xyz,fgh,dfg the toltax table have the 3 value sender variable (def) and receiver variable (dfg) then automatically the tax value will be 10 the 3rd variable the post is charge according to the main centre of sender and receivers office the office databases have the large amount of charges according to it when I run your code the application API halt and don't proceed further show no error in log – Aksoom Hussain Mar 04 '19 at 12:26