Skip to content

Commit

Permalink
Merge pull request #14 from lara-zeus/TagType
Browse files Browse the repository at this point in the history
configurable tag type
  • Loading branch information
atmonshi authored Mar 23, 2024
2 parents aedfa2f + 56327e3 commit 52ab7c2
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 44 deletions.
68 changes: 34 additions & 34 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ trait Configuration

protected array $tartarusModels = [
'Company' => \LaraZeus\Tartarus\Models\Company::class,
'TagType' => \LaraZeus\Tartarus\Enums\TagTypes::class,
];

public function navigationGroupLabel(Closure | string $label): static
Expand Down
4 changes: 1 addition & 3 deletions src/Enums/TagTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

enum TagTypes: string implements HasLabel
{
case TestType = 'Test Type';

case CustomerCategories = 'Customer Categories';
case TestType = 'Tag';

public function getLabel(): ?string
{
Expand Down
6 changes: 3 additions & 3 deletions src/Filament/Clusters/System/Resources/TagResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
use Illuminate\Support\Str;
use LaraZeus\Chaos\Filament\ChaosResource;
use LaraZeus\Chaos\Forms\Components\MultiLang;
use LaraZeus\Tartarus\Enums\TagTypes;
use LaraZeus\Tartarus\Filament\Clusters\System;
use LaraZeus\Tartarus\Filament\Clusters\System\Resources\TagResource\Pages;
use LaraZeus\Tartarus\TartarusPlugin;
use Spatie\Tags\Tag;

class TagResource extends ChaosResource
Expand Down Expand Up @@ -54,7 +54,7 @@ public static function form(Form $form): Form
Select::make('type')
->label(__(static::langFile() . '.type'))
->columnSpan(2)
->options(TagTypes::class),
->options(TartarusPlugin::getModel('TagType')),
]),
]
);
Expand Down Expand Up @@ -96,7 +96,7 @@ function (Tag $record): int {
],
filters: [
SelectFilter::make('type')
->options(TagTypes::class)
->options(TartarusPlugin::getModel('TagType'))
->label(__(static::langFile() . 'type')),
]
);
Expand Down
11 changes: 7 additions & 4 deletions src/Models/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@

use Illuminate\Database\Eloquent\SoftDeletes;
use LaraZeus\Chaos\Concerns\ChaosModel;
use LaraZeus\Tartarus\Enums\TagTypes;
use LaraZeus\Tartarus\Models\Concerns\ForCompany;
use LaraZeus\Tartarus\TartarusPlugin;

class Tag extends \Spatie\Tags\Tag
{
use ChaosModel;
use ForCompany;
use SoftDeletes;

protected $casts = [
'type' => TagTypes::class,
];
public function getCasts(): array
{
return [
'type' => TartarusPlugin::getModel('TagType'),
];
}
}

0 comments on commit 52ab7c2

Please sign in to comment.