Skip to content

Commit

Permalink
Format Code
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io authored and github-actions[bot] committed Nov 27, 2024
1 parent 293101b commit 143316a
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 138 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
Expand Down
52 changes: 26 additions & 26 deletions resources/lang/ar/messages.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<?php

return [
"category" => [
"title" => "التصنيفات",
"single" => "التصنيف",
"sections" => [
"details" => [
"title" => "تفاصيل التصنيف",
"description" => "إنشاء تصنيف جديد",
"columns" => [
"name" => "الاسم",
"slug" => "الرابط المختصر",
"description" => "الوصف",
"icon" => "الأيقونة",
"color" => "اللون",
]
'category' => [
'title' => 'التصنيفات',
'single' => 'التصنيف',
'sections' => [
'details' => [
'title' => 'تفاصيل التصنيف',
'description' => 'إنشاء تصنيف جديد',
'columns' => [
'name' => 'الاسم',
'slug' => 'الرابط المختصر',
'description' => 'الوصف',
'icon' => 'الأيقونة',
'color' => 'اللون',
],
],
"status" => [
"title" => "الحالة",
"description" => "إعدادات الحالة",
"columns" => [
"parent_id" => "الأب",
"type" => "النوع",
"for" => "لـ",
"is_active" => "نشط",
"show_in_menu" => "إظهار في القائمة",
]
]
]
'status' => [
'title' => 'الحالة',
'description' => 'إعدادات الحالة',
'columns' => [
'parent_id' => 'الأب',
'type' => 'النوع',
'for' => 'لـ',
'is_active' => 'نشط',
'show_in_menu' => 'إظهار في القائمة',
],
],
],
],
];
52 changes: 26 additions & 26 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<?php

return [
"category" => [
"title" => "Categories",
"single" => "Category",
"sections" => [
"details" => [
"title" => "Category Details",
"description" => "Create a new category",
"columns" => [
"name" => "Name",
"slug" => "Slug",
"description" => "Description",
"icon" => "Icon",
"color" => "Color",
]
'category' => [
'title' => 'Categories',
'single' => 'Category',
'sections' => [
'details' => [
'title' => 'Category Details',
'description' => 'Create a new category',
'columns' => [
'name' => 'Name',
'slug' => 'Slug',
'description' => 'Description',
'icon' => 'Icon',
'color' => 'Color',
],
],
"status" => [
"title" => "Status",
"description" => "Status settings",
"columns" => [
"parent_id" => "Parent",
"type" => "Type",
"for" => "For",
"is_active" => "Is Active",
"show_in_menu" => "Show In Menu",
]
]
]
'status' => [
'title' => 'Status',
'description' => 'Status settings',
'columns' => [
'parent_id' => 'Parent',
'type' => 'Type',
'for' => 'For',
'is_active' => 'Is Active',
'show_in_menu' => 'Show In Menu',
],
],
],
],
];
5 changes: 2 additions & 3 deletions src/Console/FilamentCategoriesInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function __construct()
parent::__construct();
}


/**
* Execute the console command.
*
Expand All @@ -37,8 +36,8 @@ public function __construct()
public function handle()
{
$this->info('Publish Vendor Assets');
$this->artisanCommand(["migrate"]);
$this->artisanCommand(["optimize"]);
$this->artisanCommand(['migrate']);
$this->artisanCommand(['optimize']);
$this->info('Filament Categories installed successfully.');
}
}
61 changes: 29 additions & 32 deletions src/Filament/Resources/CategoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

namespace TomatoPHP\FilamentCategories\Filament\Resources;

use Filament\Resources\Concerns\Translatable;
use Illuminate\Support\Str;
use TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource\Pages;
use TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource\RelationManagers;
use TomatoPHP\FilamentCategories\Models\Category;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Concerns\Translatable;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use TomatoPHP\FilamentCategories\Models\Post;
use Illuminate\Support\Str;
use TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource\Pages;
use TomatoPHP\FilamentCategories\Models\Category;
use TomatoPHP\FilamentCategories\Services\FilamentCMSTypes;
use TomatoPHP\FilamentIcons\Components\IconColumn;
use TomatoPHP\FilamentIcons\Components\IconPicker;
Expand Down Expand Up @@ -63,7 +60,7 @@ public static function form(Form $form): Form
->description(trans('filament-cms::messages.content.category.sections.details.description'))
->schema([
Forms\Components\TextInput::make('name')
->afterStateUpdated( fn(Forms\Get $get, Forms\Set $set)=> $set('slug', Str::of($get('name'))->replace(' ', '-')->lower()->toString()))
->afterStateUpdated(fn (Forms\Get $get, Forms\Set $set) => $set('slug', Str::of($get('name'))->replace(' ', '-')->lower()->toString()))
->label(trans('filament-cms::messages.content.category.sections.details.columns.name'))
->lazy()
->required(),
Expand All @@ -77,7 +74,7 @@ public static function form(Form $form): Form
IconPicker::make('icon')
->label(trans('filament-cms::messages.content.category.sections.details.columns.icon')),
Forms\Components\ColorPicker::make('color')
->label(trans('filament-cms::messages.content.category.sections.details.columns.color'))
->label(trans('filament-cms::messages.content.category.sections.details.columns.color')),
])
->columns(2),
Forms\Components\Section::make(trans('filament-cms::messages.content.posts.sections.images.title'))
Expand Down Expand Up @@ -111,23 +108,23 @@ public static function form(Form $form): Form
->label(trans('filament-cms::messages.content.category.sections.status.columns.for'))
->searchable()
->live()
->options(fn() => FilamentCMSTypes::getOptions()->pluck('label', 'key')->toArray())
->options(fn () => FilamentCMSTypes::getOptions()->pluck('label', 'key')->toArray())
->default('post'),
Forms\Components\Select::make('type')
->hidden(function(Forms\Get $get){
->hidden(function (Forms\Get $get) {
$for = FilamentCMSTypes::getOptions()->where('key', $get('for'))->first();
if($for && count($for->sub)){
if ($for && count($for->sub)) {
return false;
}
})
->label(trans('filament-cms::messages.content.category.sections.status.columns.type'))
->searchable()
->options(fn(Forms\Get $get) => FilamentCMSTypes::getOptions()->where('key', $get('for'))->first()?->getSub()->pluck('label', 'key')->toArray())
->options(fn (Forms\Get $get) => FilamentCMSTypes::getOptions()->where('key', $get('for'))->first()?->getSub()->pluck('label', 'key')->toArray())
->default('category'),
Forms\Components\Select::make('parent_id')
->label(trans('filament-cms::messages.content.category.sections.status.columns.parent_id'))
->searchable()
->options(fn() => Category::query()->pluck('name', 'id')->toArray()),
->options(fn () => Category::query()->pluck('name', 'id')->toArray()),
Forms\Components\Toggle::make('is_active')
->label(trans('filament-cms::messages.content.category.sections.status.columns.is_active')),
Forms\Components\Toggle::make('show_in_menu')
Expand All @@ -137,8 +134,8 @@ public static function form(Form $form): Form
'sm' => 1,
'md' => 2,
'lg' => 4,
])
])
]),
]),
]);
}

Expand All @@ -148,35 +145,35 @@ public static function table(Table $table): Table
->columns([
Tables\Columns\SpatieMediaLibraryImageColumn::make('feature_image')
->label(trans('filament-cms::messages.content.posts.sections.images.columns.feature_image'))
->defaultImageUrl(fn(Category $category)=> 'https://ui-avatars.com/api/?name='.Str::of($category->slug)->replace('-','+').'&color=FFFFFF&background=020617')
->defaultImageUrl(fn (Category $category) => 'https://ui-avatars.com/api/?name=' . Str::of($category->slug)->replace('-', '+') . '&color=FFFFFF&background=020617')
->square()
->collection('feature_image'),
Tables\Columns\TextColumn::make('name')
->description(fn(Category $category)=> Str::of($category->description)->limit(50))
->description(fn (Category $category) => Str::of($category->description)->limit(50))
->label(trans('filament-cms::messages.content.category.sections.details.columns.name'))
->searchable(),
Tables\Columns\TextColumn::make('for')
->state(function (Category $category){
->state(function (Category $category) {
return FilamentCMSTypes::getOptions()->where('key', $category->for)->first()?->label;
})
->color(function (Category $category){
->color(function (Category $category) {
return FilamentCMSTypes::getOptions()->where('key', $category->for)->first()?->color;
})
->icon(function (Category $category){
->icon(function (Category $category) {
return FilamentCMSTypes::getOptions()->where('key', $category->for)->first()?->icon;
})
->badge()
->sortable()
->label(trans('filament-cms::messages.content.category.sections.status.columns.for'))
->searchable(),
Tables\Columns\TextColumn::make('type')
->state(function (Category $category){
->state(function (Category $category) {
return FilamentCMSTypes::getOptions()->where('key', $category->for)->first()?->getSub()->where('key', $category->type)->first()?->label;
})
->color(function (Category $category){
->color(function (Category $category) {
return FilamentCMSTypes::getOptions()->where('key', $category->for)->first()?->getSub()->where('key', $category->type)->first()?->color;
})
->icon(function (Category $category){
->icon(function (Category $category) {
return FilamentCMSTypes::getOptions()->where('key', $category->for)->first()?->getSub()->where('key', $category->type)->first()?->icon;
})
->badge()
Expand Down Expand Up @@ -217,29 +214,29 @@ public static function table(Table $table): Table
->label(trans('filament-cms::messages.content.category.sections.status.columns.for'))
->searchable()
->live()
->options(fn() => FilamentCMSTypes::getOptions()->pluck('label', 'key')->toArray()),
->options(fn () => FilamentCMSTypes::getOptions()->pluck('label', 'key')->toArray()),
Forms\Components\Select::make('type')
->hidden(function(Forms\Get $get){
->hidden(function (Forms\Get $get) {
$for = FilamentCMSTypes::getOptions()->where('key', $get('for'))->first();
if($for && count($for->sub)){
if ($for && count($for->sub)) {
return false;
}
})
->label(trans('filament-cms::messages.content.category.sections.status.columns.type'))
->searchable()
->options(fn(Forms\Get $get) => FilamentCMSTypes::getOptions()->where('key', $get('for'))->first()?->getSub()->pluck('label', 'key')->toArray()),
->options(fn (Forms\Get $get) => FilamentCMSTypes::getOptions()->where('key', $get('for'))->first()?->getSub()->pluck('label', 'key')->toArray()),

])
->query(function (Builder $query, array $data){
->query(function (Builder $query, array $data) {
$query->when(
$data['for'],
fn(Builder $query, $for) => $query->where('for', $for)
fn (Builder $query, $for) => $query->where('for', $for)
)->when(
$data['type'],
fn(Builder $query, $type) => $query->where('type', $type)
fn (Builder $query, $type) => $query->where('type', $type)
);
}),
Tables\Filters\TrashedFilter::make()
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource\Pages;

use TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource;

class CreateCategory extends CreateRecord
{
Expand All @@ -15,7 +15,7 @@ class CreateCategory extends CreateRecord
protected function getHeaderActions(): array
{
return [
Actions\LocaleSwitcher::make()
Actions\LocaleSwitcher::make(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

namespace TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource\Pages;

use TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource;

class EditCategory extends EditRecord
{
use EditRecord\Concerns\Translatable;

protected static string $resource = CategoryResource::class;


protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
Actions\LocaleSwitcher::make()
Actions\LocaleSwitcher::make(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

namespace TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource\Pages;

use TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use TomatoPHP\FilamentCategories\Filament\Resources\CategoryResource;

class ListCategories extends ListRecords
{
use ListRecords\Concerns\Translatable;

protected static string $resource = CategoryResource::class;


protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
Actions\LocaleSwitcher::make()
Actions\LocaleSwitcher::make(),
];
}
}
1 change: 0 additions & 1 deletion src/FilamentCategoriesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class FilamentCategoriesPlugin implements Plugin
{

public function getId(): string
{
return 'filament-categories';
Expand Down
Loading

0 comments on commit 143316a

Please sign in to comment.