diff --git a/config/responsecache.php b/config/responsecache.php
index 96f7710..4df1df9 100644
--- a/config/responsecache.php
+++ b/config/responsecache.php
@@ -13,7 +13,7 @@
* You can provide your own class given that it implements the
* CacheProfile interface.
*/
- 'cache_profile' => Spatie\ResponseCache\CacheProfiles\CacheAllSuccessfulGetRequests::class,
+ 'cache_profile' => \EscolaLms\Courses\Services\CacheGetRequestService::class,
/*
* When using the default CacheRequestFilter this setting controls the
diff --git a/database/factories/CourseFactory.php b/database/factories/CourseFactory.php
index 805d7d4..03aed8d 100644
--- a/database/factories/CourseFactory.php
+++ b/database/factories/CourseFactory.php
@@ -62,18 +62,18 @@ public function configure()
//
$id = $course->id;
$word = $this->faker->word;
- $filename_image = "course/$id/" . $word . ".jpg";
- $filename_video = "course/$id/" . $word . ".mp4";
- $filename_poster = "course/$id/" . $word . "poster.jpg";
+ $filename_image = $word . ".jpg";
+ $filename_video = $word . ".mp4";
+ $filename_poster = $word . "poster.jpg";
- Storage::putFileAs("course/{$id}", new File(__DIR__ . '/../mocks/1.jpg'), $filename_image);
- Storage::putFileAs("course/{$id}", new File(__DIR__ . '/../mocks/1.mp4'), $filename_video);
- Storage::putFileAs("course/{$id}", new File(__DIR__ . '/../mocks/poster.jpg'), $filename_poster);
+ Storage::putFileAs("course/{$id}/images", new File(__DIR__ . '/../mocks/1.jpg'), $filename_image);
+ Storage::putFileAs("course/{$id}/videos", new File(__DIR__ . '/../mocks/1.mp4'), $filename_video);
+ Storage::putFileAs("course/{$id}/posters", new File(__DIR__ . '/../mocks/poster.jpg'), $filename_poster);
$course->update([
- 'image_path' => $filename_image,
- 'video_path' => $filename_video,
- 'poster_path' => $filename_poster,
+ 'image_path' => "course/{$id}/images/" . $filename_image,
+ 'video_path' => "course/{$id}/videos/" . $filename_video,
+ 'poster_path' => "course/{$id}/posters/" . $filename_poster,
]);
});
}
diff --git a/phpunit.xml b/phpunit.xml
index a8ead77..9f5fbb8 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -12,6 +12,7 @@
./tests
+
diff --git a/src/Repositories/CourseRepository.php b/src/Repositories/CourseRepository.php
index 2d06ed0..0967909 100644
--- a/src/Repositories/CourseRepository.php
+++ b/src/Repositories/CourseRepository.php
@@ -23,6 +23,7 @@
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Str;
/**
* Class CourseRepository
@@ -219,6 +220,18 @@ public function update(array $input, int $id): Model
$isActive = $model->is_active;
+ if (isset($input['video_path'])) {
+ $input['video_path'] = Str::after($input['video_path'], env('AWS_ACCESS_KEY_ID') . '/');
+ }
+
+ if (isset($input['image_path'])) {
+ $input['image_path'] = Str::after($input['image_path'], env('AWS_ACCESS_KEY_ID') . '/');
+ }
+
+ if (isset($input['poster_path'])) {
+ $input['poster_path'] = Str::after($input['poster_path'], env('AWS_ACCESS_KEY_ID') . '/');
+ }
+
if (isset($input['video'])) {
$input['video_path'] = FileHelper::getFilePath($input['video'], "course/$id/videos");
}
diff --git a/src/Services/CacheGetRequestService.php b/src/Services/CacheGetRequestService.php
new file mode 100644
index 0000000..0a8404c
--- /dev/null
+++ b/src/Services/CacheGetRequestService.php
@@ -0,0 +1,14 @@
+