mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-12 20:20:41 -05:00
Fixes Local Image Issue
Local images should now appear. Needed to specify the public disk to ensure that HTTPS was used.
This commit is contained in:
parent
a2fb68ea93
commit
d34a75523a
@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Scout\Searchable;
|
||||
|
||||
@ -31,17 +32,10 @@ class Mod extends Model
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
// Apply the global scope to exclude disabled mods.
|
||||
static::addGlobalScope(new DisabledScope);
|
||||
}
|
||||
|
||||
protected function slug(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn (string $value) => strtolower($value),
|
||||
set: fn (string $value) => Str::slug($value),
|
||||
);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
@ -57,6 +51,9 @@ class Mod extends Model
|
||||
return $this->hasMany(ModVersion::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to include the total number of downloads for a mod.
|
||||
*/
|
||||
public function scopeWithTotalDownloads($query)
|
||||
{
|
||||
return $query->addSelect(['total_downloads' => ModVersion::selectRaw('SUM(downloads) AS total_downloads')
|
||||
@ -110,6 +107,9 @@ class Mod extends Model
|
||||
->with(['lastUpdatedVersion', 'lastUpdatedVersion.sptVersion']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the indexable data array for the model.
|
||||
*/
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
return [
|
||||
@ -124,8 +124,45 @@ class Mod extends Model
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the model should be searchable.
|
||||
*/
|
||||
public function shouldBeSearchable(): bool
|
||||
{
|
||||
return ! $this->disabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL to the thumbnail.
|
||||
*/
|
||||
public function thumbnailUrl(): Attribute
|
||||
{
|
||||
return Attribute::get(function (): string {
|
||||
return $this->thumbnail
|
||||
? Storage::disk($this->thumbnailDisk())->url($this->thumbnail)
|
||||
: '';
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the disk where the thumbnail is stored.
|
||||
*/
|
||||
protected function thumbnailDisk(): string
|
||||
{
|
||||
return match (config('app.env')) {
|
||||
'production' => 'r2', // Cloudflare R2 Storage
|
||||
default => 'public', // Local
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the slug is always lower case when retrieved and slugified when saved.
|
||||
*/
|
||||
protected function slug(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn (string $value) => Str::lower($value),
|
||||
set: fn (string $value) => Str::slug($value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -84,4 +84,15 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the disk that profile photos should be stored on.
|
||||
*/
|
||||
protected function profilePhotoDisk(): string
|
||||
{
|
||||
return match (config('app.env')) {
|
||||
'production' => 'r2', // Cloudflare R2 Storage
|
||||
default => 'public', // Local
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<img src="https://placehold.co/450x450/EEE/31343C?font=source-sans-pro&text={{ $mod->name }}" alt="{{ $mod->name }}" class="block dark:hidden h-48 w-full object-cover md:h-full md:w-48 transform group-hover:scale-110 transition-all duration-200">
|
||||
<img src="https://placehold.co/450x450/31343C/EEE?font=source-sans-pro&text={{ $mod->name }}" alt="{{ $mod->name }}" class="hidden dark:block h-48 w-full object-cover md:h-full md:w-48 transform group-hover:scale-110 transition-all duration-200">
|
||||
@else
|
||||
<img src="{{ asset($mod->thumbnail) }}" alt="{{ $mod->name }}" class="h-48 w-full object-cover md:h-full md:w-48 transform group-hover:scale-110 transition-all duration-200">
|
||||
<img src="{{ $mod->thumbnailUrl }}" alt="{{ $mod->name }}" class="h-48 w-full object-cover md:h-full md:w-48 transform group-hover:scale-110 transition-all duration-200">
|
||||
@endif
|
||||
</div>
|
||||
<div class="flex flex-col w-full justify-between p-5">
|
||||
|
@ -15,7 +15,7 @@
|
||||
<img src="https://placehold.co/144x144/EEE/31343C?font=source-sans-pro&text={{ $mod->name }}" alt="{{ $mod->name }}" class="block dark:hidden w-36 rounded-lg">
|
||||
<img src="https://placehold.co/144x144/31343C/EEE?font=source-sans-pro&text={{ $mod->name }}" alt="{{ $mod->name }}" class="hidden dark:block w-36 rounded-lg">
|
||||
@else
|
||||
<img src="{{ Storage::url($mod->thumbnail) }}" alt="{{ $mod->name }}" class="w-36 rounded-lg">
|
||||
<img src="{{ $mod->thumbnailUrl }}" alt="{{ $mod->name }}" class="w-36 rounded-lg">
|
||||
@endif
|
||||
</div>
|
||||
<div class="grow flex flex-col justify-center items-center sm:items-start text-gray-800 dark:text-gray-200">
|
||||
|
Loading…
x
Reference in New Issue
Block a user