コード例 #1
0
 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
 public static function boot()
 {
     parent::boot();
     static::created(function ($model) {
         $responses = Event::fire('notification::assigned', array($model));
     });
     static::saving(function ($model) {
         $model->updateTimestamps();
     });
 }
コード例 #3
0
ファイル: MorphPivot.php プロジェクト: AlexCutts/framework
 /**
  * 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);
 }
コード例 #4
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;
 }
コード例 #5
0
 /**
  * @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;
 }
コード例 #6
0
 /**
  * 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;
 }
コード例 #7
0
ファイル: Pivot.php プロジェクト: stickableapp/stickable-api
 public function toArray()
 {
     $array = parent::toArray();
     $array = $this->formatArrayDates($array);
     return $array;
 }