Skip to content
Advertisement

Want to compare two columns of different table in laravel

I want to compare two columns from two different tables, I have column called “Features” in Model Attrition_correlators and another “Topcorrelators” in Membersdetail. Since I am new to laravel not sure how I can get the value and compare both values. Here is my code:

Controller.php

JavaScript

JavaScript

I want to compare the data which I am getting $row with the values in “features” if they match Want to get the value of correlation which is in Model “Attrition_correlators” under . Can anyone help me out in this! Thanks in Advance Below is the error I am getting enter image description here

Advertisement

Answer

It’s because you get a collection of Attrition_correlation_list. In this case you need to iterate over it to get properties:

JavaScript

You also need to edit your controller like below. Because you passed null value in $Attrition_correlation_list

JavaScript
Advertisement