webseite funktioniert, pay sdk, blog backend funktioniert
This commit is contained in:
@@ -2,16 +2,21 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Spatie\Translatable\HasTranslations;
|
||||
use Stephenjude\FilamentBlog\Models\Post as BasePost;
|
||||
|
||||
class BlogPost extends BasePost
|
||||
class BlogPost extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, HasTranslations;
|
||||
|
||||
protected $table = 'blog_posts';
|
||||
|
||||
protected $translatable = [
|
||||
'title',
|
||||
'excerpt',
|
||||
@@ -21,7 +26,6 @@ class BlogPost extends BasePost
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'blog_author_id',
|
||||
'blog_category_id',
|
||||
'slug',
|
||||
'banner',
|
||||
@@ -29,4 +33,33 @@ class BlogPost extends BasePost
|
||||
'is_published',
|
||||
'translations',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'published_at' => 'date',
|
||||
'is_published' => 'boolean',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'banner_url',
|
||||
];
|
||||
|
||||
public function bannerUrl(): Attribute
|
||||
{
|
||||
return Attribute::get(fn () => $this->banner ? asset(Storage::url($this->banner)) : '');
|
||||
}
|
||||
|
||||
public function scopePublished(Builder $query)
|
||||
{
|
||||
return $query->whereNotNull('published_at')->where('is_published', true);
|
||||
}
|
||||
|
||||
public function scopeDraft(Builder $query)
|
||||
{
|
||||
return $query->whereNull('published_at');
|
||||
}
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BlogCategory::class, 'blog_category_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user