mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2025-12-13 05:26:47 +00:00
🗃️ refactor(project): rename project support route for clarity and consistency. 🗑️ chore(project): implement delete confirmation for project proposals in the index view. 🔧 fix(editor): adjust initialization delay for SimpleMDE editor to improve responsiveness. 📸 fix(media): update fallback image URL in ProjectProposal model for better asset management.
80 lines
1.9 KiB
PHP
80 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Support\Facades\Cookie;
|
|
use Spatie\Image\Enums\Fit;
|
|
use Spatie\MediaLibrary\HasMedia;
|
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
|
use Spatie\Sluggable\HasSlug;
|
|
use Spatie\Sluggable\SlugOptions;
|
|
|
|
class ProjectProposal extends Model implements HasMedia
|
|
{
|
|
use InteractsWithMedia;
|
|
use HasSlug;
|
|
|
|
/**
|
|
* The attributes that aren't mass assignable.
|
|
* @var array
|
|
*/
|
|
protected $guarded = [];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'id' => 'integer',
|
|
'einundzwanzig_pleb_id' => 'integer',
|
|
];
|
|
|
|
protected static function booted()
|
|
{
|
|
|
|
}
|
|
|
|
public function getSlugOptions(): SlugOptions
|
|
{
|
|
return SlugOptions::create()
|
|
->generateSlugsFrom(['name'])
|
|
->saveSlugsTo('slug')
|
|
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
|
}
|
|
|
|
public function registerMediaConversions(Media $media = null): void
|
|
{
|
|
$this
|
|
->addMediaConversion('preview')
|
|
->fit(Fit::Crop, 300, 300)
|
|
->nonQueued();
|
|
$this
|
|
->addMediaConversion('thumb')
|
|
->fit(Fit::Crop, 130, 130)
|
|
->width(130)
|
|
->height(130);
|
|
}
|
|
|
|
public function registerMediaCollections(): void
|
|
{
|
|
$this
|
|
->addMediaCollection('main')
|
|
->singleFile()
|
|
->useFallbackUrl(asset('einundzwanzig-alpha.jpg'));
|
|
}
|
|
|
|
public function einundzwanzigPleb(): BelongsTo
|
|
{
|
|
return $this->belongsTo(EinundzwanzigPleb::class);
|
|
}
|
|
|
|
public function votes(): HasMany
|
|
{
|
|
return $this->hasMany(Vote::class);
|
|
}
|
|
}
|