feat: Add Logos page, refactor Testimonials to RelationManager, and improve designs
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\Pages\RelationManagers;
|
||||
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TestimonialsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'testimonials';
|
||||
|
||||
protected static ?string $title = 'Müşteri Görüşleri';
|
||||
|
||||
protected static ?string $modelLabel = 'Müşteri Görüşü';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Müşteri Görüşleri';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function canViewForRecord(\Illuminate\Database\Eloquent\Model $ownerRecord, string $pageClass): bool
|
||||
{
|
||||
// Sadece Müşteri Görüşleri sayfası veya testimonials şablonu kullananlar için göster
|
||||
return $ownerRecord->slug === 'musteri-gorusleri' ||
|
||||
$ownerRecord->template === 'corporate.testimonials' ||
|
||||
$ownerRecord->is_homepage;
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Müşteri Adı')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('position')
|
||||
->label('Şirket / Ünvan')
|
||||
->maxLength(255),
|
||||
Textarea::make('content')
|
||||
->label('Görüş / Yorum')
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
Select::make('rating')
|
||||
->label('Puan')
|
||||
->options([
|
||||
1 => '1 Yıldız',
|
||||
2 => '2 Yıldız',
|
||||
3 => '3 Yıldız',
|
||||
4 => '4 Yıldız',
|
||||
5 => '5 Yıldız',
|
||||
])
|
||||
->default(5)
|
||||
->required(),
|
||||
FileUpload::make('avatar')
|
||||
->label('Profil Resmi')
|
||||
->image()
|
||||
->directory('testimonials'),
|
||||
Toggle::make('is_active')
|
||||
->label('Aktif')
|
||||
->default(true),
|
||||
TextInput::make('sort_order')
|
||||
->label('Sıralama')
|
||||
->numeric()
|
||||
->default(0),
|
||||
]);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('name')
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Ad')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('position')
|
||||
->label('Ünvan')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('rating')
|
||||
->label('Puan')
|
||||
->sortable(),
|
||||
Tables\Columns\IconColumn::make('is_active')
|
||||
->label('Aktif')
|
||||
->boolean()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('sort_order')
|
||||
->label('Sıra')
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make(),
|
||||
])
|
||||
->actions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user