Skip to content

Commit

Permalink
Adding system updaes
Browse files Browse the repository at this point in the history
  • Loading branch information
khalil khassep committed May 8, 2024
1 parent 57f701a commit 9d3ed4b
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 38 deletions.
3 changes: 3 additions & 0 deletions src/Filament/Resources/FaqResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 3 additions & 0 deletions src/Filament/Resources/LibraryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
33 changes: 19 additions & 14 deletions src/Filament/Resources/NavigationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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'))
Expand All @@ -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')
Expand Down Expand Up @@ -117,16 +121,17 @@ 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()
->icon(null),
DeleteAction::make()
->icon(null),
])
->filters([

]);
->filters([]);
}

public static function getPages(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 ;
}
}
57 changes: 34 additions & 23 deletions src/Filament/Resources/PageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -56,6 +57,7 @@ public static function getEloquentQuery(): Builder
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
PanelScope::class,
]);
}

Expand Down Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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())
Expand Down
15 changes: 15 additions & 0 deletions src/Filament/Resources/PageResource/Pages/CreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 ;
}
}
4 changes: 4 additions & 0 deletions src/Filament/Resources/PostResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<PostScope>
class PostResource extends SkyResource
Expand Down Expand Up @@ -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'))
Expand Down
17 changes: 16 additions & 1 deletion src/Filament/Resources/PostResource/Pages/CreatePost.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 ;
}
}
3 changes: 3 additions & 0 deletions src/Filament/Resources/TagResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 9d3ed4b

Please sign in to comment.