mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-13 06:56:48 +00:00
default images added
This commit is contained in:
@@ -4,13 +4,20 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use Spatie\Sluggable\HasSlug;
|
||||
use Spatie\Sluggable\SlugOptions;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Venue extends Model
|
||||
class Venue extends Model implements HasMedia
|
||||
{
|
||||
use HasFactory;
|
||||
use HasSlug;
|
||||
use HasRelationships;
|
||||
use InteractsWithMedia;
|
||||
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
@@ -27,6 +34,24 @@ class Venue extends Model
|
||||
'city_id' => 'integer',
|
||||
];
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
{
|
||||
$this
|
||||
->addMediaConversion('preview')
|
||||
->fit(Manipulations::FIT_CROP, 300, 300)
|
||||
->nonQueued();
|
||||
$this->addMediaConversion('thumb')
|
||||
->fit(Manipulations::FIT_CROP, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
}
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('images')
|
||||
->useFallbackUrl(asset('img/einundzwanzig-cover-lesestunde.png'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the options for generating the slug.
|
||||
*/
|
||||
@@ -43,6 +68,16 @@ class Venue extends Model
|
||||
return $this->belongsTo(City::class);
|
||||
}
|
||||
|
||||
public function lecturers()
|
||||
{
|
||||
return $this->hasManyDeepFromRelations($this->courses(), (new Course())->lecturer());
|
||||
}
|
||||
|
||||
public function courses()
|
||||
{
|
||||
return $this->hasManyDeepFromRelations($this->events(), (new Event())->course());
|
||||
}
|
||||
|
||||
public function events(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
|
||||
Reference in New Issue
Block a user