🆙 Final fix delete storage link to fix news_images and logs 🆙

This commit is contained in:
Remco
2026-01-07 20:29:24 +01:00
parent 65ea6c167f
commit acf2d7e661
447 changed files with 208 additions and 66965 deletions
-18
View File
@@ -1,18 +0,0 @@
<?php
namespace App\Models\Articles;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Tag extends Model
{
use HasFactory;
protected $guarded = [];
public function websiteArticles()
{
return $this->morphedByMany(WebsiteArticle::class, 'taggable');
}
}
@@ -1,65 +0,0 @@
<?php
namespace App\Models\Articles;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Auth;
use Spatie\Sluggable\HasSlug;
use Spatie\Sluggable\SlugOptions;
class WebsiteArticle extends Model
{
use HasSlug, SoftDeletes;
protected $guarded = ['id'];
public function getSlugOptions(): SlugOptions
{
return SlugOptions::create()
->generateSlugsFrom('title')
->saveSlugsTo('slug')
->usingSeparator('-')->allowDuplicateSlugs();
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function reactions(): HasMany
{
return $this->hasMany(WebsiteArticleReaction::class, 'article_id')
->whereActive(true);
}
public function comments(): HasMany
{
return $this->hasMany(WebsiteArticleComment::class, 'article_id');
}
public function userHasReachedArticleCommentLimit(): bool
{
return $this->comments()->where('user_id', '=', Auth::id())->count() >= (int) setting('max_comment_per_article');
}
#[\Override]
protected static function boot()
{
parent::boot();
static::saving(function ($model): void {
if (empty($model->image)) {
$model->image = '';
}
});
}
public function tags()
{
return $this->morphToMany(Tag::class, 'taggable');
}
}
@@ -1,28 +0,0 @@
<?php
namespace App\Models\Articles;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Auth;
class WebsiteArticleComment extends Model
{
protected $guarded = ['id', 'created_at', 'updated_at'];
public function article(): BelongsTo
{
return $this->belongsTo(WebsiteArticle::class, 'article_id');
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function canBeDeleted(): bool
{
return $this->user_id === Auth::id() || hasPermission('delete_article_comments');
}
}
@@ -1,50 +0,0 @@
<?php
namespace App\Models\Articles;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class WebsiteArticleReaction extends Model
{
use HasFactory;
protected $guarded = [];
public $timestamps = false;
protected $hidden = [
'user_id',
'article_id',
];
public static function getReaction(int $articleId, int $userId, string $reaction): ?self
{
return self::where('user_id', $userId)
->where('article_id', $articleId)
->where('reaction', $reaction)
->first();
}
#[\Override]
public static function boot()
{
parent::boot();
static::creating(function ($model): void {
$model->user_id = auth()->id();
});
}
public function article(): BelongsTo
{
return $this->belongsTo(WebsiteArticle::class, 'article_id');
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}