Modifs Relation
This commit is contained in:
parent
9f448ef69c
commit
7416cf37ec
|
@ -213,22 +213,20 @@ class Image extends Model
|
||||||
*/
|
*/
|
||||||
public static function createRelation(Model $class, $relationName)
|
public static function createRelation(Model $class, $relationName)
|
||||||
{
|
{
|
||||||
|
$instance = $class->newRelatedInstance(static::class);
|
||||||
$instance = $class->newRelatedInstance(self::class);
|
$foreignPivotKey = 'relation_id';
|
||||||
|
$relatedPivotKey = 'image_id';
|
||||||
$foreignKey = 'relation_id';
|
|
||||||
$relatedKey = 'image_id';
|
|
||||||
$name = 'relation';
|
|
||||||
$table = 'associate_images';
|
$table = 'associate_images';
|
||||||
$inverse = false;
|
$name = 'relation';
|
||||||
|
|
||||||
$relation = new MorphToMany(
|
$morph = new MorphToMany(
|
||||||
$instance->newQuery(), $class, $name, $table,
|
$instance->newQuery(), $class, $name, $table,
|
||||||
$foreignKey, $relatedKey, $relationName, $inverse
|
$foreignPivotKey, $relatedPivotKey, $class->getKeyName(),
|
||||||
|
$instance->getKeyName(), $relationName, false
|
||||||
);
|
);
|
||||||
$relation->withPivot('position');
|
$morph->withPivot('position');
|
||||||
|
|
||||||
return $relation;
|
return $morph;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray()
|
public function toArray()
|
||||||
|
|
Loading…
Reference in New Issue