Skip to content

Commit

Permalink
Merge pull request #91 from EscolaLMS/issue/upload
Browse files Browse the repository at this point in the history
test
  • Loading branch information
KrzysztofDziedziechEscolasoft authored Apr 1, 2022
2 parents 88725af + 16fddc3 commit 9a6deac
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions src/Repositories/H5PRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use EscolaLms\HeadlessH5P\Models\H5PLibraryLanguage;
use H5PFrameworkInterface;
use Illuminate\Support\Facades\Log;
use TypeError;

class H5PRepository implements H5PFrameworkInterface
{
Expand Down Expand Up @@ -637,29 +636,17 @@ public function deleteLibraryUsage($contentId)
*/
public function saveLibraryUsage($contentId, $librariesInUse)
{
$contentLibraries = array_map(function ($value) use ($contentId, &$test) {
try {
return H5PContentLibrary::firstOrCreate([
'content_id' => $contentId,
'library_id' => $value['library']['id'],
'dependency_type' => $value['type'],
], [
'drop_css' => boolval($value['library']['dropLibraryCss']),
'weight' => $value['weight'],
$contentLibraries = array_map(function ($value) use ($contentId) {
return H5PContentLibrary::firstOrCreate([
'content_id' => $contentId,
'library_id' => $value['library']['id'],
'dependency_type' => $value['type'],
], [
'drop_css' => boolval($value['library']['dropLibraryCss']),
'weight' => $value['weight'],
])->toArray();
} catch (TypeError $exception) {
dd([
'drop_css' => boolval($value['library']['dropLibraryCss']),
'weight' => $value['weight'],
],
[
'content_id' => $contentId,
'library_id' => $value['library']['id'],
'dependency_type' => $value['type'],
]
);
}
}, $librariesInUse);

$content = H5PContent::with('library')->findOrFail($contentId);

$libraryLibraries = array_map(function ($value) use ($contentId) {
Expand Down

0 comments on commit 9a6deac

Please sign in to comment.