Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jun 27, 2017
1 parent f2adbe2 commit 1137d86
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 84 deletions.
26 changes: 13 additions & 13 deletions src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Concerns\HasDefault;
use Illuminate\Database\Eloquent\Relations\Concerns\SupportsDefaultModels;

class BelongsTo extends Relation
{
use HasDefault;
use SupportsDefaultModels;

/**
* The child model instance of the relation.
Expand Down Expand Up @@ -296,6 +296,17 @@ protected function relationHasIncrementingId()
$this->related->getKeyType() === 'int';
}

/**
* Make a new related instance for the given model.
*
* @param \Illuminate\Database\Eloquent\Model $parent
* @return \Illuminate\Database\Eloquent\Model
*/
protected function newRelatedInstanceFor(Model $parent)
{
return $this->related->newInstance();
}

/**
* Get the foreign key of the relationship.
*
Expand Down Expand Up @@ -345,15 +356,4 @@ public function getRelation()
{
return $this->relation;
}

/**
* Make a new related instance for the given model.
*
* @param \Illuminate\Database\Eloquent\Model $parent
* @return \Illuminate\Database\Eloquent\Model
*/
protected function newRelatedInstanceFor(Model $parent)
{
return $this->related->newInstance();
}
}
63 changes: 0 additions & 63 deletions src/Illuminate/Database/Eloquent/Relations/Concerns/HasDefault.php

This file was deleted.

9 changes: 5 additions & 4 deletions src/Illuminate/Database/Eloquent/Relations/HasOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Concerns\HasDefault;
use Illuminate\Database\Eloquent\Relations\Concerns\SupportsDefaultModels;

class HasOne extends HasOneOrMany
{
use HasDefault;
use SupportsDefaultModels;

/**
* Get the results of the relationship.
Expand Down Expand Up @@ -57,7 +57,8 @@ public function match(array $models, Collection $results, $relation)
*/
public function newRelatedInstanceFor(Model $parent)
{
return $this->related->newInstance()
->setAttribute($this->getForeignKeyName(), $parent->{$this->localKey});
return $this->related->newInstance()->setAttribute(
$this->getForeignKeyName(), $parent->{$this->localKey}
);
}
}
8 changes: 4 additions & 4 deletions src/Illuminate/Database/Eloquent/Relations/MorphOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Concerns\HasDefault;
use Illuminate\Database\Eloquent\Relations\Concerns\SupportsDefaultModels;

class MorphOne extends MorphOneOrMany
{
use HasDefault;
use SupportsDefaultModels;

/**
* Get the results of the relationship.
Expand Down Expand Up @@ -58,7 +58,7 @@ public function match(array $models, Collection $results, $relation)
public function newRelatedInstanceFor(Model $parent)
{
return $this->related->newInstance()
->setAttribute($this->getForeignKeyName(), $parent->{$this->localKey})
->setAttribute($this->getMorphType(), $this->morphClass);
->setAttribute($this->getForeignKeyName(), $parent->{$this->localKey})
->setAttribute($this->getMorphType(), $this->morphClass);
}
}

0 comments on commit 1137d86

Please sign in to comment.