-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from hellboy1975/release/0.1.2
Release/0.1.2
- Loading branch information
Showing
56 changed files
with
2,124 additions
and
666 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/Filament/Resources/AttemptResource/Pages/ViewAttempt.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\AttemptResource\Pages; | ||
|
||
use App\Filament\Resources\AttemptResource; | ||
use Filament\Resources\Pages\ViewRecord; | ||
|
||
class ViewAttempt extends ViewRecord | ||
{ | ||
protected static string $resource = AttemptResource::class; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\PostResource\Pages; | ||
use App\Models\Post; | ||
use Camya\Filament\Forms\Components\TitleWithSlugInput; | ||
use Filament\Forms\Components\DateTimePicker; | ||
use Filament\Forms\Components\FileUpload; | ||
use Filament\Forms\Components\Group; | ||
use Filament\Forms\Components\MarkdownEditor; | ||
use Filament\Forms\Components\Section; | ||
use Filament\Forms\Components\Select; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Form; | ||
use Filament\Forms\Get; | ||
use Filament\Infolists\Components\Section as ComponentsSection; | ||
use Filament\Infolists\Components\TextEntry; | ||
use Filament\Infolists\Infolist; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Filters\SelectFilter; | ||
use Filament\Tables\Table; | ||
|
||
class PostResource extends Resource | ||
{ | ||
protected static ?string $model = Post::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; | ||
|
||
protected static ?string $navigationGroup = 'Manage'; | ||
|
||
protected static ?int $navigationSort = 10; | ||
|
||
public static function infolist(Infolist $infolist): Infolist | ||
{ | ||
return $infolist | ||
->schema([ | ||
ComponentsSection::make()->schema([ | ||
TextEntry::make('title'), | ||
TextEntry::make('status') | ||
->badge() | ||
->color(fn (string $state): string => match ($state) { | ||
'draft' => 'gray', | ||
'reviewing' => 'warning', | ||
'published' => 'success', | ||
'rejected' => 'danger', | ||
}), | ||
TextEntry::make('post_type') | ||
->badge() | ||
->color(fn (string $state): string => match ($state) { | ||
'news' => 'warning', | ||
'page' => 'success', | ||
'journal' => 'danger', | ||
}), | ||
TextEntry::make('description'), | ||
])->columns(3), | ||
ComponentsSection::make()->schema([ | ||
TextEntry::make('content') | ||
->hiddenLabel() | ||
->markdown(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Group::make() | ||
->schema([ | ||
Section::make('Content') | ||
->schema([ | ||
TitleWithSlugInput::make( | ||
fieldTitle: 'title', // The name of the field in your model that stores the title. | ||
fieldSlug: 'slug', // The name of the field in your model that will store the slug. | ||
), | ||
TextInput::make('description') | ||
->required(), | ||
MarkdownEditor::make('content') | ||
->required(), | ||
FileUpload::make('featured_image') | ||
->columnSpanFull() | ||
->directory('postImages') | ||
->disk('public') | ||
->image() | ||
->imageEditor() | ||
->imageEditorAspectRatios([ | ||
'16:9', | ||
'4:3', | ||
'1:1', | ||
]), | ||
]), | ||
]) | ||
->columnSpan(['lg' => 2]), | ||
Group::make() | ||
->schema([ | ||
Section::make('Info')->schema([ | ||
Select::make('post_type') | ||
->default('news') | ||
->options([ | ||
'news' => 'News', | ||
'page' => 'Page', | ||
'journal' => 'Journal', | ||
]) | ||
->live(), | ||
Select::make('status') | ||
->options([ | ||
'draft' => 'Draft', | ||
'reviewing' => 'Reviewing', | ||
'published' => 'Published', | ||
'rejected' => 'Rejected', | ||
]) | ||
->default('draft'), | ||
Select::make('user_id') | ||
->relationship('author', 'name') | ||
->label('Author') | ||
->default(auth()->user()->id), | ||
Select::make('parent_id') | ||
->relationship('parent', 'title') | ||
->label('Parent Page') | ||
->visible(fn (Get $get): bool => ! $get('post_type') == 'page'), | ||
DateTimePicker::make('published_at') | ||
->default(now()), | ||
]) | ||
->columnSpan(['lg' => 1]), | ||
]), | ||
])->columns(3); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
TextColumn::make('title'), | ||
TextColumn::make('post_type') | ||
->badge() | ||
->color(fn (string $state): string => match ($state) { | ||
'news' => 'warning', | ||
'page' => 'success', | ||
'journal' => 'danger', | ||
}), | ||
TextColumn::make('status') | ||
->badge() | ||
->color(fn (string $state): string => match ($state) { | ||
'draft' => 'gray', | ||
'reviewing' => 'warning', | ||
'published' => 'success', | ||
'rejected' => 'danger', | ||
}), | ||
TextColumn::make('author.name'), | ||
TextColumn::make('published_at') | ||
->date(), | ||
]) | ||
->filters([ | ||
SelectFilter::make('status') | ||
->options([ | ||
'draft' => 'Draft', | ||
'reviewing' => 'Reviewing', | ||
'published' => 'Published', | ||
'rejected' => 'Rejected', | ||
]), | ||
SelectFilter::make('post_type') | ||
->options([ | ||
'news' => 'News', | ||
'page' => 'Page', | ||
'journal' => 'Journal', | ||
]), | ||
]) | ||
->actions([ | ||
Tables\Actions\ViewAction::make()->iconButton(), | ||
Tables\Actions\EditAction::make()->iconButton(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListPosts::route('/'), | ||
'create' => Pages\CreatePost::route('/create'), | ||
'view' => Pages\ViewPost::route('/{record}'), | ||
'edit' => Pages\EditPost::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\PostResource\Pages; | ||
|
||
use App\Filament\Resources\PostResource; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreatePost extends CreateRecord | ||
{ | ||
protected static string $resource = PostResource::class; | ||
} |
Oops, something went wrong.