So , I have wrote a Common Helper function , which when called should give me a variable set with either 1 or 0 , and then proceed to the rest of code.
function getPfWages($earning_id,$payrunid){
$name = Earning::select('consider_epf_contribution')->where('id',$earning_id)->where('consider_epf_contribution','1')->first();
dump($name);
if($name=='1'){
$TotalAmount = PayrunsEmployeeDetails::where('earning_id',$earning_id)->where('payrun_id',$payrunid)->sum('payamount');
return $TotalAmount;
}
else{
return 0;
}
}
The dump function shows this output :
But , when I try to access the $name array by an offset 'consider_epf_contribution' , it throws an error of "Trying to access array offset on value of type null". I cant figure out why this is happening.
I have also tried "toArray()" , "get()" and "sum()" but same errors are thrown while accessing the array. This is my first ever Laravel project.
-TIA ~regards
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire