mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
comments for news
This commit is contained in:
@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Spatie\Comments\Models\Concerns\HasComments;
|
||||
use Spatie\EloquentSortable\Sortable;
|
||||
use Spatie\EloquentSortable\SortableTrait;
|
||||
use Spatie\Image\Manipulations;
|
||||
@@ -24,6 +25,7 @@ class LibraryItem extends Model implements HasMedia, Sortable
|
||||
use SortableTrait;
|
||||
use HasStatuses;
|
||||
use HasSlug;
|
||||
use HasComments;
|
||||
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
@@ -41,14 +43,6 @@ class LibraryItem extends Model implements HasMedia, Sortable
|
||||
'library_id' => 'integer',
|
||||
];
|
||||
|
||||
public function getSlugOptions(): SlugOptions
|
||||
{
|
||||
return SlugOptions::create()
|
||||
->generateSlugsFrom(['name'])
|
||||
->saveSlugsTo('slug')
|
||||
->usingLanguage(Cookie::get('lang', config('app.locale')));
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
@@ -58,6 +52,14 @@ class LibraryItem extends Model implements HasMedia, Sortable
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
@@ -101,4 +103,26 @@ class LibraryItem extends Model implements HasMedia, Sortable
|
||||
{
|
||||
return $this->belongsToMany(Library::class);
|
||||
}
|
||||
|
||||
/*
|
||||
* This string will be used in notifications on what a new comment
|
||||
* was made.
|
||||
*/
|
||||
public function commentableName(): string
|
||||
{
|
||||
return __('Library Item');
|
||||
}
|
||||
|
||||
/*
|
||||
* This URL will be used in notifications to let the user know
|
||||
* where the comment itself can be read.
|
||||
*/
|
||||
public function commentUrl(): string
|
||||
{
|
||||
if ($this->type === 'markdown_article') {
|
||||
return url()->route('article.view', ['libraryItem' => $this]);
|
||||
} else {
|
||||
return url()->route('libraryItem.view', ['libraryItem' => $this]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user