Filter Relational

I have my InvoiceSearch.php file that has several relation attributes.

I did a search field that works fine but it doesn’t search if the attribute that I’m searching is a relation.

This is my search code:




if ($this->invoice_no) {

        	$query->andFilterWhere(['or',

        		['like','invoice_no',$this->invoice_no],

        		['like','invoiced_to',$this->invoice_no],

        		['like','invoice_date',$this->invoice_no],

        		['like','invoice_by',$this->invoice_no],

        		['like','invoice_total',$this->invoice_no],

        		['like','branch_id',$this->invoice_no],

        		['like','invoice_status',$this->invoice_no],

        		['like','fuel_percent',$this->invoice_no],

        		['like','from_dt',$this->invoice_no],

        		['like','to_dt',$this->invoice_no],

        		['like','last_sent',$this->invoice_no]

        	]);

        }



invoice_no is the id field and it’s the only field that works, the other ones is all relation.

I already added those attributes as safe as well.

Any clue?




if ($this->invoice_no) {

        	$query->andFilterWhere(['or',

        		['like','invoice_no',$this->invoice_no],

        		['like','invoiced_to',$this->invoice_no],

        		['like','invoice_date',$this->invoice_no],

        		['like','invoice_by',$this->invoice_no],

        		['like','invoice_total',$this->invoice_no],

        		['like','branch_id',$this->invoice_no],

        		['like','invoice_status',$this->invoice_no],

        		['like','fuel_percent',$this->invoice_no],

        		['like','from_dt',$this->invoice_no],

        		['like','to_dt',$this->invoice_no],

        		['like','last_sent',$this->invoice_no]

        	]);

        }




['like','invoiced_to',$this->invoice_no],

it should be


['like','invoiced_to',$this->invoice_to],

and if it is in relation read below.

stateSearch model and countryid is relation of tbl_country table.

im displaying countryname relative to its countryid, so in search i have to use below code.


$query->andFilterWhere(['like', 'tbl_country.countryName', $this->countrySort]);

regards,

webin