You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 More fixes 🆙
This commit is contained in:
@@ -2,16 +2,17 @@
|
||||
|
||||
namespace App\Models\Articles;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function websiteArticles()
|
||||
/**
|
||||
* @return MorphToMany<WebsiteArticle, $this>
|
||||
*/
|
||||
public function websiteArticles(): MorphToMany
|
||||
{
|
||||
return $this->morphedByMany(WebsiteArticle::class, 'taggable');
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -11,11 +11,17 @@ class WebsiteArticleComment extends Model
|
||||
{
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo<WebsiteArticle, $this>
|
||||
*/
|
||||
public function article(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WebsiteArticle::class, 'article_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
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;
|
||||
@@ -34,15 +31,22 @@ class WebsiteArticleReaction extends Model
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model): void {
|
||||
$model->user_id = auth()->id();
|
||||
/** @var WebsiteArticleReaction $model */
|
||||
$model->user_id = (int) auth()->id();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<WebsiteArticle, $this>
|
||||
*/
|
||||
public function article(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WebsiteArticle::class, 'article_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
@@ -2,25 +2,29 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ChatlogPrivate extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'chatlogs_private';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function sender(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_from_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function receiver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_to_id');
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Game\Room;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ChatlogRoom extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'chatlogs_room';
|
||||
|
||||
protected $guarded = [];
|
||||
@@ -18,17 +17,26 @@ class ChatlogRoom extends Model
|
||||
|
||||
protected $primaryKey = 'timestamp';
|
||||
|
||||
public function room()
|
||||
/**
|
||||
* @return BelongsTo<Room, $this>
|
||||
*/
|
||||
public function room(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Room::class);
|
||||
}
|
||||
|
||||
public function sender()
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function sender(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_from_id');
|
||||
}
|
||||
|
||||
public function receiver()
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function receiver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_to_id');
|
||||
}
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CommandLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'commandlogs';
|
||||
|
||||
protected $primaryKey = 'timestamp';
|
||||
@@ -18,6 +16,9 @@ class CommandLog extends Model
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
@@ -17,11 +17,17 @@ class WebsiteRareValue extends Model
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<WebsiteRareValueCategory, $this>
|
||||
*/
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WebsiteRareValueCategory::class, 'category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<CatalogItem, $this>
|
||||
*/
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CatalogItem::class, 'item_id', 'item_ids');
|
||||
|
||||
@@ -9,6 +9,9 @@ class WebsiteRareValueCategory extends Model
|
||||
{
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* @return HasMany<WebsiteRareValue, $this>
|
||||
*/
|
||||
public function furniture(): HasMany
|
||||
{
|
||||
return $this->hasMany(WebsiteRareValue::class, 'category_id');
|
||||
|
||||
@@ -19,11 +19,17 @@ class WebsiteStaffApplications extends Model
|
||||
'content',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Permission, $this>
|
||||
*/
|
||||
public function rank(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Permission::class, 'rank_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
|
||||
Reference in New Issue
Block a user