Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // src/Model/Entity/Article.php
- namespace App\Model\Entity;
- use Cake\ORM\Entity;
- class Cat extends Entity
- {
- protected $_accessible = [
- '*' => true,
- ];
- }
- <?php
- // src/Model/Entity/Article.php
- namespace App\Model\Entity;
- use Cake\ORM\Entity;
- class Dog extends Entity
- {
- protected $_accessible = [
- '*' => true,
- ];
- }
- <?php
- // src/Model/Entity/Article.php
- namespace App\Model\Entity;
- use Cake\ORM\Entity;
- class Dog extends Entity
- {
- protected $_accessible = [
- '*' => true,
- ];
- }
- <?php
- namespace App\Model\Table;
- use App\Model\Entity\Cat;
- use Cake\ORM\Table;
- use Cake\ORM\Query;
- use Cake\ORM\RulesChecker;
- use Cake\ORM\Validation\Validator;
- class CatsTable extends Table
- {
- public function initialize(array $config)
- {
- $this->addBehavior('Timestamp');
- $this->hasMany('DogsCats',[
- 'foreignKey'=>'cat_id',
- ]);
- }
- }
- <?php
- namespace App\Model\Table;
- use App\Model\Entity\Dog;
- use Cake\ORM\Table;
- use Cake\ORM\Query;
- use Cake\ORM\RulesChecker;
- use Cake\ORM\Validation\Validator;
- class DogsTable extends Table
- {
- public function initialize(array $config)
- {
- $this->addBehavior('Timestamp');
- $this->hasMany('DogsCats',[
- 'foreignKey'=>'dog_id'
- ]);
- }
- }
- <?php
- namespace App\Model\Table;
- use App\Model\Entity\DogsCat;
- use Cake\ORM\Table;
- use Cake\ORM\Query;
- use Cake\ORM\RulesChecker;
- use Cake\ORM\Validation\Validator;
- class DogsCatsTable extends Table
- {
- public function initialize(array $config)
- {
- $this->addBehavior('Timestamp');
- $this->belongsTo('Dogs', [
- 'foreignKey' => 'id',
- 'joinType'=>'INNER'
- ]);
- $this->belongsTo('Cats', [
- 'foreignKey' => 'id',
- 'joinType'=>'INNER'
- ]);
- }
- }
- <?php
- namespace App\Controller;
- use App\Controller\AppController;
- class DogsCatsController extends AppController
- {
- public function initialize()
- {
- parent::initialize();
- $this->loadComponent('Paginator');
- $this->loadComponent('Flash');
- }
- public function index()
- {
- $result = $this->DogsCats->find('all')->contain(['Dogs','Cats']);
- $this->set('farms',$result);
- }
- public function add()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement