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)
|
||||
{
|
||||
|
||||
$instance = $class->newRelatedInstance(self::class);
|
||||
|
||||
$foreignKey = 'relation_id';
|
||||
$relatedKey = 'image_id';
|
||||
$name = 'relation';
|
||||
$instance = $class->newRelatedInstance(static::class);
|
||||
$foreignPivotKey = 'relation_id';
|
||||
$relatedPivotKey = 'image_id';
|
||||
$table = 'associate_images';
|
||||
$inverse = false;
|
||||
$name = 'relation';
|
||||
|
||||
$relation = new MorphToMany(
|
||||
$morph = new MorphToMany(
|
||||
$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()
|
||||
|
|
Loading…
Reference in New Issue