From db59909c22c1accf99dc2ca6c86b2dc8ec7dd0d6 Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Tue, 8 Nov 2022 09:13:44 +0100 Subject: [PATCH] fix some array bracket styling --- ...2022_07_04_104832_add_indices_to_posts.php | 18 +++-- routes/web.php | 25 +++---- src/Filament/Resources/FaqResource.php | 12 ++-- src/Filament/Resources/PageResource.php | 62 ++++++----------- src/Filament/Resources/PostResource.php | 68 +++++++------------ src/Filament/Resources/TagResource.php | 21 +++--- src/Http/Livewire/Page.php | 10 +-- src/Http/Livewire/Posts.php | 7 +- src/Http/Livewire/Tags.php | 6 +- src/Models/Post.php | 40 +++++------ src/Models/PostScope.php | 7 +- src/SkyServiceProvider.php | 9 +-- 12 files changed, 106 insertions(+), 179 deletions(-) diff --git a/database/migrations/2022_07_04_104832_add_indices_to_posts.php b/database/migrations/2022_07_04_104832_add_indices_to_posts.php index feb4413..b2ac0ab 100644 --- a/database/migrations/2022_07_04_104832_add_indices_to_posts.php +++ b/database/migrations/2022_07_04_104832_add_indices_to_posts.php @@ -4,17 +4,15 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class () extends Migration { +return new class extends Migration +{ public function up() { - Schema::table( - 'posts', - function (Blueprint $table) { - $table->index('title'); - $table->index('slug'); - $table->index('description'); - $table->fullText('content'); - } - ); + Schema::table('posts', function (Blueprint $table) { + $table->index('title'); + $table->index('slug'); + $table->index('description'); + $table->fullText('content'); + }); } }; diff --git a/routes/web.php b/routes/web.php index 6a9c218..63a5a68 100644 --- a/routes/web.php +++ b/routes/web.php @@ -9,23 +9,18 @@ Route::prefix(config('zeus-sky.path')) ->middleware(config('zeus-sky.middleware')) - ->group( - function () { - Route::get('/', Posts::class)->name('blogs'); - Route::get(config('zeus-sky.post_uri_prefix') . '/{slug}', Post::class)->name('post'); - Route::get(config('zeus-sky.page_uri_prefix') . '/{slug}', Page::class)->name('page'); - Route::get('{type}/{slug}', Tags::class)->name('tags'); + ->group(function () { + Route::get('/', Posts::class)->name('blogs'); + Route::get(config('zeus-sky.post_uri_prefix') . '/{slug}', Post::class)->name('post'); + Route::get(config('zeus-sky.page_uri_prefix') . '/{slug}', Page::class)->name('page'); + Route::get('{type}/{slug}', Tags::class)->name('tags'); - Route::get( - 'passConf', - function () { - session()->put(request('postID') . '-' . request('password'), request('password')); + Route::get('passConf', function () { + session()->put(request('postID') . '-' . request('password'), request('password')); - return redirect()->back()->with('status', 'sorry, password incorrect!'); - } - ); - } - ); + return redirect()->back()->with('status', 'sorry, password incorrect!'); + }); + }); if (in_array('LaraZeus\Sky\Filament\Resources\FaqResource', config('zeus-sky.enabled_resources'))) { Route::get(config('zeus-sky.faq_uri_prefix') . '', Faq::class)->name('faq'); diff --git a/src/Filament/Resources/FaqResource.php b/src/Filament/Resources/FaqResource.php index ffd903c..94cdaf3 100644 --- a/src/Filament/Resources/FaqResource.php +++ b/src/Filament/Resources/FaqResource.php @@ -44,8 +44,7 @@ protected static function getNavigationLabel(): string public static function form(Form $form): Form { return $form - ->schema( - [ + ->schema([ Textarea::make('question') ->label(__('Question')) ->required() @@ -57,18 +56,15 @@ public static function form(Form $form): Form ->required() ->maxLength(65535) ->columnSpan(2), - ] - ); + ]); } public static function table(Table $table): Table { return $table - ->columns( - [ + ->columns([ TextColumn::make('question'), - ] - ); + ]); } public static function getPages(): array diff --git a/src/Filament/Resources/PageResource.php b/src/Filament/Resources/PageResource.php index 7e7e361..f0b7643 100644 --- a/src/Filament/Resources/PageResource.php +++ b/src/Filament/Resources/PageResource.php @@ -41,38 +41,29 @@ protected static function getNavigationBadge(): ?string public static function form(Form $form): Form { return $form - ->schema( - [ - Grid::make()->schema( - [ - Card::make()->schema( - [ + ->schema([ + Grid::make()->schema([ + Card::make()->schema([ TextInput::make('title') ->label(__('Post Title')) ->required() ->maxLength(255) ->reactive() - ->afterStateUpdated( - function (Closure $set, $state) { - $set('slug', Str::slug($state)); - } - ), + ->afterStateUpdated(function (Closure $set, $state) { + $set('slug', Str::slug($state)); + }), TinyEditor::make('content') ->label(__('Post Content')) ->showMenuBar() ->required(), - ] - ), - ] - ) + ]), + ]) ->columnSpan(3), - Grid::make()->schema( - [ + Grid::make()->schema([ Section::make(__('SEO')) - ->description(__('SEO Settings'))->schema( - [ + ->description(__('SEO Settings'))->schema([ Hidden::make('user_id') ->required() ->default(auth()->user()->id), @@ -100,14 +91,12 @@ function (Closure $set, $state) { ->integer() ->label(__('Page Order')) ->default(1), - ] - ) + ]) ->collapsible(), Section::make(__('visibility')) ->description(__('Visibility Options')) - ->schema( - [ + ->schema([ Select::make('status') ->label(__('status')) ->default('publish') @@ -123,30 +112,24 @@ function (Closure $set, $state) { DateTimePicker::make('published_at') ->label(__('published at')) ->default(now()), - ] - ) + ]) ->collapsible(), Section::make(__('Featured Image')) - ->schema( - [ + ->schema([ SpatieMediaLibraryFileUpload::make('featured_image') ->collection('pages') ->label(''), - ] - ) + ]) ->collapsible(), - ] - )->columnSpan(1), - ] - )->columns(4); + ])->columnSpan(1), + ])->columns(4); } public static function table(Table $table): Table { return $table - ->columns( - [ + ->columns([ ViewColumn::make('title_card') ->label(__('Title')) ->sortable(['title']) @@ -159,11 +142,9 @@ public static function table(Table $table): Table ->searchable(['status']) ->view('zeus-sky::filament.columns.status-desc') ->tooltip(fn (Post $record): string => $record->published_at->format('Y/m/d | H:i A')), - ] - ) + ]) ->defaultSort('id', 'desc') - ->filters( - [ + ->filters([ MultiSelectFilter::make('status') ->label(__('Status')) ->options(PostStatus::pluck('label', 'name')), @@ -171,8 +152,7 @@ public static function table(Table $table): Table Filter::make('password') ->label(__('Password Protected')) ->query(fn (Builder $query): Builder => $query->whereNotNull('password')), - ] - ); + ]); } public static function getPages(): array diff --git a/src/Filament/Resources/PostResource.php b/src/Filament/Resources/PostResource.php index 0abc206..a1bc0f2 100644 --- a/src/Filament/Resources/PostResource.php +++ b/src/Filament/Resources/PostResource.php @@ -41,38 +41,29 @@ protected static function getNavigationBadge(): ?string public static function form(Form $form): Form { return $form - ->schema( - [ - Grid::make()->schema( - [ - Card::make()->schema( - [ + ->schema([ + Grid::make()->schema([ + Card::make()->schema([ TextInput::make('title') ->label(__('Post Title')) ->required() ->maxLength(255) ->reactive() - ->afterStateUpdated( - function (Closure $set, $state) { - $set('slug', Str::slug($state)); - } - ), + ->afterStateUpdated(function (Closure $set, $state) { + $set('slug', Str::slug($state)); + }), TinyEditor::make('content') ->label(__('Post Content')) ->showMenuBar() ->required(), - ] - ), - ] - )->columnSpan(3), + ]), + ])->columnSpan(3), - Grid::make()->schema( - [ + Grid::make()->schema([ Section::make(__('SEO')) ->description(__('SEO Settings')) - ->schema( - [ + ->schema([ Hidden::make('user_id') ->default(auth()->user()->id) ->required(), @@ -91,14 +82,12 @@ function (Closure $set, $state) { ->required() ->maxLength(255) ->label(__('Post Slug')), - ] - ) + ]) ->collapsible(), Section::make(__('Tags and Categories')) ->description(__('Tags and Categories Options')) - ->schema( - [ + ->schema([ SpatieTagsInput::make('tags') ->type('tag') ->label(__('Tags')), @@ -106,14 +95,12 @@ function (Closure $set, $state) { SpatieTagsInput::make('category') ->type('category') ->label(__('Categories')), - ] - ) + ]) ->collapsible(), Section::make(__('visibility')) ->description(__('Visibility Options')) - ->schema( - [ + ->schema([ Select::make('status') ->label(__('status')) ->default('publish') @@ -132,30 +119,24 @@ function (Closure $set, $state) { DateTimePicker::make('sticky_until') ->label(__('Sticky Until')), - ] - ) + ]) ->collapsible(), Section::make(__('Featured Image')) - ->schema( - [ + ->schema([ SpatieMediaLibraryFileUpload::make('featured_image') ->collection('posts') ->label(''), - ] - ) + ]) ->collapsible(), - ] - )->columnSpan(1), - ] - )->columns(4); + ])->columnSpan(1), + ])->columns(4); } public static function table(Table $table): Table { return $table - ->columns( - [ + ->columns([ ViewColumn::make('title_card') ->label(__('Title')) ->sortable(['title']) @@ -176,11 +157,9 @@ public static function table(Table $table): Table SpatieTagsColumn::make('category') ->label(__('Post Category')) ->type('category'), - ] - ) + ]) ->defaultSort('id', 'desc') - ->filters( - [ + ->filters([ MultiSelectFilter::make('status') ->label(__('Status')) ->options(PostStatus::pluck('label', 'name')), @@ -212,8 +191,7 @@ public static function table(Table $table): Table MultiSelectFilter::make('tags') ->relationship('tags', 'name') ->label(__('Tags')), - ] - ); + ]); } public static function getPages(): array diff --git a/src/Filament/Resources/TagResource.php b/src/Filament/Resources/TagResource.php index 9493585..ed74d23 100644 --- a/src/Filament/Resources/TagResource.php +++ b/src/Filament/Resources/TagResource.php @@ -40,35 +40,30 @@ public static function form(Form $form): Form ->maxLength(255) ->label(__('Tag.Name')) ->reactive() - ->afterStateUpdated( - function (Closure $set, $state) { - $set('slug', Str::slug($state)); - } - ), + ->afterStateUpdated(function (Closure $set, $state) { + $set('slug', Str::slug($state)); + }), TextInput::make('slug') ->unique(ignorable: fn (?Model $record): ?Model => $record) ->required() ->maxLength(255), Select::make('type') ->options([ - 'tag' => 'Tag', + 'tag' => 'Tag', 'category' => 'Category', - ]), - ] - ); + ]), + ]); } public static function table(Table $table): Table { return $table - ->columns( - [ + ->columns([ TextColumn::make('name'), TextColumn::make('type'), TextColumn::make('slug'), TextColumn::make('posts_count')->counts('posts'), - ] - ); + ]); } public static function getPages(): array diff --git a/src/Http/Livewire/Page.php b/src/Http/Livewire/Page.php index b887632..417e64d 100644 --- a/src/Http/Livewire/Page.php +++ b/src/Http/Livewire/Page.php @@ -30,15 +30,11 @@ public function render() ->twitter(); return view(app('theme') . '.page') - ->with( - [ + ->with([ 'post' => $this->page, - /** - * @phpstan-ignore-next-line - */ + /** @phpstan-ignore-next-line */ 'children' => Post::with('parent')->where('parent_id', $this->page->id)->get(), - ] - ) + ]) ->layout(config('zeus-sky.layout')); } } diff --git a/src/Http/Livewire/Posts.php b/src/Http/Livewire/Posts.php index e0d7e7b..1ae35ed 100644 --- a/src/Http/Livewire/Posts.php +++ b/src/Http/Livewire/Posts.php @@ -48,16 +48,13 @@ public function render() ->withUrl() ->twitter(); - return view(app('theme') . '.home') - ->with( - [ + return view(app('theme') . '.home')->with([ 'posts' => $posts, 'pages' => $pages, 'recent' => $recent, 'tags' => Tag::withCount('postsPublished')->where('type', 'category')->get(), 'stickies' => Post::sticky()->published()->get(), - ] - ) + ]) ->layout(config('zeus-sky.layout')); } } diff --git a/src/Http/Livewire/Tags.php b/src/Http/Livewire/Tags.php index 3b7413b..33056fb 100644 --- a/src/Http/Livewire/Tags.php +++ b/src/Http/Livewire/Tags.php @@ -34,11 +34,9 @@ public function render() ->twitter(); return view(app('theme') . '.category') - ->with( - [ + ->with([ 'posts' => $this->tag->postsPublished, - ] - ) + ]) ->layout(config('zeus-sky.layout')); } } diff --git a/src/Models/Post.php b/src/Models/Post.php index 9199db0..3baecda 100644 --- a/src/Models/Post.php +++ b/src/Models/Post.php @@ -2,7 +2,7 @@ namespace LaraZeus\Sky\Models; -use LaraZeus\Sky\Factories\PostFactory; +use Database\Factories\PostFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Blade; @@ -20,30 +20,30 @@ class Post extends Model implements HasMedia use HasTranslations; public $translatable = [ - 'title', - 'content', - 'description', + 'title', + 'content', + 'description', ]; protected $fillable = [ - 'title', - 'slug', - 'description', - 'post_type', - 'content', - 'user_id', - 'parent_id', - 'featured_image', - 'published_at', - 'sticky_until', - 'password', - 'ordering', - 'status', + 'title', + 'slug', + 'description', + 'post_type', + 'content', + 'user_id', + 'parent_id', + 'featured_image', + 'published_at', + 'sticky_until', + 'password', + 'ordering', + 'status', ]; protected $casts = [ - 'published_at' => 'datetime', - 'sticky_until' => 'datetime', + 'published_at' => 'datetime', + 'sticky_until' => 'datetime', ]; protected static function newFactory(): PostFactory @@ -61,7 +61,7 @@ public function statusDesc(): string $PostStatus = PostStatus::where('name', $this->status)->first(); $icon = Blade::render('@svg("' . $PostStatus->icon . '","w-4 h-4 inline-flex")'); - return " " . $icon . " {$PostStatus->label}"; + return " " . $icon . " {$PostStatus->label}"; } public function author() diff --git a/src/Models/PostScope.php b/src/Models/PostScope.php index 9301866..8fa2395 100644 --- a/src/Models/PostScope.php +++ b/src/Models/PostScope.php @@ -16,12 +16,9 @@ public function scopeSticky($query) public function scopeNotSticky($query) { - $query->wherePostType('post') - ->where( - function ($q) { + $query->wherePostType('post')->where(function ($q) { return $q->whereDate('sticky_until', '<=', now())->orWhereNull('sticky_until'); - } - ) + }) ->whereDate('published_at', '<=', now()); } diff --git a/src/SkyServiceProvider.php b/src/SkyServiceProvider.php index af83e07..28b8242 100644 --- a/src/SkyServiceProvider.php +++ b/src/SkyServiceProvider.php @@ -17,12 +17,9 @@ public function boot() { View::share('theme', 'zeus-sky::themes.' . config('zeus-sky.theme', 'zeus')); - App::singleton( - 'theme', - function () { - return 'zeus-sky::themes.' . config('zeus-sky.theme', 'zeus'); - } - ); + App::singleton('theme', function () { + return 'zeus-sky::themes.' . config('zeus-sky.theme', 'zeus'); + }); return parent::boot(); }