Skip to content

Commit

Permalink
card to section and small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
atmonshi committed Aug 6, 2023
1 parent 7889f59 commit 5a890e2
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 31 deletions.
3 changes: 0 additions & 3 deletions resources/views/filament/columns/tag-counts.blade.php

This file was deleted.

4 changes: 2 additions & 2 deletions resources/views/themes/zeus/sky/addons/library-item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</li>
</x-slot>

<x-filament::card>
<x-filament::section>
<h1>{{ $item->title }}</h1>

<p>
Expand All @@ -32,5 +32,5 @@
@include($skyTheme.'.addons.library-types.'.strtolower($item->type))
@endforeach
</div>
</x-filament::card>
</x-filament::section>
</div>
4 changes: 2 additions & 2 deletions resources/views/themes/zeus/sky/addons/library-tag.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<div class="my-2 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-2">
@foreach($libraryTag->library as $lib)
<x-filament::card>
<x-filament::section>
<div>
<h2 class="text-secondary-600 text-xl font-semibold">
<a href="{{ route('library.item', $lib->slug) }}">
Expand All @@ -36,7 +36,7 @@
{{ $lib->description ?? '' }}
</div>
</div>
</x-filament::card>
</x-filament::section>
@endforeach
</div>
</div>
4 changes: 2 additions & 2 deletions resources/views/themes/zeus/sky/addons/library.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-2">
@foreach($categories as $category)
<x-filament::card>
<x-filament::section>
<h2><a href="{{ route('library.tag',$category->slug ) }}" class="text-secondary-600">{{ $category->name }}</a></h2>
<div class="space-y-2">
@foreach($category->library as $library)
Expand Down Expand Up @@ -39,7 +39,7 @@
</div>
@endforeach
</div>
</x-filament::card>
</x-filament::section>
@endforeach
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="max-w-3xl mx-auto">
<x-filament::card>
<x-filament::section>
<x-filament-panels::form method="post" action="{{ route('passwordConfirmation',[$post]) }}">
@csrf
<div class="flex flex-col gap-4">
Expand All @@ -15,5 +15,5 @@
{{ __('Send') }}
</x-filament::button>
</x-filament-panels::form>
</x-filament::card>
</x-filament::section>
</div>
14 changes: 7 additions & 7 deletions src/Filament/Resources/PageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static function form(Form $form): Form
->hint(__('Write an excerpt for your post')),

TextInput::make('slug')
->unique(ignorable: fn (?Post $record): ?Post => $record)
->unique(ignorable: fn(?Post $record): ?Post => $record)
->required()
->maxLength(255)
->label(__('Post Slug')),
Expand All @@ -116,7 +116,7 @@ public static function form(Form $form): Form

TextInput::make('password')
->label(__('Password'))
->visible(fn (Get $get): bool => $get('status') === 'private'),
->visible(fn(Get $get): bool => $get('status') === 'private'),

DateTimePicker::make('published_at')
->label(__('published at'))
Expand All @@ -140,11 +140,11 @@ public static function form(Form $form): Form
->inline(),
SpatieMediaLibraryFileUpload::make('featured_image_upload')
->collection('pages')
->visible(fn (Get $get) => $get('featured_image_type') === 'upload')
->visible(fn(Get $get) => $get('featured_image_type') === 'upload')
->label(''),
TextInput::make('featured_image')
->label(__('featured image url'))
->visible(fn (Get $get) => $get('featured_image_type') === 'url')
->visible(fn(Get $get) => $get('featured_image_type') === 'url')
->url(),
]),
])->columnSpan(2),
Expand All @@ -168,7 +168,7 @@ public static function table(Table $table): Table
->searchable(['status'])
->toggleable()
->view('zeus::filament.columns.status-desc')
->tooltip(fn (Post $record): string => $record->published_at->format('Y/m/d | H:i A')),
->tooltip(fn(Post $record): string => $record->published_at->format('Y/m/d | H:i A')),
])
->defaultSort('id', 'desc')
->actions([
Expand All @@ -178,7 +178,7 @@ public static function table(Table $table): Table
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Post $record): string => route('page', ['slug' => $record]))
->url(fn(Post $record): string => route('page', ['slug' => $record]))
->openUrlInNewTab(),
DeleteAction::make('delete'),
ForceDeleteAction::make(),
Expand All @@ -198,7 +198,7 @@ public static function table(Table $table): Table
->options(SkyPlugin::get()->getPostStatusModel()::pluck('label', 'name')),
Filter::make('password')
->label(__('Password Protected'))
->query(fn (Builder $query): Builder => $query->whereNotNull('password')),
->query(fn(Builder $query): Builder => $query->whereNotNull('password')),
]);
}

