junction() public méthode

Sets the table instance for the junction relation. If no arguments are passed, the current configured table instance is returned
public junction ( string | Table | null $table = null ) : Table
$table string | Cake\ORM\Table | null Name or instance for the join table
Résultat Cake\ORM\Table
Exemple #1
0
 /**
  * Tests that custom foreignKeys are properly trasmitted to involved associations
  * when they are customized
  *
  * @return void
  */
 public function testJunctionWithCustomForeignKeys()
 {
     $assoc = new BelongsToMany('Test', ['sourceTable' => $this->article, 'targetTable' => $this->tag, 'foreignKey' => 'Art', 'targetForeignKey' => 'Tag']);
     $junction = $assoc->junction();
     $this->assertEquals('Art', $junction->association('Articles')->foreignKey());
     $this->assertEquals('Tag', $junction->association('Tags')->foreignKey());
     $inverseRelation = $this->tag->association('Articles');
     $this->assertEquals('Tag', $inverseRelation->foreignKey());
     $this->assertEquals('Art', $inverseRelation->targetForeignKey());
 }