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()); }
public static function boot() { parent::boot(); static::created(function ($model) { $responses = Event::fire('notification::assigned', array($model)); }); static::saving(function ($model) { $model->updateTimestamps(); }); }
/** * Set the keys for a save update query. * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ protected function setKeysForSaveQuery(Builder $query) { $query->where($this->morphType, $this->morphClass); return parent::setKeysForSaveQuery($query); }
/** * 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; }
/** * @param Model $parent * @param Model $third * @param array $attributes * @param string $table * @param boolean $exists */ public function __construct(Model $parent, Model $third, $attributes, $table, $exists = false) { parent::__construct($parent, $attributes, $table, $exists); $this->thirdKey = $third->getKeyName(); $this->third = $third; }
/** * 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; }
public function toArray() { $array = parent::toArray(); $array = $this->formatArrayDates($array); return $array; }