feat: add category management
associate with entries and text widgets
This commit is contained in:
parent
c83028b4d4
commit
9b9e1a8e29
22 changed files with 392 additions and 46 deletions
10
app/Models/Category.php
Normal file
10
app/Models/Category.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
protected $fillable = ['name'];
|
||||
}
|
||||
|
|
@ -7,20 +7,19 @@ use Filament\Forms\Components\RichEditor\Models\Concerns\InteractsWithRichConten
|
|||
use Filament\Forms\Components\RichEditor\Models\Contracts\HasRichContent;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\Tags\HasTags;
|
||||
|
||||
/*
|
||||
/*
|
||||
Entry model with rich content and media library integration
|
||||
This is the main article / blog rich content model
|
||||
*/
|
||||
class Entry extends Model implements HasRichContent, HasMedia
|
||||
|
||||
class Entry extends Model implements HasMedia, HasRichContent
|
||||
{
|
||||
|
||||
use InteractsWithMedia, InteractsWithRichContent, HasFactory, HasTags;
|
||||
use HasFactory, HasTags, InteractsWithMedia, InteractsWithRichContent;
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
|
|
@ -30,9 +29,9 @@ class Entry extends Model implements HasRichContent, HasMedia
|
|||
'is_featured',
|
||||
'published_at',
|
||||
'content',
|
||||
'category_id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Set up rich content configuration for media library integration
|
||||
*/
|
||||
|
|
@ -56,4 +55,9 @@ class Entry extends Model implements HasRichContent, HasMedia
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class TextWidget extends Model
|
||||
{
|
||||
|
|
@ -13,5 +14,11 @@ class TextWidget extends Model
|
|||
'title',
|
||||
'description',
|
||||
'content',
|
||||
'category_id',
|
||||
];
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue