Kontroler
public function action_index() { $items = ORM::factory('item') ->with('combination') ->with('image') ->find_all(); $this->template->content = View::factory('all')->set('items', $items); }
Model Item
class Model_Item extends ORM { 'model' => 'combination', 'foreign_key' => 'combination_id'), 'model' => 'image', 'foreign_key' => 'image_id')); }
Model Image
class Model_Image extends ORM { }
Model Combination
class Model_Combination extends ORM { }
i widok
<div class="items"> <?php foreach($items as $post):?> <div class="pictures"><a class="items"><img src="<?php echo url::base().'media/pictures/'.$post->image->url ?>" border="1"></a></div> <div class="tooltip"> <img src="<?php echo url::base().'media/pictures/'.$post->image->url ?>" style="float:left;margin:0px 0px 0px 0px" /> <table style="margin:0"> <tr><td class="label">Kombinacja:</td><td><?php echo $post->combination->id_one .' + '. $post->combination->id_two ?></td></tr> </table> </div>
w widoku
$post->combination->id_one
jak i
$post->combination->id_two
zawierają różne id które teraz mi się wyświetlają jako cyfry, problem mój polega na tym że chciałbym aby te id_one i id_two zostało zastąpione przez odpowiedni $post->name, jak to najlepiej wykonać?
Pozdrawiam