relations and foreign key

Ok , i have 3tables: user,casa,preco.

user has-many casa

casa belongs to user

casa has-many preco

preco belongs to casa

load model from casa controller i have


$uid = Yii::app()->user->name == ("admin") ? ">= 1" : "=" . Yii::app()->user->id;

        $model = Casa::model()->with('casas')->find('casas.propid' . $uid . ' And cod_casa=' . $id); 

only the owner or admin see her casa. Fine.

but i can’t get the casa->id in preco search() function to filter it and show only the preco of tat casa->id.

Should i use a parameter in a link, I’m tired and i can find a solution.

i’ve used Gii but right now i can’t see how i get a casa->id in the preco model as i get the user id in casa model.