Skip to content

Commit

Permalink
media collections disks
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Dec 13, 2023
1 parent 5d82063 commit 8cf4c7a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Article extends Model implements HasMedia
public function registerMediaCollections(): void
{
$this->addMediaCollection('preview')
->useDisk(config('filesystems.default_public'))
->useFallbackUrl(Vite::image('placeholder.png'))
->singleFile()
->registerMediaConversions(function (Media $media) {
Expand All @@ -60,6 +61,7 @@ public function registerMediaCollections(): void
});

$this->addMediaCollection('gallery')
->useDisk(config('filesystems.default_public'))
->useFallbackUrl(Vite::image('placeholder.png'))
->registerMediaConversions(function (Media $media) {
$this
Expand Down
2 changes: 2 additions & 0 deletions app/Models/BCRProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class BCRProject extends Model implements HasMedia
public function registerMediaCollections(): void
{
$this->addMediaCollection('preview')
->useDisk(config('filesystems.default_public'))
->useFallbackUrl(Vite::image('placeholder.png'))
->singleFile()
->registerMediaConversions(function () {
Expand All @@ -70,6 +71,7 @@ public function registerMediaCollections(): void
});

$this->addMediaCollection('gallery')
->useDisk(config('filesystems.default_public'))
->registerMediaConversions(function () {
$this
->addMediaConversion('preview')
Expand Down
1 change: 1 addition & 0 deletions app/Models/Badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Badge extends Model implements HasMedia
public function registerMediaCollections(): void
{
$this->addMediaCollection('default')
->useDisk(config('filesystems.default_public'))
->useFallbackUrl(Vite::asset('resources/images/badge.png'))
->singleFile()
->registerMediaConversions(function (Media $media) {
Expand Down
5 changes: 4 additions & 1 deletion app/Models/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function donations()
public function registerMediaCollections(): void
{
$this->addMediaCollection('logo')
->useDisk(config('filesystems.default_public'))
->useFallbackUrl(Vite::image('placeholder.png'))
->singleFile()
->registerMediaConversions(function (Media $media) {
Expand All @@ -104,9 +105,11 @@ public function registerMediaCollections(): void
});

$this->addMediaCollection('statute')
->useDisk(config('filesystems.default'))
->singleFile();

$this->addMediaCollection('statute_pending');
$this->addMediaCollection('statute_pending')
->useDisk(config('filesystems.default'));
}

public function users(): HasMany
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class Project extends Model implements HasMedia
public function registerMediaCollections(): void
{
$this->addMediaCollection('preview')
->useDisk(config('filesystems.default_public'))
->useFallbackUrl(Vite::image('placeholder.png'))
->singleFile()
->registerMediaConversions(function (Media $media) {
Expand All @@ -97,6 +98,7 @@ public function registerMediaCollections(): void
});

$this->addMediaCollection('gallery')
->useDisk(config('filesystems.default_public'))
->registerMediaConversions(function (Media $media) {
$this
->addMediaConversion('preview')
Expand Down
4 changes: 4 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public function register(): void
$this->registerCarbonMacros();

Vite::macro('image', fn (string $asset) => $this->asset("resources/images/{$asset}"));

config([
'filament.default_filesystem_disk' => config('filesystems.default_public'),
]);
}

/**
Expand Down
23 changes: 20 additions & 3 deletions config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

'default' => env('FILESYSTEM_DISK', 'local'),

'default_public' => env('FILESYSTEM_DISK_PUBLIC', 'public'),

/*
|--------------------------------------------------------------------------
| Filesystem Disks
Expand Down Expand Up @@ -46,7 +48,22 @@
'throw' => false,
],

's3' => [
's3public' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'token' => env('AWS_SESSION_TOKEN'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_PUBLIC_BUCKET'),
'url' => env('AWS_PUBLIC_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'root' => env('AWS_PUBLIC_BUCKET_ROOT'),
'visibility' => 'private',
],

's3private' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
Expand All @@ -57,8 +74,8 @@
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'root' => env('AWS_BUCKET_ROOT'),
'visibility' => 'public',
'root' => env('AWS_PUBLIC_BUCKET_ROOT'),
'visibility' => 'private',
],

],
Expand Down

0 comments on commit 8cf4c7a

Please sign in to comment.