Refactor and localize settings and resources
- Updated GeneralSettings page to include localized labels and structured sections for better organization. - Enhanced CarouselSlide, Category, Collection, and Product resources with localized model labels and improved form/table configurations. - Modified HomeController to utilize query builder for better performance and added collection items retrieval. - Updated views to reflect localized settings and improved layout for collections and footer. - Adjusted timezone and locale settings in app configuration for better regional support.
This commit is contained in:
@@ -2,15 +2,20 @@
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Pages\SettingsPage;
|
||||
use App\Settings\GeneralSettings as Settings;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Pages\SettingsPage;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class GeneralSettings extends SettingsPage
|
||||
{
|
||||
protected static ?string $navigationLabel = 'Umumy Sazlamalar';
|
||||
|
||||
protected static ?string $title = 'Umumy Sazlamalar';
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-cog-6-tooth';
|
||||
|
||||
protected static string $settings = Settings::class;
|
||||
@@ -19,22 +24,57 @@ class GeneralSettings extends SettingsPage
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('marquee_text')
|
||||
->required(),
|
||||
TextInput::make('about_title')
|
||||
->required(),
|
||||
Textarea::make('about_text')
|
||||
->required(),
|
||||
FileUpload::make('about_image')
|
||||
->image()
|
||||
->visibility('public')
|
||||
->directory('settings'),
|
||||
Textarea::make('footer_address')
|
||||
->required(),
|
||||
TextInput::make('footer_phone')
|
||||
->required(),
|
||||
TextInput::make('footer_copyright')
|
||||
->required(),
|
||||
Section::make('Umumy')->schema([
|
||||
TextInput::make('site_title')
|
||||
->label('Saýdyň ady')
|
||||
->required(),
|
||||
TextInput::make('marquee_text')
|
||||
->label('Hereketli tekst')
|
||||
->required(),
|
||||
]),
|
||||
|
||||
Section::make('Biz barada')->schema([
|
||||
TextInput::make('about_label')
|
||||
->label('Biz barada kiçi tekst')
|
||||
->required(),
|
||||
TextInput::make('about_title')
|
||||
->label('Biz barada sözbaşy')
|
||||
->required(),
|
||||
Textarea::make('about_text')
|
||||
->label('Biz barada tekst')
|
||||
->required(),
|
||||
FileUpload::make('about_image')
|
||||
->label('Biz barada surat')
|
||||
->image()
|
||||
->visibility('public')
|
||||
->directory('settings'),
|
||||
]),
|
||||
|
||||
Section::make('Sosial torlar we Bizi tapyň')->schema([
|
||||
TextInput::make('find_us_label')
|
||||
->label('Bizi tapyň ýarlyk')
|
||||
->required(),
|
||||
TextInput::make('instagram_url')
|
||||
->label('Instagram URL')
|
||||
->url()
|
||||
->required(),
|
||||
TextInput::make('tiktok_url')
|
||||
->label('TikTok URL')
|
||||
->url()
|
||||
->required(),
|
||||
]),
|
||||
|
||||
Section::make('Podwal')->schema([
|
||||
Textarea::make('footer_address')
|
||||
->label('Podwal salgysy')
|
||||
->required(),
|
||||
TextInput::make('footer_phone')
|
||||
->label('Podwal telefony')
|
||||
->required(),
|
||||
TextInput::make('footer_copyright')
|
||||
->label('Podwal awtorlyk hukugy')
|
||||
->required(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,11 @@ class CarouselSlideResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CarouselSlide::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
protected static ?string $modelLabel = 'Karusel';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Karuseller';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-photo';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -14,17 +14,22 @@ class CarouselSlideForm
|
||||
return $schema
|
||||
->components([
|
||||
FileUpload::make('image')
|
||||
->label('Surat')
|
||||
->image()
|
||||
->visibility('public')
|
||||
->required(),
|
||||
|
||||
TextInput::make('title'),
|
||||
TextInput::make('subtitle'),
|
||||
TextInput::make('title')
|
||||
->label('Sözbaşy'),
|
||||
TextInput::make('subtitle')
|
||||
->label('Sözbaşy asty'),
|
||||
TextInput::make('order')
|
||||
->label('Tertibi')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
Toggle::make('is_active')
|
||||
->label('Işjeňmi')
|
||||
->default(true)
|
||||
->required(),
|
||||
]);
|
||||
|
||||
@@ -16,21 +16,28 @@ class CarouselSlidesTable
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
ImageColumn::make('image'),
|
||||
ImageColumn::make('image')
|
||||
->label('Surat'),
|
||||
TextColumn::make('title')
|
||||
->label('Sözbaşy')
|
||||
->searchable(),
|
||||
TextColumn::make('subtitle')
|
||||
->label('Sözbaşy asty')
|
||||
->searchable(),
|
||||
TextColumn::make('order')
|
||||
->label('Tertibi')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
IconColumn::make('is_active')
|
||||
->label('Işjeňmi')
|
||||
->boolean(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Döredilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Üýtgedilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -18,7 +18,11 @@ class CategoryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Category::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
protected static ?string $modelLabel = 'Kategoriýa';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Kategoriýalar';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-tag';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -12,9 +12,12 @@ class CategoryForm
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label('Ady')
|
||||
->required(),
|
||||
TextInput::make('icon'),
|
||||
TextInput::make('icon')
|
||||
->label('Ikonkasy'),
|
||||
TextInput::make('order')
|
||||
->label('Tertibi')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
|
||||
@@ -15,17 +15,22 @@ class CategoriesTable
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label('Ady')
|
||||
->searchable(),
|
||||
TextColumn::make('icon')
|
||||
->label('Ikonkasy')
|
||||
->searchable(),
|
||||
TextColumn::make('order')
|
||||
->label('Tertibi')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Döredilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Üýtgedilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -11,14 +11,17 @@ use App\Models\Collection;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CollectionResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Collection::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
protected static ?string $modelLabel = 'Kolleksiýa';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Kolleksiýalar';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-rectangle-group';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -33,7 +36,7 @@ class CollectionResource extends Resource
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
RelationManagers\CollectionItemsRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Collections\RelationManagers;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CollectionItemsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'collectionItems';
|
||||
|
||||
protected static ?string $title = 'Kolleksiýa elementleri';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->columns(4)
|
||||
->components([
|
||||
TextInput::make('title')
|
||||
->label('Sözbaşy')
|
||||
->required(),
|
||||
TextInput::make('subtitle')
|
||||
->label('Sözbaşy asty'),
|
||||
TextInput::make('order')
|
||||
->label('Tertibi')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
Toggle::make('is_active')
|
||||
->label('Işjeňmi')
|
||||
->default(true)
|
||||
->required(),
|
||||
FileUpload::make('image')
|
||||
->label('Suraty')
|
||||
->image()
|
||||
->visibility('public')
|
||||
->columnSpan(2),
|
||||
]);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('title')
|
||||
->columns([
|
||||
ImageColumn::make('image')
|
||||
->label('Suraty'),
|
||||
TextColumn::make('title')
|
||||
->label('Sözbaşy')
|
||||
->searchable(),
|
||||
TextColumn::make('subtitle')
|
||||
->label('Sözbaşy asty')
|
||||
->searchable(),
|
||||
TextColumn::make('order')
|
||||
->label('Tertibi')
|
||||
->sortable(),
|
||||
ToggleColumn::make('is_active')
|
||||
->label('Işjeňmi'),
|
||||
])
|
||||
->defaultSort('order')
|
||||
->reorderable('order')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Filament\Resources\Collections\Schemas;
|
||||
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -14,16 +13,18 @@ class CollectionForm
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('title')
|
||||
->label('Sözbaşy')
|
||||
->required(),
|
||||
TextInput::make('subtitle'),
|
||||
FileUpload::make('image')
|
||||
->image()
|
||||
->visibility('public'),
|
||||
TextInput::make('subtitle')
|
||||
->label('Sözbaşy asty'),
|
||||
TextInput::make('order')
|
||||
->label('Tertibi')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
Toggle::make('is_active')
|
||||
->label('Işjeňmi')
|
||||
->default(true)
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
@@ -17,20 +16,25 @@ class CollectionsTable
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('title')
|
||||
->label('Sözbaşy')
|
||||
->searchable(),
|
||||
TextColumn::make('subtitle')
|
||||
->label('Sözbaşy asty')
|
||||
->searchable(),
|
||||
ImageColumn::make('image'),
|
||||
TextColumn::make('order')
|
||||
->label('Tertibi')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
IconColumn::make('is_active')
|
||||
->label('Işjeňmi')
|
||||
->boolean(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Döredilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Üýtgedilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -18,7 +18,11 @@ class ProductResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Product::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
protected static ?string $modelLabel = 'Önüm';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Önümler';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-shopping-bag';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -16,20 +16,27 @@ class ProductForm
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('category_id')
|
||||
->label('Kategoriýasy')
|
||||
->relationship('category', 'name')
|
||||
->required(),
|
||||
TextInput::make('name')
|
||||
->label('Ady')
|
||||
->required(),
|
||||
Textarea::make('description')
|
||||
->label('Düşündirişi')
|
||||
->columnSpanFull(),
|
||||
TextInput::make('price')
|
||||
->label('Bahasy')
|
||||
->required()
|
||||
->numeric()
|
||||
->prefix('$'),
|
||||
->suffix('TMT'),
|
||||
FileUpload::make('image')
|
||||
->label('Suraty')
|
||||
->image()
|
||||
->visibility('public'),
|
||||
Toggle::make('is_active')
|
||||
->label('Işjeňmi')
|
||||
->default(true)
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -17,20 +17,27 @@ class ProductsTable
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('category.name')
|
||||
->label('Kategoriýasy')
|
||||
->searchable(),
|
||||
TextColumn::make('name')
|
||||
->label('Ady')
|
||||
->searchable(),
|
||||
TextColumn::make('price')
|
||||
->money()
|
||||
->label('Bahasy')
|
||||
->money('TMT')
|
||||
->sortable(),
|
||||
ImageColumn::make('image'),
|
||||
ImageColumn::make('image')
|
||||
->label('Suraty'),
|
||||
IconColumn::make('is_active')
|
||||
->label('Işjeňmi')
|
||||
->boolean(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Döredilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Üýtgedilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -13,10 +13,12 @@ class HomeController extends Controller
|
||||
{
|
||||
public function __invoke(GeneralSettings $settings)
|
||||
{
|
||||
$slides = CarouselSlide::where('is_active', true)->orderBy('order')->get();
|
||||
$collections = Collection::where('is_active', true)->orderBy('order')->get();
|
||||
$categories = Category::orderBy('order')->get();
|
||||
$products = Product::with('category')->where('is_active', true)->get();
|
||||
$slides = CarouselSlide::query()->where('is_active', true)->orderBy('order')->get();
|
||||
$collections = Collection::with(['collectionItems' => function ($query) {
|
||||
$query->where('is_active', true)->orderBy('order');
|
||||
}])->where('is_active', true)->orderBy('order')->get();
|
||||
$categories = Category::query()->orderBy('order')->get();
|
||||
$products = Product::query()->with('category')->where('is_active', true)->get();
|
||||
|
||||
return view('home', compact('slides', 'collections', 'categories', 'products', 'settings'));
|
||||
}
|
||||
|
||||
@@ -3,18 +3,14 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Collection extends Model
|
||||
{
|
||||
protected $fillable = ['title', 'subtitle', 'image', 'order', 'is_active'];
|
||||
protected $fillable = ['title', 'subtitle', 'order', 'is_active'];
|
||||
|
||||
protected static function booted(): void
|
||||
public function collectionItems(): HasMany
|
||||
{
|
||||
static::deleting(function (Collection $collection) {
|
||||
if ($collection->image) {
|
||||
Storage::disk('public')->delete($collection->image);
|
||||
}
|
||||
});
|
||||
return $this->hasMany(CollectionItem::class);
|
||||
}
|
||||
}
|
||||
|
||||
26
app/Models/CollectionItem.php
Normal file
26
app/Models/CollectionItem.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class CollectionItem extends Model
|
||||
{
|
||||
protected $fillable = ['collection_id', 'title', 'subtitle', 'image', 'order', 'is_active'];
|
||||
|
||||
public function collection(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Collection::class);
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::deleting(function (CollectionItem $item) {
|
||||
if ($item->image) {
|
||||
Storage::disk('public')->delete($item->image);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,15 @@ use Spatie\LaravelSettings\Settings;
|
||||
|
||||
class GeneralSettings extends Settings
|
||||
{
|
||||
public string $site_title;
|
||||
public string $marquee_text;
|
||||
public string $about_label;
|
||||
public string $about_title;
|
||||
public string $about_text;
|
||||
public string $about_image;
|
||||
public string $find_us_label;
|
||||
public string $instagram_url;
|
||||
public string $tiktok_url;
|
||||
public string $footer_address;
|
||||
public string $footer_phone;
|
||||
public string $footer_copyright;
|
||||
|
||||
Reference in New Issue
Block a user