diff --git a/config/zeus-sky.php b/config/zeus-sky.php
index 3b94027..7d4bb09 100644
--- a/config/zeus-sky.php
+++ b/config/zeus-sky.php
@@ -123,6 +123,7 @@
'tag' => 'Tag',
'category' => 'Category',
'library' => 'Library',
+ 'faq' => 'faq',
],
/**
diff --git a/resources/lang/ar.json b/resources/lang/ar.json
index 8cf237b..b98ca94 100644
--- a/resources/lang/ar.json
+++ b/resources/lang/ar.json
@@ -77,5 +77,6 @@
"Library File": "ملف المكتبة",
"file url": "رابط الملف",
"Send": "ارسال",
- "sorry, the password incorrect!": "عفوا، كلمة المرور غير صحيحة"
+ "sorry, the password incorrect!": "عفوا، كلمة المرور غير صحيحة",
+ "FAQ Categories": "التصنيفات"
}
diff --git a/resources/views/filament/columns/tag-counts.blade.php b/resources/views/filament/columns/tag-counts.blade.php
new file mode 100644
index 0000000..70af7c9
--- /dev/null
+++ b/resources/views/filament/columns/tag-counts.blade.php
@@ -0,0 +1,3 @@
+
+ {{ $getRecord()->{$getRecord()->type}()->count() }}
+
\ No newline at end of file
diff --git a/src/Filament/Resources/FaqResource.php b/src/Filament/Resources/FaqResource.php
index c9396be..4bc5707 100644
--- a/src/Filament/Resources/FaqResource.php
+++ b/src/Filament/Resources/FaqResource.php
@@ -3,13 +3,16 @@
namespace LaraZeus\Sky\Filament\Resources;
use Filament\Forms\Components\RichEditor;
+use Filament\Forms\Components\SpatieTagsInput;
use Filament\Forms\Components\Textarea;
use Filament\Resources\Form;
use Filament\Resources\Table;
use Filament\Tables\Actions\ActionGroup;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\EditAction;
+use Filament\Tables\Columns\SpatieTagsColumn;
use Filament\Tables\Columns\TextColumn;
+use Filament\Tables\Filters\SelectFilter;
use LaraZeus\Sky\Filament\Resources\FaqResource\Pages;
use LaraZeus\Sky\Models\Faq;
@@ -57,6 +60,10 @@ public static function form(Form $form): Form
->required()
->maxLength(65535)
->columnSpan(2),
+
+ SpatieTagsInput::make('category')
+ ->type('faq')
+ ->label(__('FAQ Categories')),
]);
}
@@ -65,6 +72,17 @@ public static function table(Table $table): Table
return $table
->columns([
TextColumn::make('question')->searchable(),
+
+ SpatieTagsColumn::make('tags')
+ ->label(__('FAQ Categories'))
+ ->toggleable()
+ ->type('faq'),
+ ])
+ ->filters([
+ SelectFilter::make('tags')
+ ->multiple()
+ ->relationship('tags', 'name')
+ ->label(__('Tags')),
])
->actions([
ActionGroup::make([
diff --git a/src/Filament/Resources/TagResource.php b/src/Filament/Resources/TagResource.php
index 1512cc3..114df45 100644
--- a/src/Filament/Resources/TagResource.php
+++ b/src/Filament/Resources/TagResource.php
@@ -62,7 +62,9 @@ public static function table(Table $table): Table
TextColumn::make('name')->toggleable()->searchable()->sortable(),
TextColumn::make('type')->toggleable()->searchable()->sortable(),
TextColumn::make('slug')->toggleable()->searchable()->sortable(),
- TextColumn::make('posts_count')->counts('posts')->toggleable()->searchable()->sortable(),
+ TextColumn::make('items_count')
+ ->toggleable()
+ ->view('zeus-sky::filament.columns.tag-counts'),
])
->filters([
SelectFilter::make('type')
diff --git a/src/Models/Faq.php b/src/Models/Faq.php
index 0b6a8ae..30eab4a 100644
--- a/src/Models/Faq.php
+++ b/src/Models/Faq.php
@@ -3,11 +3,13 @@
namespace LaraZeus\Sky\Models;
use Illuminate\Database\Eloquent\Model;
+use Spatie\Tags\HasTags;
use Spatie\Translatable\HasTranslations;
class Faq extends Model
{
use HasTranslations;
+ use HasTags;
public $translatable = [
'question',
diff --git a/src/Models/Tag.php b/src/Models/Tag.php
index 982b357..e00e8f7 100644
--- a/src/Models/Tag.php
+++ b/src/Models/Tag.php
@@ -19,6 +19,16 @@ public function library()
return $this->morphedByMany(config('zeus-sky.models.library'), 'taggable');
}
+ public function category()
+ {
+ return $this->morphedByMany(config('zeus-sky.models.post'), 'taggable');
+ }
+
+ public function faq()
+ {
+ return $this->morphedByMany(config('zeus-sky.models.faq'), 'taggable');
+ }
+
public function postsPublished()
{
return $this->morphedByMany(config('zeus-sky.models.post'), 'taggable')->published();