generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c21ed1
commit 6cf3ce2
Showing
5 changed files
with
92 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
<?php | ||
|
||
use FFMpeg\Coordinate\Dimension; | ||
use Finller\LaravelMedia\Casts\GeneratedConversion; | ||
use Finller\LaravelMedia\Database\Factories\MediaFactory; | ||
use Finller\LaravelMedia\Enums\MediaType; | ||
use Finller\LaravelMedia\Media; | ||
use Finller\LaravelMedia\Tests\Models\Test; | ||
use Illuminate\Http\UploadedFile; | ||
use Illuminate\Support\Facades\Storage; | ||
|
||
it('retrieve the generated conversion key', function () { | ||
// | ||
$model = (new Test())->save(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Finller\LaravelMedia\Tests\Models; | ||
|
||
use Finller\LaravelMedia\Enums\MediaType; | ||
use Finller\LaravelMedia\Jobs\OptimizedImageConversionJob; | ||
use Finller\LaravelMedia\Media; | ||
use Finller\LaravelMedia\MediaCollection; | ||
use Finller\LaravelMedia\MediaConversion; | ||
use Finller\LaravelMedia\Traits\HasMedia; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Str; | ||
|
||
/** | ||
* @property ?string $uuid | ||
*/ | ||
class Test extends Model | ||
{ | ||
use HasMedia; | ||
|
||
protected $table = 'tests'; | ||
|
||
protected $guarded = []; | ||
|
||
/** | ||
* @return Collection<string, MediaCollection> | ||
*/ | ||
public function getMediaCollections(): Collection | ||
{ | ||
return collect([ | ||
'files' => new MediaCollection( | ||
single: false, | ||
public: false, | ||
) | ||
]); | ||
} | ||
|
||
function getMediaConversions(Media $media): Collection | ||
{ | ||
|
||
$conversions = collect(); | ||
|
||
if ($media->type === MediaType::Image) { | ||
$conversions->push( | ||
new MediaConversion( | ||
name: 'optimized', | ||
job: new OptimizedImageConversionJob($media, 'optimized') | ||
) | ||
); | ||
} | ||
|
||
return $conversions->keyBy('name'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters