public function testMorphOneWhereClausesCanBeRemoved()
 {
     $builder = new EloquentMorphResetBuilderStub();
     $parent = m::mock('Illuminate\\Database\\Eloquent\\Model');
     $parent->shouldReceive('getKey')->andReturn(1);
     $relation = new MorphOne($builder, $parent, 'morph');
     $relation->where('foo', '=', 'bar');
     list($wheres, $bindings) = $relation->getAndResetWheres();
     $this->assertEquals('bar', $bindings[0]);
     $this->assertEquals('Basic', $wheres[0]['type']);
     $this->assertEquals('foo', $wheres[0]['column']);
     $this->assertEquals('bar', $wheres[0]['value']);
 }
Exemplo n.º 2
0
 /**
  * Create a new has many relationship instance.
  * @return void
  */
 public function __construct(Builder $query, Model $parent, $type, $id, $isPublic, $localKey, $relationName = null)
 {
     $this->relationName = $relationName;
     $this->public = $isPublic;
     parent::__construct($query, $parent, $type, $id, $localKey);
     $this->addDefinedConstraints();
 }
Exemplo n.º 3
0
 /**
  * Create a new has many relationship instance.
  * @return void
  */
 public function __construct(Builder $query, Model $parent, $type, $id, $localKey, $relationName = null)
 {
     $this->relationName = $relationName;
     parent::__construct($query, $parent, $type, $id, $localKey);
 }
Exemplo n.º 4
0
 /**
  * @param Model $model
  * @param Model $parent
  */
 public function attach(Model $model, Model $parent)
 {
     parent::attach($model, $parent);
     $model->setAttribute($this->relation->getPlainMorphType(), $this->relation->getMorphClass());
 }