You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 More fixes 🆙
This commit is contained in:
@@ -6,6 +6,8 @@ use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use App\Models\Articles\Tag;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Spatie\Sluggable\HasSlug;
|
||||
@@ -25,17 +27,26 @@ class WebsiteArticle extends Model
|
||||
->usingSeparator('-')->allowDuplicateSlugs();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<WebsiteArticleReaction, $this>
|
||||
*/
|
||||
public function reactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebsiteArticleReaction::class, 'article_id')
|
||||
->whereActive(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<WebsiteArticleComment, $this>
|
||||
*/
|
||||
public function comments(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebsiteArticleComment::class, 'article_id');
|
||||
@@ -52,13 +63,17 @@ class WebsiteArticle extends Model
|
||||
parent::boot();
|
||||
|
||||
static::saving(function ($model): void {
|
||||
/** @var WebsiteArticle $model */
|
||||
if (empty($model->image)) {
|
||||
$model->image = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function tags()
|
||||
/**
|
||||
* @return MorphToMany<Tag, $this>
|
||||
*/
|
||||
public function tags(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany(Tag::class, 'taggable');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user