diff --git a/composer.json b/composer.json index 08c0ab2..861b36e 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "lara-zeus/sky", + "name": "lara-zeus-kh/palsky", "description": "Lara-zeus sky is simple CMS for your website. It includes posts, pages, tags, and categories.", "keywords": [ "laravel", @@ -24,8 +24,8 @@ "type": "library", "authors": [ { - "name": "php coder", - "email": "info@larazeus.com", + "name": "khalil khassep", + "email": "khalil.khassep@gmail.com", "role": "Owner" } ], diff --git a/src/Filament/Resources/FaqResource.php b/src/Filament/Resources/FaqResource.php index 57446cc..6155eb5 100644 --- a/src/Filament/Resources/FaqResource.php +++ b/src/Filament/Resources/FaqResource.php @@ -79,6 +79,9 @@ public static function table(Table $table): Table ->label(__('FAQ Categories')) ->toggleable() ->type('faq'), + TextColumn::make('panels.panel_name') + ->label(__('Panel')), + ]) ->filters([ SelectFilter::make('tags') diff --git a/src/Filament/Resources/LibraryResource.php b/src/Filament/Resources/LibraryResource.php index 7a90717..ed41f69 100644 --- a/src/Filament/Resources/LibraryResource.php +++ b/src/Filament/Resources/LibraryResource.php @@ -146,6 +146,9 @@ public static function table(Table $table): Table ->label(__('Library Tags')) ->toggleable() ->type('library'), + TextColumn::make('panels.panel_name') + ->label(__('Panel')), + ]) ->actions(static::getActions()) ->filters([ diff --git a/src/Filament/Resources/NavigationResource.php b/src/Filament/Resources/NavigationResource.php index 7c9b7ff..293320c 100644 --- a/src/Filament/Resources/NavigationResource.php +++ b/src/Filament/Resources/NavigationResource.php @@ -8,6 +8,7 @@ use Filament\Forms\Components\TextInput; use Filament\Forms\Components\View; use Filament\Forms\Components\ViewField; +use Filament\Forms\Components\Select; use Filament\Forms\Form; use Filament\Forms\Set; use Filament\Tables\Actions\DeleteAction; @@ -29,7 +30,7 @@ class NavigationResource extends SkyResource public static function disableTimestamps(bool $condition = true): void { - static::$showTimestamps = ! $condition; + static::$showTimestamps = !$condition; } public static function form(Form $form): Form @@ -41,13 +42,13 @@ public static function form(Form $form): Form ->label(__('zeus-sky::filament-navigation.attributes.name')) ->reactive() ->debounce() - ->afterStateUpdated(function (?string $state, Set $set) { - if (! $state) { - return; - } + // ->afterStateUpdated(function (?string $state, Set $set) { + // if (!$state) { + // return; + // } - $set('handle', Str::slug($state)); - }) + // $set('handle', Str::slug($state)); + // }) ->required(), ViewField::make('items') ->label(__('zeus-sky::filament-navigation.attributes.items')) @@ -60,10 +61,13 @@ public static function form(Form $form): Form ]), Group::make([ Section::make('')->schema([ - TextInput::make('handle') - ->label(__('zeus-sky::filament-navigation.attributes.handle')) - ->required() - ->unique(column: 'handle', ignoreRecord: true), + Select::make('handle') + ->label(__('Location')) + ->options([ + 'main-header-menu' => __('Header menu'), + ]) + ->required(), + //->unique(column: 'handle', ignoreRecord: true), View::make('zeus::filament.card-divider') ->visible(static::$showTimestamps), Placeholder::make('created_at') @@ -117,6 +121,9 @@ public static function table(Table $table): Table ->label(__('zeus-sky::filament-navigation.attributes.updated_at')) ->dateTime() ->sortable(), + TextColumn::make('panels.panel_name') + ->label(__('Panel')), + ]) ->actions([ EditAction::make() @@ -124,9 +131,7 @@ public static function table(Table $table): Table DeleteAction::make() ->icon(null), ]) - ->filters([ - - ]); + ->filters([]); } public static function getPages(): array diff --git a/src/Filament/Resources/NavigationResource/Pages/CreateNavigation.php b/src/Filament/Resources/NavigationResource/Pages/CreateNavigation.php index a6be7c8..a2e21bd 100644 --- a/src/Filament/Resources/NavigationResource/Pages/CreateNavigation.php +++ b/src/Filament/Resources/NavigationResource/Pages/CreateNavigation.php @@ -2,6 +2,9 @@ namespace LaraZeus\Sky\Filament\Resources\NavigationResource\Pages; +use App\Models\Panel; +use Filament\Facades\Filament; +use Illuminate\Database\Eloquent\Model; use Filament\Resources\Pages\CreateRecord; use LaraZeus\Sky\Filament\Resources\NavigationResource; @@ -10,4 +13,17 @@ class CreateNavigation extends CreateRecord use NavigationResource\Pages\Concerns\HandlesNavigationBuilder; protected static string $resource = NavigationResource::class; + + protected function handleRecordCreation(array $data): Model + { + // attach cereated record to panel + + $panel = Panel::findByName(Filament::getCurrentPanel()->getId()); + + $record = static::getModel()::create($data) ; + + $panel->posts()->attach($record->id); + + return $record ; + } } diff --git a/src/Filament/Resources/PageResource.php b/src/Filament/Resources/PageResource.php index 9011d50..d5ff44a 100644 --- a/src/Filament/Resources/PageResource.php +++ b/src/Filament/Resources/PageResource.php @@ -2,39 +2,40 @@ namespace LaraZeus\Sky\Filament\Resources; -use Filament\Forms\Components\DateTimePicker; +use Filament\Forms\Get; +use Filament\Forms\Set; +use Filament\Forms\Form; +use Filament\Tables\Table; +use Illuminate\Support\Str; +use LaraZeus\Sky\SkyPlugin; +use LaraZeus\Sky\Models\Post; +use Filament\Forms\Components\Tabs; +use Filament\Tables\Actions\Action; +use Filament\Tables\Filters\Filter; use Filament\Forms\Components\Hidden; -use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\Select; -use Filament\Forms\Components\SpatieMediaLibraryFileUpload; -use Filament\Forms\Components\Tabs; use Filament\Forms\Components\Textarea; +use Filament\Tables\Actions\EditAction; +use Filament\Tables\Columns\TextColumn; +use Filament\Tables\Columns\ViewColumn; use Filament\Forms\Components\TextInput; -use Filament\Forms\Components\ToggleButtons; -use Filament\Forms\Form; -use Filament\Forms\Get; -use Filament\Forms\Set; -use Filament\Tables\Actions\Action; use Filament\Tables\Actions\ActionGroup; use Filament\Tables\Actions\DeleteAction; +use Filament\Tables\Filters\SelectFilter; +use Illuminate\Database\Eloquent\Builder; +use Filament\Forms\Components\Placeholder; +use Filament\Tables\Actions\RestoreAction; +use Filament\Tables\Filters\TrashedFilter; +use Filament\Forms\Components\ToggleButtons; +use Filament\Forms\Components\DateTimePicker; use Filament\Tables\Actions\DeleteBulkAction; -use Filament\Tables\Actions\EditAction; use Filament\Tables\Actions\ForceDeleteAction; -use Filament\Tables\Actions\ForceDeleteBulkAction; -use Filament\Tables\Actions\RestoreAction; use Filament\Tables\Actions\RestoreBulkAction; -use Filament\Tables\Columns\ViewColumn; -use Filament\Tables\Filters\Filter; -use Filament\Tables\Filters\SelectFilter; -use Filament\Tables\Filters\TrashedFilter; -use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; +use Filament\Tables\Actions\ForceDeleteBulkAction; use Illuminate\Database\Eloquent\SoftDeletingScope; -use Illuminate\Support\Str; use LaraZeus\Sky\Filament\Resources\PageResource\Pages; -use LaraZeus\Sky\Models\Post; -use LaraZeus\Sky\SkyPlugin; - +use Filament\Forms\Components\SpatieMediaLibraryFileUpload; +use App\Models\Scopes\PanelScope; class PageResource extends SkyResource { protected static ?string $slug = 'pages'; @@ -56,6 +57,7 @@ public static function getEloquentQuery(): Builder return parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, + PanelScope::class, ]); } @@ -142,7 +144,7 @@ public static function form(Form $form): Form SpatieMediaLibraryFileUpload::make('featured_image_upload') ->collection('pages') ->disk(SkyPlugin::get()->getUploadDisk()) - ->directory(SkyPlugin::get()->getUploadDirectory()) + ->directory(SkyPlugin::get()->getUploadDirectory().'kh') ->visible(fn (Get $get) => $get('featured_image_type') === 'upload') ->label(''), TextInput::make('featured_image') @@ -154,6 +156,12 @@ public static function form(Form $form): Form ]); } + protected function mutateFormDataBeforeFill(array $data): array + { + dd($data); + return $data; + } + public static function table(Table $table): Table { return $table @@ -172,6 +180,9 @@ public static function table(Table $table): Table ->toggleable() ->view('zeus::filament.columns.status-desc') ->tooltip(fn (Post $record): string => $record->published_at->format('Y/m/d | H:i A')), + TextColumn::make('panels.panel_name') + ->label(__('Panel')), + ]) ->defaultSort('id', 'desc') ->actions(static::getActions()) diff --git a/src/Filament/Resources/PageResource/Pages/CreatePage.php b/src/Filament/Resources/PageResource/Pages/CreatePage.php index 0461e83..72e14a5 100644 --- a/src/Filament/Resources/PageResource/Pages/CreatePage.php +++ b/src/Filament/Resources/PageResource/Pages/CreatePage.php @@ -2,7 +2,10 @@ namespace LaraZeus\Sky\Filament\Resources\PageResource\Pages; +use App\Models\Panel; +use Filament\Facades\Filament; use Filament\Actions\LocaleSwitcher; +use Illuminate\Database\Eloquent\Model; use Filament\Resources\Pages\CreateRecord; use LaraZeus\Sky\Filament\Resources\PageResource; @@ -18,4 +21,16 @@ protected function getHeaderActions(): array LocaleSwitcher::make(), ]; } + protected function handleRecordCreation(array $data): Model + { + // attach cereated record to panel + + $panel = Panel::findByName(Filament::getCurrentPanel()->getId()); + + $record = static::getModel()::create($data) ; + + $panel->posts()->attach($record->id); + + return $record ; + } } diff --git a/src/Filament/Resources/PostResource.php b/src/Filament/Resources/PostResource.php index adf5a5e..7b3defc 100644 --- a/src/Filament/Resources/PostResource.php +++ b/src/Filament/Resources/PostResource.php @@ -35,6 +35,7 @@ use LaraZeus\Sky\Filament\Resources\PostResource\Pages; use LaraZeus\Sky\Models\Post; use LaraZeus\Sky\SkyPlugin; +use Filament\Tables\Columns\TextColumn; // @mixin Builder class PostResource extends SkyResource @@ -182,6 +183,9 @@ public static function table(Table $table): Table ->label(__('Post Tags')) ->toggleable(isToggledHiddenByDefault: true) ->type('tag'), + TextColumn::make('panels.panel_name') + ->label(__('Panel')), + SpatieTagsColumn::make('category') ->label(__('Post Category')) diff --git a/src/Filament/Resources/PostResource/Pages/CreatePost.php b/src/Filament/Resources/PostResource/Pages/CreatePost.php index 30a769a..79217ab 100644 --- a/src/Filament/Resources/PostResource/Pages/CreatePost.php +++ b/src/Filament/Resources/PostResource/Pages/CreatePost.php @@ -4,8 +4,10 @@ use Filament\Actions\LocaleSwitcher; use Filament\Resources\Pages\CreateRecord; +use Illuminate\Database\Eloquent\Model; use LaraZeus\Sky\Filament\Resources\PostResource; - +use Filament\Facades\Filament; +use App\Models\Panel; class CreatePost extends CreateRecord { use CreateRecord\Concerns\Translatable; @@ -18,4 +20,17 @@ protected function getHeaderActions(): array LocaleSwitcher::make(), ]; } + + protected function handleRecordCreation(array $data): Model + { + // attach cereated record to panel + + $panel = Panel::findByName(Filament::getCurrentPanel()->getId()); + + $record = static::getModel()::create($data) ; + + $panel->posts()->attach($record->id); + + return $record ; + } } diff --git a/src/Filament/Resources/TagResource.php b/src/Filament/Resources/TagResource.php index 5fa8a32..067e467 100644 --- a/src/Filament/Resources/TagResource.php +++ b/src/Filament/Resources/TagResource.php @@ -71,6 +71,9 @@ public static function table(Table $table): Table ? $record->{$record->type}()->count() : 0 ), + TextColumn::make('panels.panel_name') + ->label(__('Panel')), + ]) ->filters([ SelectFilter::make('type')