Skip to content

Commit f356419

Browse files
committed
fromRawAttributes method on pivot
1 parent 9650f4f commit f356419

File tree

1 file changed

+18
-0
lines changed
  • src/Illuminate/Database/Eloquent/Relations

1 file changed

+18
-0
lines changed

src/Illuminate/Database/Eloquent/Relations/Pivot.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ public function __construct(Model $parent, $attributes, $table, $exists = false)
6969
$this->timestamps = $this->hasTimestampAttributes();
7070
}
7171

72+
/**
73+
* Create a new pivot model from raw values returned from a query.
74+
*
75+
* @param \Illuminate\Database\Eloquent\Model $parent
76+
* @param array $attributes
77+
* @param string $table
78+
* @param bool $exists
79+
* @return static
80+
*/
81+
public static function fromRawAttributes(Model $parent, $attributes, $table, $exists = false)
82+
{
83+
$instance = new static($parent, $attributes, $table, $exists);
84+
85+
$instance->setRawAttributes($attributes, true);
86+
87+
return $instance;
88+
}
89+
7290
/**
7391
* Set the keys for a save update query.
7492
*

0 commit comments

Comments
 (0)