targetForeignKey() 공개 메소드

If no parameters are passed current field is returned
public targetForeignKey ( string | null $key = null ) : string
$key string | null the key to be used to link both tables together
리턴 string
예제 #1
0
 /**
  * Tests that targetForeignKey() returns the correct configured value
  *
  * @return void
  */
 public function testTargetForeignKey()
 {
     $assoc = new BelongsToMany('Test', ['sourceTable' => $this->article, 'targetTable' => $this->tag]);
     $this->assertEquals('tag_id', $assoc->targetForeignKey());
     $assoc->targetForeignKey('another_key');
     $this->assertEquals('another_key', $assoc->targetForeignKey());
     $assoc = new BelongsToMany('Test', ['sourceTable' => $this->article, 'targetTable' => $this->tag, 'targetForeignKey' => 'foo']);
     $this->assertEquals('foo', $assoc->targetForeignKey());
 }