Skip to content

Commit

Permalink
Add QueryCachable trait (#199)
Browse files Browse the repository at this point in the history
* Add QueryCachable trait

* WIP
  • Loading branch information
mako321 authored Jan 19, 2024
1 parent 780d317 commit f155239
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Models/H5PContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace EscolaLms\HeadlessH5P\Models;

use EscolaLms\Core\Models\Traits\QueryCacheable;
use EscolaLms\Core\Models\User;
use EscolaLms\HeadlessH5P\Database\Factories\H5PContentFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
Expand Down Expand Up @@ -89,7 +90,7 @@

class H5PContent extends Model
{
use HasFactory;
use HasFactory, QueryCacheable;

protected $table = 'hh5p_contents';

Expand Down
3 changes: 2 additions & 1 deletion src/Models/H5PContentLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace EscolaLms\HeadlessH5P\Models;

use EscolaLms\Core\Models\Traits\QueryCacheable;
use EscolaLms\HeadlessH5P\Database\Factories\H5PContentLibraryFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class H5PContentLibrary extends Model
{
use HasFactory;
use HasFactory, QueryCacheable;

public $incrementing = false;

Expand Down
3 changes: 2 additions & 1 deletion src/Models/H5PLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace EscolaLms\HeadlessH5P\Models;

use EscolaLms\Core\Models\Traits\QueryCacheable;
use EscolaLms\HeadlessH5P\Database\Factories\H5PLibraryFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand Down Expand Up @@ -117,7 +118,7 @@

class H5PLibrary extends Model
{
use HasFactory;
use HasFactory, QueryCacheable;

protected $table = 'hh5p_libraries';

Expand Down
2 changes: 1 addition & 1 deletion tests/Repositories/H5PRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function testDeleteLibraryUsageShouldDeleteLibrariesById(): void

$this->repository->deleteLibraryUsage($h5pContent->getKey());

$this->assertCount(0, H5PContent::find($h5pContent->getKey())->libraries);
$this->assertCount(0, $h5pContent->refresh()->libraries);
}

public function testDeleteLibraryUsageShouldFailWhenContentNotExists(): void
Expand Down

0 comments on commit f155239

Please sign in to comment.