mirror of
https://github.com/nihonbuzz/nihonbuzz-academy.git
synced 2026-01-26 13:32:07 +07:00
feat: update seeder with real YouTube video URLs and update technical blueprint
This commit is contained in:
@@ -21,7 +21,7 @@ class CourseForm
|
||||
->required(),
|
||||
TextInput::make('slug')
|
||||
->required(),
|
||||
Textarea::make('description')
|
||||
\Filament\Forms\Components\RichEditor::make('description')
|
||||
->columnSpanFull(),
|
||||
Select::make('level_id')
|
||||
->relationship('level', 'name'),
|
||||
@@ -29,9 +29,13 @@ class CourseForm
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0)
|
||||
->prefix('$'),
|
||||
TextInput::make('thumbnail_url')
|
||||
->url(),
|
||||
->prefix('IDR'),
|
||||
\Filament\Forms\Components\FileUpload::make('thumbnail_url')
|
||||
->disk('r2')
|
||||
->directory('thumbnails')
|
||||
->visibility('public')
|
||||
->image()
|
||||
->imageEditor(),
|
||||
Toggle::make('is_published')
|
||||
->required(),
|
||||
Textarea::make('metadata')
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Filament\Admin\Resources\Vocabularies\Schemas;
|
||||
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class VocabularyForm
|
||||
@@ -12,20 +15,63 @@ class VocabularyForm
|
||||
{
|
||||
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(),
|
||||
Section::make('Core Info')
|
||||
->schema([
|
||||
TextInput::make('word')
|
||||
->label('Word (Kanji/Kana)')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('reading')
|
||||
->label('Reading (Kana)')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('romaji')
|
||||
->maxLength(255),
|
||||
TextInput::make('meaning_id')
|
||||
->label('Meaning (Bahasa Indonesia)')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('meaning_en')
|
||||
->label('Meaning (English)')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
])->columns(2),
|
||||
|
||||
Section::make('Metadata & Media')
|
||||
->schema([
|
||||
Select::make('level_id')
|
||||
->label('JLPT Level')
|
||||
->relationship('level', 'code')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Select::make('type')
|
||||
->options([
|
||||
'noun' => 'Noun',
|
||||
'verb' => 'Verb',
|
||||
'adjective' => 'Adjective',
|
||||
'adverb' => 'Adverb',
|
||||
'particle' => 'Particle',
|
||||
'expression' => 'Expression',
|
||||
])
|
||||
->required(),
|
||||
FileUpload::make('audio_url')
|
||||
->label('Pronunciation Audio')
|
||||
->disk('r2')
|
||||
->directory('audio/vocab')
|
||||
->visibility('public')
|
||||
->acceptedFileTypes(['audio/mpeg', 'audio/wav', 'audio/ogg']),
|
||||
])->columns(2),
|
||||
|
||||
Section::make('Advanced')
|
||||
->schema([
|
||||
Textarea::make('stroke_order_svg')
|
||||
->label('Stroke Order SVG (JSON)')
|
||||
->columnSpanFull(),
|
||||
Textarea::make('example_sentences')
|
||||
->label('Example Sentences (JSON)')
|
||||
->columnSpanFull(),
|
||||
])->collapsed(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ 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;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class VocabulariesTable
|
||||
@@ -14,30 +14,33 @@ class VocabulariesTable
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('ID')
|
||||
Tables\Columns\TextColumn::make('word')
|
||||
->label('Word')
|
||||
->searchable()
|
||||
->description(fn (\App\Models\Vocabulary $record): string => $record->reading),
|
||||
Tables\Columns\TextColumn::make('meaning_id')
|
||||
->label('Meaning')
|
||||
->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')
|
||||
Tables\Columns\TextColumn::make('level.code')
|
||||
->label('Level')
|
||||
->badge()
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'N1' => 'danger',
|
||||
'N2' => 'warning',
|
||||
'N3' => 'info',
|
||||
default => 'success',
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->badge(),
|
||||
Tables\Columns\IconColumn::make('audio_url')
|
||||
->label('Audio')
|
||||
->icon('heroicon-o-speaker-wave')
|
||||
->color(fn ($state) => $state ? 'success' : 'gray'),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Courses;
|
||||
|
||||
use App\Filament\Resources\Courses\Pages\CreateCourse;
|
||||
use App\Filament\Resources\Courses\Pages\EditCourse;
|
||||
use App\Filament\Resources\Courses\Pages\ListCourses;
|
||||
use App\Filament\Resources\Courses\Schemas\CourseForm;
|
||||
use App\Filament\Resources\Courses\Tables\CoursesTable;
|
||||
use App\Models\Course;
|
||||
use BackedEnum;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class CourseResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Course::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'title';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(fn ($state, $set) => $set('slug', \Illuminate\Support\Str::slug($state))),
|
||||
|
||||
Forms\Components\TextInput::make('slug')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->unique(ignoreRecord: true),
|
||||
|
||||
Forms\Components\RichEditor::make('description')
|
||||
->columnSpanFull(),
|
||||
|
||||
Forms\Components\Select::make('level_id')
|
||||
->label('JLPT Level')
|
||||
->relationship('level', 'code')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
|
||||
Forms\Components\TextInput::make('price')
|
||||
->numeric()
|
||||
->prefix('IDR')
|
||||
->maxValue(42949672.95),
|
||||
|
||||
Forms\Components\FileUpload::make('thumbnail_url')
|
||||
->label('Thumbnail Image')
|
||||
->image()
|
||||
->disk('r2')
|
||||
->directory('thumbnails')
|
||||
->visibility('public')
|
||||
->imageEditor(),
|
||||
|
||||
Forms\Components\Select::make('teacher_id')
|
||||
->relationship('teacher', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\ImageColumn::make('thumbnail_url')
|
||||
->disk('r2')
|
||||
->visibility('public'),
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('level.code')
|
||||
->label('Level')
|
||||
->badge(),
|
||||
Tables\Columns\TextColumn::make('price')
|
||||
->money('IDR'),
|
||||
Tables\Columns\TextColumn::make('teacher.name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListCourses::route('/'),
|
||||
'create' => CreateCourse::route('/create'),
|
||||
'edit' => EditCourse::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getRecordRouteBindingEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getRecordRouteBindingEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Courses\Pages;
|
||||
|
||||
use App\Filament\Resources\Courses\CourseResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCourse extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CourseResource::class;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Courses\Pages;
|
||||
|
||||
use App\Filament\Resources\Courses\CourseResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCourse extends EditRecord
|
||||
{
|
||||
protected static string $resource = CourseResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Courses\Pages;
|
||||
|
||||
use App\Filament\Resources\Courses\CourseResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCourses extends ListRecords
|
||||
{
|
||||
protected static string $resource = CourseResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Courses\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class CourseForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('teacher_id')
|
||||
->relationship('teacher', 'name')
|
||||
->required(),
|
||||
TextInput::make('title')
|
||||
->required(),
|
||||
TextInput::make('slug')
|
||||
->required(),
|
||||
Textarea::make('description')
|
||||
->columnSpanFull(),
|
||||
TextInput::make('level')
|
||||
->required()
|
||||
->default('N5'),
|
||||
TextInput::make('price')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0)
|
||||
->prefix('$'),
|
||||
TextInput::make('thumbnail_url')
|
||||
->url(),
|
||||
Toggle::make('is_published')
|
||||
->required(),
|
||||
Textarea::make('metadata')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Courses\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CoursesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
TextColumn::make('teacher.name')
|
||||
->searchable(),
|
||||
TextColumn::make('title')
|
||||
->searchable(),
|
||||
TextColumn::make('slug')
|
||||
->searchable(),
|
||||
TextColumn::make('level')
|
||||
->searchable(),
|
||||
TextColumn::make('price')
|
||||
->money()
|
||||
->sortable(),
|
||||
TextColumn::make('thumbnail_url')
|
||||
->searchable(),
|
||||
IconColumn::make('is_published')
|
||||
->boolean(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
ForceDeleteBulkAction::make(),
|
||||
RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Lessons;
|
||||
|
||||
use App\Filament\Resources\Lessons\Pages\CreateLesson;
|
||||
use App\Filament\Resources\Lessons\Pages\EditLesson;
|
||||
use App\Filament\Resources\Lessons\Pages\ListLessons;
|
||||
use App\Filament\Resources\Lessons\Schemas\LessonForm;
|
||||
use App\Filament\Resources\Lessons\Tables\LessonsTable;
|
||||
use App\Models\Lesson;
|
||||
use BackedEnum;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class LessonResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Lesson::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-play-circle';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'title';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
Forms\Components\Select::make('module_id')
|
||||
->relationship('module', 'title')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(fn ($state, $set) => $set('slug', \Illuminate\Support\Str::slug($state))),
|
||||
Forms\Components\TextInput::make('slug')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->unique(ignoreRecord: true),
|
||||
Forms\Components\Select::make('type')
|
||||
->options([
|
||||
'video' => 'Video',
|
||||
'text' => 'Text',
|
||||
'quiz' => 'Quiz',
|
||||
'vocab_list' => 'Vocabulary List',
|
||||
])
|
||||
->default('text')
|
||||
->required(),
|
||||
Forms\Components\FileUpload::make('content_pdf')
|
||||
->label('Lesson PDF (Paid Content)')
|
||||
->disk('r2_private')
|
||||
->directory('pdfs')
|
||||
->visibility('private')
|
||||
->acceptedFileTypes(['application/pdf'])
|
||||
->downloadable()
|
||||
->columnSpanFull(),
|
||||
Forms\Components\RichEditor::make('content')
|
||||
->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('video_url')
|
||||
->label('Video URL (YouTube/Vimeo)')
|
||||
->url(),
|
||||
Forms\Components\Toggle::make('is_free_preview')
|
||||
->label('Free Preview?')
|
||||
->default(false),
|
||||
Forms\Components\TextInput::make('order_index')
|
||||
->numeric()
|
||||
->default(0),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('module.title')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->badge(),
|
||||
Tables\Columns\IconColumn::make('is_free_preview')
|
||||
->boolean(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->defaultSort('order_index', 'asc');
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListLessons::route('/'),
|
||||
'create' => CreateLesson::route('/create'),
|
||||
'edit' => EditLesson::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getRecordRouteBindingEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getRecordRouteBindingEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Lessons\Pages;
|
||||
|
||||
use App\Filament\Resources\Lessons\LessonResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateLesson extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LessonResource::class;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Lessons\Pages;
|
||||
|
||||
use App\Filament\Resources\Lessons\LessonResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditLesson extends EditRecord
|
||||
{
|
||||
protected static string $resource = LessonResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Lessons\Pages;
|
||||
|
||||
use App\Filament\Resources\Lessons\LessonResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListLessons extends ListRecords
|
||||
{
|
||||
protected static string $resource = LessonResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Lessons\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class LessonForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('module_id')
|
||||
->relationship('module', 'title')
|
||||
->required(),
|
||||
TextInput::make('title')
|
||||
->required(),
|
||||
TextInput::make('slug')
|
||||
->required(),
|
||||
TextInput::make('type')
|
||||
->required()
|
||||
->default('text'),
|
||||
Textarea::make('content')
|
||||
->columnSpanFull(),
|
||||
TextInput::make('video_url')
|
||||
->url(),
|
||||
TextInput::make('duration_seconds')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
Toggle::make('is_free_preview')
|
||||
->required(),
|
||||
TextInput::make('order_index')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
Textarea::make('metadata')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Lessons\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class LessonsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
TextColumn::make('module.title')
|
||||
->searchable(),
|
||||
TextColumn::make('title')
|
||||
->searchable(),
|
||||
TextColumn::make('slug')
|
||||
->searchable(),
|
||||
TextColumn::make('type')
|
||||
->searchable(),
|
||||
TextColumn::make('video_url')
|
||||
->searchable(),
|
||||
TextColumn::make('duration_seconds')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
IconColumn::make('is_free_preview')
|
||||
->boolean(),
|
||||
TextColumn::make('order_index')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
ForceDeleteBulkAction::make(),
|
||||
RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Levels;
|
||||
|
||||
use App\Filament\Resources\Levels\Pages\CreateLevel;
|
||||
use App\Filament\Resources\Levels\Pages\EditLevel;
|
||||
use App\Filament\Resources\Levels\Pages\ListLevels;
|
||||
use App\Filament\Resources\Levels\Schemas\LevelForm;
|
||||
use App\Filament\Resources\Levels\Tables\LevelsTable;
|
||||
use App\Models\Level;
|
||||
use BackedEnum;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class LevelResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Level::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-signal';
|
||||
|
||||
protected static ?int $navigationSort = 10;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'code';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('code')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->unique(ignoreRecord: true),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\Textarea::make('description')
|
||||
->maxLength(65535)
|
||||
->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('order_index')
|
||||
->numeric()
|
||||
->default(0),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('code')
|
||||
->badge()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('order_index')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->defaultSort('order_index', 'asc');
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListLevels::route('/'),
|
||||
'create' => CreateLevel::route('/create'),
|
||||
'edit' => EditLevel::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Levels\Pages;
|
||||
|
||||
use App\Filament\Resources\Levels\LevelResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateLevel extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LevelResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Levels\Pages;
|
||||
|
||||
use App\Filament\Resources\Levels\LevelResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditLevel extends EditRecord
|
||||
{
|
||||
protected static string $resource = LevelResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Levels\Pages;
|
||||
|
||||
use App\Filament\Resources\Levels\LevelResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListLevels extends ListRecords
|
||||
{
|
||||
protected static string $resource = LevelResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Levels\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class LevelForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('code')
|
||||
->required(),
|
||||
Textarea::make('description')
|
||||
->columnSpanFull(),
|
||||
TextInput::make('order_index')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Levels\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class LevelsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('code')
|
||||
->searchable(),
|
||||
TextColumn::make('order_index')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Modules;
|
||||
|
||||
use App\Filament\Resources\Modules\Pages\CreateModule;
|
||||
use App\Filament\Resources\Modules\Pages\EditModule;
|
||||
use App\Filament\Resources\Modules\Pages\ListModules;
|
||||
use App\Filament\Resources\Modules\Schemas\ModuleForm;
|
||||
use App\Filament\Resources\Modules\Tables\ModulesTable;
|
||||
use App\Models\Module;
|
||||
use BackedEnum;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class ModuleResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Module::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-rectangle-group';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'title';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
Forms\Components\Select::make('course_id')
|
||||
->relationship('course', 'title')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\RichEditor::make('description')
|
||||
->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('order_index')
|
||||
->numeric()
|
||||
->default(0),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('course.title')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('order_index')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->defaultSort('order_index', 'asc');
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListModules::route('/'),
|
||||
'create' => CreateModule::route('/create'),
|
||||
'edit' => EditModule::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getRecordRouteBindingEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getRecordRouteBindingEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Modules\Pages;
|
||||
|
||||
use App\Filament\Resources\Modules\ModuleResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateModule extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ModuleResource::class;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Modules\Pages;
|
||||
|
||||
use App\Filament\Resources\Modules\ModuleResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditModule extends EditRecord
|
||||
{
|
||||
protected static string $resource = ModuleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Modules\Pages;
|
||||
|
||||
use App\Filament\Resources\Modules\ModuleResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListModules extends ListRecords
|
||||
{
|
||||
protected static string $resource = ModuleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Modules\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ModuleForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('course_id')
|
||||
->relationship('course', 'title')
|
||||
->required(),
|
||||
TextInput::make('title')
|
||||
->required(),
|
||||
Textarea::make('description')
|
||||
->columnSpanFull(),
|
||||
TextInput::make('order_index')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
Toggle::make('is_free_preview')
|
||||
->required(),
|
||||
Textarea::make('metadata')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Modules\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ModulesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
TextColumn::make('course.title')
|
||||
->searchable(),
|
||||
TextColumn::make('title')
|
||||
->searchable(),
|
||||
TextColumn::make('order_index')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
IconColumn::make('is_free_preview')
|
||||
->boolean(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
ForceDeleteBulkAction::make(),
|
||||
RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Pages;
|
||||
|
||||
use App\Filament\Resources\Roles\RoleResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateRole extends CreateRecord
|
||||
{
|
||||
protected static string $resource = RoleResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Pages;
|
||||
|
||||
use App\Filament\Resources\Roles\RoleResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditRole extends EditRecord
|
||||
{
|
||||
protected static string $resource = RoleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Pages;
|
||||
|
||||
use App\Filament\Resources\Roles\RoleResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListRoles extends ListRecords
|
||||
{
|
||||
protected static string $resource = RoleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles;
|
||||
|
||||
use App\Filament\Resources\Roles\Pages\CreateRole;
|
||||
use App\Filament\Resources\Roles\Pages\EditRole;
|
||||
use App\Filament\Resources\Roles\Pages\ListRoles;
|
||||
use App\Filament\Resources\Roles\Schemas\RoleForm;
|
||||
use App\Filament\Resources\Roles\Tables\RolesTable;
|
||||
use App\Models\Role;
|
||||
use BackedEnum;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class RoleResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Role::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?int $navigationSort = 91;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('guard_name')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->default('web'),
|
||||
Forms\Components\Select::make('permissions')
|
||||
->relationship('permissions', 'name')
|
||||
->multiple()
|
||||
->preload(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('guard_name')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('permissions_count')
|
||||
->counts('permissions')
|
||||
->label('Perms'),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListRoles::route('/'),
|
||||
'create' => CreateRole::route('/create'),
|
||||
'edit' => EditRole::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class RoleForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('guard_name')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class RolesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('guard_name')
|
||||
->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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditUser extends EditRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUsers extends ListRecords
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Schemas;
|
||||
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class UserForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('email')
|
||||
->label('Email address')
|
||||
->email()
|
||||
->required(),
|
||||
DateTimePicker::make('email_verified_at'),
|
||||
TextInput::make('password')
|
||||
->password(),
|
||||
TextInput::make('avatar_url')
|
||||
->url(),
|
||||
TextInput::make('xp_points')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
TextInput::make('current_streak')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
Textarea::make('metadata')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UsersTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('email')
|
||||
->label('Email address')
|
||||
->searchable(),
|
||||
TextColumn::make('email_verified_at')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('avatar_url')
|
||||
->searchable(),
|
||||
TextColumn::make('xp_points')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('current_streak')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users;
|
||||
|
||||
use App\Filament\Resources\Users\Pages\CreateUser;
|
||||
use App\Filament\Resources\Users\Pages\EditUser;
|
||||
use App\Filament\Resources\Users\Pages\ListUsers;
|
||||
use App\Filament\Resources\Users\Schemas\UserForm;
|
||||
use App\Filament\Resources\Users\Tables\UsersTable;
|
||||
use App\Models\User;
|
||||
use BackedEnum;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UserResource extends Resource
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?int $navigationSort = 90;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('email')
|
||||
->email()
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\DateTimePicker::make('email_verified_at'),
|
||||
Forms\Components\TextInput::make('password')
|
||||
->password()
|
||||
->dehydrateStateUsing(fn ($state) => filled($state) ? bcrypt($state) : null)
|
||||
->required(fn (string $context): bool => $context === 'create')
|
||||
->maxLength(255),
|
||||
Forms\Components\Select::make('roles')
|
||||
->relationship('roles', 'name')
|
||||
->multiple()
|
||||
->preload(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('roles.name')
|
||||
->badge(),
|
||||
Tables\Columns\TextColumn::make('email_verified_at')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListUsers::route('/'),
|
||||
'create' => CreateUser::route('/create'),
|
||||
'edit' => EditUser::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Vocabularies\Pages;
|
||||
|
||||
use App\Filament\Resources\Vocabularies\VocabularyResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateVocabulary extends CreateRecord
|
||||
{
|
||||
protected static string $resource = VocabularyResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Vocabularies\Pages;
|
||||
|
||||
use App\Filament\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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Vocabularies\Pages;
|
||||
|
||||
use App\Filament\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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\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'),
|
||||
TextInput::make('audio_url')
|
||||
->url(),
|
||||
TextInput::make('type'),
|
||||
Textarea::make('stroke_order_svg')
|
||||
->columnSpanFull(),
|
||||
Textarea::make('example_sentences')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\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')
|
||||
->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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Vocabularies;
|
||||
|
||||
use App\Filament\Resources\Vocabularies\Pages\CreateVocabulary;
|
||||
use App\Filament\Resources\Vocabularies\Pages\EditVocabulary;
|
||||
use App\Filament\Resources\Vocabularies\Pages\ListVocabularies;
|
||||
use App\Filament\Resources\Vocabularies\Schemas\VocabularyForm;
|
||||
use App\Filament\Resources\Vocabularies\Tables\VocabulariesTable;
|
||||
use App\Models\Vocabulary;
|
||||
use BackedEnum;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components as Schemas;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class VocabularyResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Vocabulary::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-language';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'word';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
Schemas\Section::make('Core Info')
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('word')
|
||||
->label('Word (Kanji/Kana)')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('reading')
|
||||
->label('Reading (Kana)')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('romaji')
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('meaning_id')
|
||||
->label('Meaning (Bahasa Indonesia)')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('meaning_en')
|
||||
->label('Meaning (English)')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
])->columns(2),
|
||||
|
||||
Schemas\Section::make('Metadata & Media')
|
||||
->schema([
|
||||
Forms\Components\Select::make('level_id')
|
||||
->label('JLPT Level')
|
||||
->relationship('level', 'code')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Forms\Components\Select::make('type')
|
||||
->options([
|
||||
'noun' => 'Noun',
|
||||
'verb' => 'Verb',
|
||||
'adjective' => 'Adjective',
|
||||
'adverb' => 'Adverb',
|
||||
'particle' => 'Particle',
|
||||
'expression' => 'Expression',
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\FileUpload::make('audio_url')
|
||||
->label('Pronunciation Audio')
|
||||
->disk('r2')
|
||||
->directory('audio/vocab')
|
||||
->visibility('public')
|
||||
->acceptedFileTypes(['audio/mpeg', 'audio/wav', 'audio/ogg']),
|
||||
])->columns(2),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('word')
|
||||
->label('Word')
|
||||
->searchable()
|
||||
->description(fn (Vocabulary $record): string => $record->reading),
|
||||
Tables\Columns\TextColumn::make('meaning_id')
|
||||
->label('Meaning')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('level.code')
|
||||
->label('Level')
|
||||
->badge()
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'N1' => 'danger',
|
||||
'N2' => 'warning',
|
||||
'N3' => 'info',
|
||||
default => 'success',
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->badge(),
|
||||
Tables\Columns\IconColumn::make('audio_url')
|
||||
->label('Audio')
|
||||
->icon('heroicon-o-speaker-wave')
|
||||
->color(fn ($state) => $state ? 'success' : 'gray'),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('level_id')
|
||||
->label('Level')
|
||||
->relationship('level', 'code'),
|
||||
]);
|
||||
}
|
||||
|
||||
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