//$locations = User::find_one_by_id($id)->related('locations')->get(); $locations = User::find()->related('locations')->where('user_id', 3)->get_one(); //$locations = User::query()->related('locations')->where('user_id', 3); //$locations = $data['user']->related('locations')->get(); \Log::error("user locations: ".print_r($locations,true));
Call to undefined method Model\User::related()
protected static $_many_many = array( 'locations' => array( 'key_from' => 'id', 'key_through_from' => 'user_id', 'table_through' => 'users_locations', 'key_through_to' => 'location_id', 'model_to' => 'Location', 'key_to' => 'id', 'cascade_save' => true, 'cascade_delete' => false, ) );
It looks like you're new here. If you want to get involved, click one of these buttons!