-
{{ __('Related Posts') }}
+
{{ __('Related Posts') }}
@foreach($related as $post)
diff --git a/routes/web.php b/routes/web.php
index a465e49..63a5a68 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,6 +1,7 @@
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(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'));
+ session()->put(request('postID') . '-' . request('password'), request('password'));
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').'', \LaraZeus\Sky\Http\Livewire\Faq::class)->name('faq');
+ 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 4506176..94cdaf3 100644
--- a/src/Filament/Resources/FaqResource.php
+++ b/src/Filament/Resources/FaqResource.php
@@ -6,7 +6,7 @@
use Filament\Forms\Components\Textarea;
use Filament\Resources\Form;
use Filament\Resources\Table;
-use Filament\Tables;
+use Filament\Tables\Columns\TextColumn;
use LaraZeus\Sky\Filament\Resources\FaqResource\Pages;
use LaraZeus\Sky\Models\Faq;
@@ -45,8 +45,17 @@ public static function form(Form $form): Form
{
return $form
->schema([
- Textarea::make('question')->label(__('Question'))->required()->maxLength(65535)->columnSpan(2),
- RichEditor::make('answer')->label(__('Answer'))->required()->maxLength(65535)->columnSpan(2),
+ Textarea::make('question')
+ ->label(__('Question'))
+ ->required()
+ ->maxLength(65535)
+ ->columnSpan(2),
+
+ RichEditor::make('answer')
+ ->label(__('Answer'))
+ ->required()
+ ->maxLength(65535)
+ ->columnSpan(2),
]);
}
@@ -54,7 +63,7 @@ public static function table(Table $table): Table
{
return $table
->columns([
- Tables\Columns\TextColumn::make('question'),
+ TextColumn::make('question'),
]);
}
diff --git a/src/Filament/Resources/PageResource.php b/src/Filament/Resources/PageResource.php
index 7de3553..47413e9 100644
--- a/src/Filament/Resources/PageResource.php
+++ b/src/Filament/Resources/PageResource.php
@@ -51,23 +51,44 @@ public static function form(Form $form): Form
->afterStateUpdated(function (Closure $set, $state) {
$set('slug', Str::slug($state));
}),
- TinyEditor::make('content')->label(__('Post Content'))->showMenuBar()->required(),
+
+ TinyEditor::make('content')
+ ->label(__('Post Content'))
+ ->showMenuBar()
+ ->required(),
]),
- ])->columnSpan(3),
+ ])
+ ->columnSpan(3),
Grid::make()->schema([
Section::make(__('SEO'))
- ->description(__('SEO Settings'))
- ->schema([
- Hidden::make('user_id')->default(auth()->user()->id)->required(),
- Hidden::make('post_type')->default('page')->required(),
+ ->description(__('SEO Settings'))->schema([
+ Hidden::make('user_id')
+ ->required()
+ ->default(auth()->user()->id),
+
+ Hidden::make('post_type')
+ ->default('page')
+ ->required(),
+
Textarea::make('description')
->maxLength(255)
->label(__('Description'))
->hint(__('Write an excerpt for your post')),
- TextInput::make('slug')->required()->maxLength(255)->label(__('Post Slug')),
- Select::make('parent_id')->options(Post::wherePostType('page')->pluck('title', 'id'))->label(__('Parent Page')),
- TextInput::make('ordering')->integer()->label(__('Page Order'))->default(1),
+
+ TextInput::make('slug')
+ ->required()
+ ->maxLength(255)
+ ->label(__('Post Slug')),
+
+ Select::make('parent_id')
+ ->options(Post::wherePostType('page')->pluck('title', 'id'))
+ ->label(__('Parent Page')),
+
+ TextInput::make('ordering')
+ ->integer()
+ ->label(__('Page Order'))
+ ->default(1),
])
->collapsible(),
@@ -80,15 +101,23 @@ public static function form(Form $form): Form
->required()
->reactive()
->options(PostStatus::pluck('label', 'name')),
- TextInput::make('password')->label(__('Password'))->reactive()
+
+ TextInput::make('password')
+ ->label(__('Password'))
+ ->reactive()
->visible(fn (Closure $get): bool => $get('status') === 'private'),
- DateTimePicker::make('published_at')->label(__('published at'))->default(now()),
+
+ DateTimePicker::make('published_at')
+ ->label(__('published at'))
+ ->default(now()),
])
->collapsible(),
Section::make(__('Featured Image'))
->schema([
- SpatieMediaLibraryFileUpload::make('featured_image')->collection('pages')->label(''),
+ SpatieMediaLibraryFileUpload::make('featured_image')
+ ->collection('pages')
+ ->label(''),
])
->collapsible(),
])->columnSpan(1),
@@ -114,9 +143,12 @@ public static function table(Table $table): Table
])
->defaultSort('id', 'desc')
->filters([
- MultiSelectFilter::make('status')->options(PostStatus::pluck('label', 'name')),
+ MultiSelectFilter::make('status')
+ ->label(__('Status'))
+ ->options(PostStatus::pluck('label', 'name')),
- Filter::make('password')->label(__('Password Protected'))
+ Filter::make('password')
+ ->label(__('Password Protected'))
->query(fn (Builder $query): Builder => $query->whereNotNull('password')),
]);
}
diff --git a/src/Filament/Resources/PostResource.php b/src/Filament/Resources/PostResource.php
index c87aa34..7027724 100644
--- a/src/Filament/Resources/PostResource.php
+++ b/src/Filament/Resources/PostResource.php
@@ -51,7 +51,11 @@ public static function form(Form $form): Form
->afterStateUpdated(function (Closure $set, $state) {
$set('slug', Str::slug($state));
}),
- TinyEditor::make('content')->label(__('Post Content'))->showMenuBar()->required(),
+
+ TinyEditor::make('content')
+ ->label(__('Post Content'))
+ ->showMenuBar()
+ ->required(),
]),
])->columnSpan(3),
@@ -59,21 +63,36 @@ public static function form(Form $form): Form
Section::make(__('SEO'))
->description(__('SEO Settings'))
->schema([
- Hidden::make('user_id')->default(auth()->user()->id)->required(),
- Hidden::make('post_type')->default('post')->required(),
+ Hidden::make('user_id')
+ ->default(auth()->user()->id)
+ ->required(),
+
+ Hidden::make('post_type')
+ ->default('post')
+ ->required(),
+
Textarea::make('description')
->maxLength(255)
->label(__('Description'))
->hint(__('Write an excerpt for your post')),
- TextInput::make('slug')->required()->maxLength(255)->label(__('Post Slug')),
+
+ TextInput::make('slug')
+ ->required()
+ ->maxLength(255)
+ ->label(__('Post Slug')),
])
->collapsible(),
Section::make(__('Tags and Categories'))
->description(__('Tags and Categories Options'))
->schema([
- SpatieTagsInput::make('tags')->type('tag')->label(__('Tags')),
- SpatieTagsInput::make('category')->type('category')->label(__('Categories')),
+ SpatieTagsInput::make('tags')
+ ->type('tag')
+ ->label(__('Tags')),
+
+ SpatieTagsInput::make('category')
+ ->type('category')
+ ->label(__('Categories')),
])
->collapsible(),
@@ -86,16 +105,26 @@ public static function form(Form $form): Form
->required()
->reactive()
->options(PostStatus::pluck('label', 'name')),
- TextInput::make('password')->label(__('Password'))->reactive()
+
+ TextInput::make('password')
+ ->label(__('Password'))
+ ->reactive()
->visible(fn (Closure $get): bool => $get('status') === 'private'),
- DateTimePicker::make('published_at')->label(__('published at'))->default(now()),
- DateTimePicker::make('sticky_until')->label(__('Sticky Until')),
+
+ DateTimePicker::make('published_at')
+ ->label(__('published at'))
+ ->default(now()),
+
+ DateTimePicker::make('sticky_until')
+ ->label(__('Sticky Until')),
])
->collapsible(),
Section::make(__('Featured Image'))
->schema([
- SpatieMediaLibraryFileUpload::make('featured_image')->collection('posts')->label(''),
+ SpatieMediaLibraryFileUpload::make('featured_image')
+ ->collection('posts')
+ ->label(''),
])
->collapsible(),
])->columnSpan(1),
@@ -119,32 +148,47 @@ public static function table(Table $table): Table
->view('zeus-sky::filament.columns.status-desc')
->tooltip(fn (Post $record): string => $record->published_at->format('Y/m/d | H:i A')),
- SpatieTagsColumn::make('tags')->label(__('Post Tags'))->type('tag'),
- SpatieTagsColumn::make('category')->label(__('Post Category'))->type('category'),
+ SpatieTagsColumn::make('tags')
+ ->label(__('Post Tags'))
+ ->type('tag'),
+
+ SpatieTagsColumn::make('category')
+ ->label(__('Post Category'))
+ ->type('category'),
])
->defaultSort('id', 'desc')
->filters([
- MultiSelectFilter::make('status')->options(PostStatus::pluck('label', 'name')),
+ MultiSelectFilter::make('status')
+ ->label(__('Status'))
+ ->options(PostStatus::pluck('label', 'name')),
- Filter::make('password')->label(__('Password Protected'))
+ Filter::make('password')
+ ->label(__('Password Protected'))
->query(fn (Builder $query): Builder => $query->whereNotNull('password')),
- Filter::make('sticky')->label(__('Still Sticky'))
+ Filter::make('sticky')
+ ->label(__('Still Sticky'))
->query(fn (Builder $query): Builder => $query->sticky()),
- Filter::make('not_sticky')->label(__('Not Sticky'))
- ->query(fn (Builder $query): Builder => $query
- ->whereDate('sticky_until', '<=', now())
- ->orWhereNull('sticky_until')
+ Filter::make('not_sticky')
+ ->label(__('Not Sticky'))
+ ->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
- ->wherePostType('post')
- ->whereNotNull('sticky_until')
+ Filter::make('sticky_only')
+ ->label(__('Sticky Only'))
+ ->query(
+ fn (Builder $query): Builder => $query
+ ->wherePostType('post')
+ ->whereNotNull('sticky_until')
),
- MultiSelectFilter::make('tags')->relationship('tags', 'name')->label(__('Tags')),
+ MultiSelectFilter::make('tags')
+ ->relationship('tags', 'name')
+ ->label(__('Tags')),
]);
}
diff --git a/src/Filament/Resources/TagResource.php b/src/Filament/Resources/TagResource.php
index 451a74a..5dbfc02 100644
--- a/src/Filament/Resources/TagResource.php
+++ b/src/Filament/Resources/TagResource.php
@@ -34,11 +34,17 @@ public static function form(Form $form): Form
{
return $form
->schema([
- TextInput::make('name')->required()->maxLength(255)->label(__('Tag.Name'))->reactive()
+ TextInput::make('name')
+ ->required()
+ ->maxLength(255)
+ ->label(__('Tag.Name'))
+ ->reactive()
->afterStateUpdated(function (Closure $set, $state) {
$set('slug', Str::slug($state));
}),
- TextInput::make('slug')->required()->maxLength(255),
+ TextInput::make('slug')
+ ->required()
+ ->maxLength(255),
Select::make('type')
->options([
'tag' => 'Tag',
diff --git a/src/Http/Livewire/Faq.php b/src/Http/Livewire/Faq.php
index 8c33906..582771c 100644
--- a/src/Http/Livewire/Faq.php
+++ b/src/Http/Livewire/Faq.php
@@ -11,14 +11,14 @@ public function render()
{
seo()
->title(__('FAQ'))
- ->description(__('FAQs').' '.config('zeus-sky.site_description', 'Laravel'))
+ ->description(__('FAQs') . ' ' . config('zeus-sky.site_description', 'Laravel'))
->site(config('zeus-sky.site_title', 'Laravel'))
- ->rawTag('favicon', '')
- ->rawTag('')
+ ->rawTag('favicon', '')
+ ->rawTag('')
->withUrl()
->twitter();
- return view(app('theme').'.addons.faq')
+ return view(app('theme') . '.addons.faq')
->with('faqs', Faqs::get())
->layout(config('zeus-sky.layout'));
}
diff --git a/src/Http/Livewire/Page.php b/src/Http/Livewire/Page.php
index 3cd1ea1..417e64d 100644
--- a/src/Http/Livewire/Page.php
+++ b/src/Http/Livewire/Page.php
@@ -22,16 +22,17 @@ public function render()
seo()
->title($this->page->title)
- ->description(($this->page->description ?? '').' '.config('zeus-sky.site_description', 'Laravel'))
+ ->description(($this->page->description ?? '') . ' ' . config('zeus-sky.site_description', 'Laravel'))
->site(config('zeus-sky.site_title', 'Laravel'))
- ->rawTag('favicon', '')
- ->rawTag('')
+ ->rawTag('favicon', '')
+ ->rawTag('')
->withUrl()
->twitter();
- return view(app('theme').'.page')
+ return view(app('theme') . '.page')
->with([
'post' => $this->page,
+ /** @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/Post.php b/src/Http/Livewire/Post.php
index 8bfa6ea..aaab493 100644
--- a/src/Http/Livewire/Post.php
+++ b/src/Http/Livewire/Post.php
@@ -22,14 +22,14 @@ public function render()
seo()
->title($this->post->title)
- ->description(($this->post->description ?? '').' '.config('zeus-sky.site_description', 'Laravel'))
+ ->description(($this->post->description ?? '') . ' ' . config('zeus-sky.site_description', 'Laravel'))
->site(config('zeus-sky.site_title', 'Laravel'))
- ->rawTag('favicon', '')
- ->rawTag('')
+ ->rawTag('favicon', '')
+ ->rawTag('')
->withUrl()
->twitter();
- return view(app('theme').'.post')
+ return view(app('theme') . '.post')
->with('post', $this->post)
->with('related', postModel::related($this->post)->take(4)->get())
->layout(config('zeus-sky.layout'));
diff --git a/src/Http/Livewire/Posts.php b/src/Http/Livewire/Posts.php
index 624629d..e6e4b2b 100644
--- a/src/Http/Livewire/Posts.php
+++ b/src/Http/Livewire/Posts.php
@@ -38,14 +38,14 @@ public function render()
seo()
->title(__('Posts'))
- ->description(__('Posts').' '.config('zeus-sky.site_description', 'Laravel'))
+ ->description(__('Posts') . ' ' . config('zeus-sky.site_description', 'Laravel'))
->site(config('zeus-sky.site_title', 'Laravel'))
- ->rawTag('favicon', '')
- ->rawTag('')
+ ->rawTag('favicon', '')
+ ->rawTag('')
->withUrl()
->twitter();
- return view(app('theme').'.home')
+ return view(app('theme') . '.home')
->with([
'posts' => $posts,
'pages' => $pages,
diff --git a/src/Http/Livewire/SearchHelpers.php b/src/Http/Livewire/SearchHelpers.php
index 9eb84a3..8e36ec9 100644
--- a/src/Http/Livewire/SearchHelpers.php
+++ b/src/Http/Livewire/SearchHelpers.php
@@ -33,7 +33,7 @@ public function parsing(string $attribute, array $words): string
$pattern = [];
foreach ($replace as $k => $fword) {
- $pattern[] = '/\b('.$fword.')(?!>)\b/i';
+ $pattern[] = '/\b(' . $fword . ')(?!>)\b/i';
$replace[$k] = sprintf('$1', $class);
}
diff --git a/src/Http/Livewire/Tags.php b/src/Http/Livewire/Tags.php
index 5580241..33056fb 100644
--- a/src/Http/Livewire/Tags.php
+++ b/src/Http/Livewire/Tags.php
@@ -27,13 +27,13 @@ public function render()
seo()
->title($this->tag->name)
->site(config('app.name', 'Laravel'))
- ->description(config('zeus-sky.site_description').' '.__('Show All posts in').' '.$this->tag->name)
- ->rawTag('favicon', '')
- ->rawTag('')
+ ->description(config('zeus-sky.site_description') . ' ' . __('Show All posts in') . ' ' . $this->tag->name)
+ ->rawTag('favicon', '')
+ ->rawTag('')
->withUrl()
->twitter();
- return view(app('theme').'.category')
+ return view(app('theme') . '.category')
->with([
'posts' => $this->tag->postsPublished,
])
diff --git a/src/Models/Post.php b/src/Models/Post.php
index c2c3db2..3baecda 100644
--- a/src/Models/Post.php
+++ b/src/Models/Post.php
@@ -13,7 +13,11 @@
class Post extends Model implements HasMedia
{
- use HasFactory, HasTags, InteractsWithMedia, PostScope, HasTranslations;
+ use HasFactory;
+ use HasTags;
+ use InteractsWithMedia;
+ use PostScope;
+ use HasTranslations;
public $translatable = [
'title',
@@ -55,9 +59,9 @@ public function getRouteKeyName()
public function statusDesc(): string
{
$PostStatus = PostStatus::where('name', $this->status)->first();
- $icon = Blade::render('@svg("'.$PostStatus->icon.'","w-4 h-4 inline-flex")');
+ $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/PostStatus.php b/src/Models/PostStatus.php
index 43faa6d..eb1aa5d 100644
--- a/src/Models/PostStatus.php
+++ b/src/Models/PostStatus.php
@@ -11,14 +11,14 @@ class PostStatus extends Model
public function getRows()
{
return [
- ['name' => 'publish', 'label' => __('Publish'), 'class' => 'success', 'icon' => 'iconpark-filesuccessone'],
- ['name' => 'future', 'label' => __('Future'), 'class' => 'warning', 'icon' => 'iconpark-filedateone'],
- ['name' => 'draft', 'label' => __('Draft'), 'class' => 'secondary', 'icon' => 'iconpark-filehidingone'],
- ['name' => 'auto-draft', 'label' => __('Auto draft'), 'class' => 'primary', 'icon' => 'iconpark-filesearchone'],
- ['name' => 'pending', 'label' => __('Pending'), 'class' => 'info', 'icon' => 'iconpark-fileeditingone'],
- ['name' => 'private', 'label' => __('Private'), 'class' => 'danger', 'icon' => 'iconpark-filelockone'],
- ['name' => 'trash', 'label' => __('Trash'), 'class' => 'danger', 'icon' => 'iconpark-filetextone'],
- ['name' => 'inherit', 'label' => __('Inherit'), 'class' => 'primary', 'icon' => 'iconpark-filetipsone'],
+ ['name' => 'publish', 'label' => __('Publish'), 'class' => 'px-2 py-0.5 text-xs rounded-xl text-success-700 bg-success-500/10', 'icon' => 'iconpark-filesuccessone'],
+ ['name' => 'future', 'label' => __('Future'), 'class' => 'px-2 py-0.5 text-xs rounded-xl text-warning-700 bg-warning-500/10', 'icon' => 'iconpark-filedateone'],
+ ['name' => 'draft', 'label' => __('Draft'), 'class' => 'px-2 py-0.5 text-xs rounded-xl text-secondary-700 bg-secondary-500/10', 'icon' => 'iconpark-filehidingone'],
+ ['name' => 'auto-draft', 'label' => __('Auto draft'), 'class' => 'px-2 py-0.5 text-xs rounded-xl text-primary-700 bg-primary-500/10', 'icon' => 'iconpark-filesearchone'],
+ ['name' => 'pending', 'label' => __('Pending'), 'class' => 'px-2 py-0.5 text-xs rounded-xl text-info-700 bg-info-500/10', 'icon' => 'iconpark-fileeditingone'],
+ ['name' => 'private', 'label' => __('Private'), 'class' => 'px-2 py-0.5 text-xs rounded-xl text-danger-700 bg-danger-500/10', 'icon' => 'iconpark-filelockone'],
+ ['name' => 'trash', 'label' => __('Trash'), 'class' => 'px-2 py-0.5 text-xs rounded-xl text-danger-700 bg-danger-500/10', 'icon' => 'iconpark-filetextone'],
+ ['name' => 'inherit', 'label' => __('Inherit'), 'class' => 'px-2 py-0.5 text-xs rounded-xl text-primary-700 bg-primary-500/10', 'icon' => 'iconpark-filetipsone'],
];
}
diff --git a/src/Models/Tag.php b/src/Models/Tag.php
index 3251d9c..0efbc01 100644
--- a/src/Models/Tag.php
+++ b/src/Models/Tag.php
@@ -2,6 +2,10 @@
namespace LaraZeus\Sky\Models;
+/**
+ * @property string $slug
+ * @property string $type
+ */
class Tag extends \Spatie\Tags\Tag
{
public function posts()
diff --git a/src/SkyServiceProvider.php b/src/SkyServiceProvider.php
index 46ad603..28b8242 100644
--- a/src/SkyServiceProvider.php
+++ b/src/SkyServiceProvider.php
@@ -15,10 +15,10 @@ class SkyServiceProvider extends PluginServiceProvider
public function boot()
{
- View::share('theme', 'zeus-sky::themes.'.config('zeus-sky.theme'));
+ View::share('theme', 'zeus-sky::themes.' . config('zeus-sky.theme', 'zeus'));
App::singleton('theme', function () {
- return 'zeus-sky::themes.'.config('zeus-sky.theme');
+ return 'zeus-sky::themes.' . config('zeus-sky.theme', 'zeus');
});
return parent::boot();
diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php
new file mode 100644
index 0000000..5d36321
--- /dev/null
+++ b/tests/ExampleTest.php
@@ -0,0 +1,5 @@
+toBeTrue();
+});
diff --git a/tests/Pest.php b/tests/Pest.php
new file mode 100644
index 0000000..6e7808b
--- /dev/null
+++ b/tests/Pest.php
@@ -0,0 +1,5 @@
+in(__DIR__);
diff --git a/tests/TestCase.php b/tests/TestCase.php
new file mode 100644
index 0000000..de59bf6
--- /dev/null
+++ b/tests/TestCase.php
@@ -0,0 +1,40 @@
+ 'LaraZeus\Sky\\Database\\Factories\\' . class_basename($modelName) . 'Factory'
+ );
+ }
+
+ protected function getPackageProviders($app)
+ {
+ return [
+ LivewireServiceProvider::class,
+ FilamentServiceProvider::class,
+ SkyServiceProvider::class,
+ ];
+ }
+
+ public function getEnvironmentSetUp($app)
+ {
+ config()->set('database.default', 'testing');
+
+ /*
+ $migration = include __DIR__.'/../database/migrations/create_Sky_table.php.stub';
+ $migration->up();
+ */
+ }
+}