I use lithium with mongodb, and I would like to learn with my models below how I can get user data from Posts :: find ('all'); request?
Should I fulfill two requests?
Thank you for your help!
<?php namespace app\models; class Posts extends \lithium\data\Model { protected $_schema = array( '_id' => array('type' => 'id'), 'name' => array('type' => 'string', 'null' => false), 'description' => array('type' => 'string', 'null' => false), 'created' => array('type' => 'datetime'), 'updated' => array('type' => 'datetime'), 'user_id' => array('type' => 'integer') ); protected $_meta = array( 'key' => '_id', ); public $belongsTo = array('Users'); } ?> <?php namespace app\models; class Users extends \lithium\data\Model { public $hasMany = array('Posts'); public $validates = array( 'name' => 'Please enter a name', ); protected $_schema = array( '_id' => array('type' => 'id'), 'name' => array('type' => 'string', 'null' => false), 'slug' => array('type' => 'string', 'null' => false), 'created' => array('type' => 'datetime', 'null' => false), ); } ?>
source share