public function testKeysCanBeSetProperly()
 {
     $pivot = new Pivot(array('foo' => 'bar'), 'table', 'connection');
     $pivot->setPivotKeys('foreign', 'other');
     $this->assertEquals('foreign', $pivot->getForeignKey());
     $this->assertEquals('other', $pivot->getOtherKey());
 }
示例#2
0
 /**
  * Create a new pivot model instance.
  *
  * @param  array  $attributes
  * @param  bool   $exists
  * @return \Illuminate\Database\Eloquent\Relation\Pivot
  */
 public function newPivot(array $attributes = array(), $exists = false)
 {
     $pivot = new Pivot($this->parent, $attributes, $this->table, $exists);
     $pivot->setPivotKeys($this->foreignKey, $this->otherKey);
     return $pivot;
 }
 /**
  * Create a new pivot model instance.
  *
  * @param  array  $attributes
  * @param  bool   $exists
  * @return Illuminate\Database\Eloquent\Relation\Pivot
  */
 protected function newPivot(array $attributes = array(), $exists = false)
 {
     $connection = $this->parent->getConnectionName();
     $pivot = new Pivot($attributes, $this->table, $connection, $exists);
     $pivot->setPivotKeys($this->foreignKey, $this->otherKey);
     return $pivot;
 }