mirror of
https://github.com/nihonbuzz/nihonbuzz-academy.git
synced 2026-01-26 13:32:07 +07:00
first commit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\Vocabularies\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\Vocabularies\VocabularyResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateVocabulary extends CreateRecord
|
||||
{
|
||||
protected static string $resource = VocabularyResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\Vocabularies\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\Vocabularies\VocabularyResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditVocabulary extends EditRecord
|
||||
{
|
||||
protected static string $resource = VocabularyResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\Vocabularies\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\Vocabularies\VocabularyResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListVocabularies extends ListRecords
|
||||
{
|
||||
protected static string $resource = VocabularyResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\Vocabularies\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class VocabularyForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('word')
|
||||
->required(),
|
||||
TextInput::make('reading'),
|
||||
TextInput::make('romaji'),
|
||||
TextInput::make('meaning_en'),
|
||||
TextInput::make('meaning_id'),
|
||||
TextInput::make('level_id'),
|
||||
TextInput::make('audio_url')
|
||||
->url(),
|
||||
TextInput::make('type'),
|
||||
Textarea::make('stroke_order_svg')
|
||||
->columnSpanFull(),
|
||||
Textarea::make('example_sentences')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\Vocabularies\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class VocabulariesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
TextColumn::make('word')
|
||||
->searchable(),
|
||||
TextColumn::make('reading')
|
||||
->searchable(),
|
||||
TextColumn::make('romaji')
|
||||
->searchable(),
|
||||
TextColumn::make('meaning_en')
|
||||
->searchable(),
|
||||
TextColumn::make('meaning_id')
|
||||
->searchable(),
|
||||
TextColumn::make('level_id')
|
||||
->searchable(),
|
||||
TextColumn::make('audio_url')
|
||||
->searchable(),
|
||||
TextColumn::make('type')
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\Vocabularies;
|
||||
|
||||
use App\Filament\Admin\Resources\Vocabularies\Pages\CreateVocabulary;
|
||||
use App\Filament\Admin\Resources\Vocabularies\Pages\EditVocabulary;
|
||||
use App\Filament\Admin\Resources\Vocabularies\Pages\ListVocabularies;
|
||||
use App\Filament\Admin\Resources\Vocabularies\Schemas\VocabularyForm;
|
||||
use App\Filament\Admin\Resources\Vocabularies\Tables\VocabulariesTable;
|
||||
use App\Models\Vocabulary;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class VocabularyResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Vocabulary::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'word';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return VocabularyForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return VocabulariesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListVocabularies::route('/'),
|
||||
'create' => CreateVocabulary::route('/create'),
|
||||
'edit' => EditVocabulary::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user