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\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Support\Facades\Cookie;
|
use Illuminate\Support\Facades\Cookie;
|
||||||
|
use Spatie\Comments\Models\Concerns\HasComments;
|
||||||
use Spatie\EloquentSortable\Sortable;
|
use Spatie\EloquentSortable\Sortable;
|
||||||
use Spatie\EloquentSortable\SortableTrait;
|
use Spatie\EloquentSortable\SortableTrait;
|
||||||
use Spatie\Image\Manipulations;
|
use Spatie\Image\Manipulations;
|
||||||
@@ -24,6 +25,7 @@ class LibraryItem extends Model implements HasMedia, Sortable
|
|||||||
use SortableTrait;
|
use SortableTrait;
|
||||||
use HasStatuses;
|
use HasStatuses;
|
||||||
use HasSlug;
|
use HasSlug;
|
||||||
|
use HasComments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that aren't mass assignable.
|
* The attributes that aren't mass assignable.
|
||||||
@@ -41,14 +43,6 @@ class LibraryItem extends Model implements HasMedia, Sortable
|
|||||||
'library_id' => 'integer',
|
'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()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
static::creating(function ($model) {
|
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
|
public function registerMediaConversions(Media $media = null): void
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
@@ -101,4 +103,26 @@ class LibraryItem extends Model implements HasMedia, Sortable
|
|||||||
{
|
{
|
||||||
return $this->belongsToMany(Library::class);
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,9 @@
|
|||||||
<span class="ml-2">{{ $libraryItem->main_image_caption ?? $libraryItem->name }}</span>
|
<span class="ml-2">{{ $libraryItem->main_image_caption ?? $libraryItem->name }}</span>
|
||||||
</figcaption>
|
</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
|
<div class="my-4">
|
||||||
|
<livewire:comments :model="$libraryItem" newest-first/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-8 lg:mt-0">
|
<div class="mt-8 lg:mt-0">
|
||||||
|
|||||||
Reference in New Issue
Block a user