| @@ 66-81 (lines=16) @@ | ||
| 63 | * @param Model $model Model that blocks belong to. |
|
| 64 | * @param array $data Array of model information. |
|
| 65 | */ |
|
| 66 | public function updateAllTextBlocks(Model $model, array $data) |
|
| 67 | { |
|
| 68 | $blockData = collect($data)->get('blocks', []); |
|
| 69 | ||
| 70 | $blockData = $this->setOrder($blockData); |
|
| 71 | ||
| 72 | foreach ($blockData as $singleBlockData) { |
|
| 73 | if (isset($singleBlockData['resource_id'])) { |
|
| 74 | $block = TextBlock::find($singleBlockData['id']); |
|
| 75 | ||
| 76 | $this->updateTextBlock($block, $singleBlockData); |
|
| 77 | } else { |
|
| 78 | $this->addBlockToModel($model, $singleBlockData); |
|
| 79 | } |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Remove a text block from a project. |
|
| @@ 169-184 (lines=16) @@ | ||
| 166 | * @param Model $model Model that links belong to. |
|
| 167 | * @param array $data Array of model information. |
|
| 168 | */ |
|
| 169 | public function updateAllLinks(Model $model, array $data) |
|
| 170 | { |
|
| 171 | $linkData = collect($data)->get('links', []); |
|
| 172 | ||
| 173 | $linkData = $this->setOrder($linkData); |
|
| 174 | ||
| 175 | foreach ($linkData as $singleLinkData) { |
|
| 176 | if (isset($singleLinkData['resource_id'])) { |
|
| 177 | $link = Link::find($singleLinkData['id']); |
|
| 178 | ||
| 179 | $this->updateLink($link, $singleLinkData); |
|
| 180 | } else { |
|
| 181 | $this->addLinkToModel($model, $singleLinkData); |
|
| 182 | } |
|
| 183 | } |
|
| 184 | } |
|
| 185 | ||
| 186 | /** |
|
| 187 | * Remove link from a project. |
|