Add company_id column to media tables
This commit is contained in:
@ -34,4 +34,26 @@ trait Media
|
||||
|
||||
return $media;
|
||||
}
|
||||
|
||||
public function attachMedia($media, $tags): void
|
||||
{
|
||||
$tags = (array)$tags;
|
||||
$increments = $this->getOrderValueForTags($tags);
|
||||
|
||||
$ids = $this->extractPrimaryIds($media);
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$attach = [];
|
||||
foreach ($ids as $id) {
|
||||
$attach[$id] = [
|
||||
'company_id' => company_id(),
|
||||
'tag' => $tag,
|
||||
'order' => ++$increments[$tag],
|
||||
];
|
||||
}
|
||||
$this->media()->attach($attach);
|
||||
}
|
||||
|
||||
$this->markMediaDirty($tags);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user