Expand Down
20 changes: 10 additions & 10 deletions src/Filament/Resources/PostResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static function form(Form $form): Form
->hint(__('Write an excerpt for your post')),

TextInput::make('slug')
->unique(ignorable: fn (?Post $record): ?Post => $record)
->unique(ignorable: fn(?Post $record): ?Post => $record)
->required()
->maxLength(255)
->label(__('Post Slug')),
Expand All @@ -112,7 +112,7 @@ public static function form(Form $form): Form

TextInput::make('password')
->label(__('Password'))
->visible(fn (Get $get): bool => $get('status') === 'private'),
->visible(fn(Get $get): bool => $get('status') === 'private'),

DateTimePicker::make('published_at')
->label(__('published at'))
Expand Down Expand Up @@ -143,12 +143,12 @@ public static function form(Form $form): Form

SpatieMediaLibraryFileUpload::make('featured_image_upload')
->collection('posts')
->visible(fn (Get $get) => $get('featured_image_type') === 'upload')
->visible(fn(Get $get) => $get('featured_image_type') === 'upload')
->label(''),

TextInput::make('featured_image')
->label(__('featured image url'))
->visible(fn (Get $get) => $get('featured_image_type') === 'url')
->visible(fn(Get $get) => $get('featured_image_type') === 'url')
->url(),
]),
])->columnSpan(2),
Expand All @@ -172,7 +172,7 @@ public static function table(Table $table): Table
->searchable(['status'])
->toggleable()
->view('zeus::filament.columns.status-desc')
->tooltip(fn (Post $record): string => $record->published_at->format('Y/m/d | H:i A')),
->tooltip(fn(Post $record): string => $record->published_at->format('Y/m/d | H:i A')),

SpatieTagsColumn::make('tags')
->label(__('Post Tags'))
Expand All @@ -192,7 +192,7 @@ public static function table(Table $table): Table
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Post $record): string => route('post', ['slug' => $record]))
->url(fn(Post $record): string => route('post', ['slug' => $record]))
->openUrlInNewTab(),
DeleteAction::make('delete'),
ForceDeleteAction::make(),
Expand All @@ -213,25 +213,25 @@ public static function table(Table $table): Table

Filter::make('password')
->label(__('Password Protected'))
->query(fn (Builder $query): Builder => $query->whereNotNull('password')),
->query(fn(Builder $query): Builder => $query->whereNotNull('password')),

Filter::make('sticky')
->label(__('Still Sticky'))
// @phpstan-ignore-next-line
->query(fn (Builder $query): Builder => $query->sticky()),
->query(fn(Builder $query): Builder => $query->sticky()),

Filter::make('not_sticky')
->label(__('Not Sticky'))
->query(
fn (Builder $query): Builder => $query
fn(Builder $query): Builder => $query
->whereDate('sticky_until', '<=', now())
->orWhereNull('sticky_until')
),

Filter::make('sticky_only')
->label(__('Sticky Only'))
->query(
fn (Builder $query): Builder => $query
fn(Builder $query): Builder => $query
->where('post_type', 'post')
->whereNotNull('sticky_until')
),
Expand Down
9 changes: 7 additions & 2 deletions src/Filament/Resources/TagResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use LaraZeus\Sky\Filament\Resources\TagResource\Pages;
use LaraZeus\Sky\Models\Tag;
use LaraZeus\Sky\SkyPlugin;

class TagResource extends SkyResource
Expand All @@ -42,7 +43,7 @@ public static function form(Form $form): Form
$set('slug', Str::slug($state));
}),
TextInput::make('slug')
->unique(ignorable: fn (?Model $record): ?Model => $record)
->unique(ignorable: fn(?Model $record): ?Model => $record)
->required()
->maxLength(255),
Select::make('type')
Expand All @@ -59,7 +60,11 @@ public static function table(Table $table): Table
TextColumn::make('slug')->toggleable()->searchable()->sortable(),
TextColumn::make('items_count')
->toggleable()
->view('zeus::filament.columns.tag-counts'),
->getStateUsing(
fn(Tag $record): int => method_exists($record, $record->type)
? $record->{$record->type}()->count()
: 0
),
])
->filters([
SelectFilter::make('type')
Expand Down
2 changes: 1 addition & 1 deletion src/SkyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function getMigrations(): array

private function bootFilamentNavigation(): void
{
if (! app('filament')->hasPlugin('zeus-sky') && ! app('filament')->hasPlugin('navigation')) {
if (! app('filament')->hasPlugin('zeus-sky') || ! app('filament')->hasPlugin('navigation')) {
return;
}

Expand Down

0 comments on commit 5a890e2

Please sign in to comment.