feat: tambah modul blog dengan resource Filament, halaman publik, dan PostSeeder

This commit is contained in:
2026-04-03 05:18:34 +07:00
parent 2646adf160
commit 3339a45243
16 changed files with 413 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;
class Post extends Model
{
protected $fillable = ['title', 'slug', 'category', 'content', 'author_id', 'published_at'];
protected $casts = ['published_at' => 'datetime'];
protected static function booted(): void
{
static::creating(function (Post $post) {
$post->slug ??= Str::slug($post->title);
});
}
public function author(): BelongsTo
{
return $this->belongsTo(User::class, 'author_id');
}
public function scopePublished($query)
{
return $query->whereNotNull('published_at')->where('published_at', '<=', now());
}
}