Auth: convert auth views and verification email to Nova layout
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ForumThread extends Model
|
||||
@@ -18,16 +21,43 @@ class ForumThread extends Model
|
||||
public $incrementing = true;
|
||||
|
||||
protected $casts = [
|
||||
'is_locked' => 'boolean',
|
||||
'is_pinned' => 'boolean',
|
||||
'last_post_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function category()
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ForumCategory::class, 'category_id');
|
||||
}
|
||||
|
||||
public function posts()
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function posts(): HasMany
|
||||
{
|
||||
return $this->hasMany(ForumPost::class, 'thread_id');
|
||||
}
|
||||
|
||||
public function scopeVisible(Builder $query): Builder
|
||||
{
|
||||
return $query->where('visibility', 'public');
|
||||
}
|
||||
|
||||
public function scopePinned(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_pinned', true);
|
||||
}
|
||||
|
||||
public function scopeRecent(Builder $query): Builder
|
||||
{
|
||||
return $query->orderByDesc('last_post_at')->orderByDesc('id');
|
||||
}
|
||||
|
||||
public function scopeInCategory(Builder $query, int $categoryId): Builder
|
||||
{
|
||||
return $query->where('category_id', $categoryId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user