Dear All,
I have a requirement where I want to find records with join from multiple tables and then I want to access property value via getter method
public function initialize() {
$this->belongsTo('state_id', 'States', 'state_id', array('alias' => 'States',
"foreignKey" => array("allowNulls" => FALSE, "message" => "{~Invalid %s|State~}"))
);
}
public function getStateName() {
//////// some customized logic
return strtoupper($this->statename." blah blah....");
}
$stations = Stations::query()
->columns(['States.state_name', 'station_name'])
->join('States')
->execute();
echo $stations[1]->state_name;
die;
so if State name is "Moscow" in database,then above code must print "MOSCOW blah blah...."
Note : Because I do not want to execute queries multiple times through chaining method (for statename) as I have to extract heavy data.