Skip to content

Commit f8e4f92

Browse files
wip testing
1 parent a2e4f87 commit f8e4f92

File tree

19 files changed

+167
-132
lines changed

19 files changed

+167
-132
lines changed

packages/builder/.github/pest.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

packages/builder/database/factories/ItemFactory.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ public function definition()
1818
{
1919
return [
2020
'title' => $this->faker->sentence,
21-
'slug' => $this->faker->slug,
21+
'slug' => $this->faker->unique()->slug,
22+
'featured_image_url' => $this->faker->image(null, 30, 30),
2223
'content' => $this->faker->paragraph,
23-
'status' => 'published',
24+
'gallery_image_urls' => null,
25+
'status' => 'draft',
2426
'type' => 'post',
27+
'author_id' => null,
28+
'publish_at' => null,
29+
'deleted_at' => null,
2530
];
2631
}
2732
}

packages/builder/database/migrations/create_items_table.php.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ return new class extends Migration
1717
$table->string('slug')->unique();
1818
$table->string('featured_image_url')->nullable();
1919
$table->text('content')->nullable();
20-
$table->json('gallery_imageurls')->nullable();
20+
$table->json('gallery_image_urls')->nullable();
2121
$table->string('status')->default('draft');
2222
$table->string('type')->default('post');
2323
$table->string('author_id')->nullable();

packages/builder/src/Commands/InstallCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Moox\Builder\Commands;
46

57
use Illuminate\Console\Command;
@@ -44,7 +46,7 @@ public function handle()
4446
if ($panelsToregister != null) {
4547
if (is_array($panelsToregister)) {
4648
foreach ($panelsToregister as $panelprovider) {
47-
$this->registerPlugins($providerPath.'/'.$panelprovider);
49+
$this->registerPlugins($providerPath . '/' . $panelprovider);
4850
}
4951
} else {
5052
$this->registerPlugins($panelsToregister);
@@ -136,11 +138,11 @@ public function registerPlugins(string $providerPath): void
136138
$newPlugins = '';
137139

138140
foreach ($pluginsToAdd as $plugin) {
139-
$searchPlugin = '/'.$plugin.'/';
141+
$searchPlugin = '/' . $plugin . '/';
140142
if (preg_match($searchPlugin, $content)) {
141143
warning("$plugin already registered.");
142144
} else {
143-
$newPlugins .= $intend.$namespace.'\\'.$plugin.$function."\n";
145+
$newPlugins .= $intend . $namespace . '\\' . $plugin . $function . "\n";
144146
}
145147
}
146148

@@ -155,7 +157,7 @@ public function registerPlugins(string $providerPath): void
155157

156158
$pluginsSection = " ->plugins([\n$newPlugins\n ]);";
157159
$placeholderPattern = '/(\->authMiddleware\(\[.*?\]\))\s*\;/s';
158-
$replacement = "$1\n".$pluginsSection;
160+
$replacement = "$1\n" . $pluginsSection;
159161
$newContent = preg_replace($placeholderPattern, $replacement, $content, 1);
160162
}
161163

@@ -182,7 +184,7 @@ public function getPanelProviderPath(): string|array
182184
);
183185
}
184186
if (count($providers) == 1) {
185-
$providerPath .= '/'.$providers[0]->getBasename();
187+
$providerPath .= '/' . $providers[0]->getBasename();
186188
}
187189

188190
return $providerPath;

packages/builder/src/ItemPlugin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Moox\Builder;
46

57
use Filament\Contracts\Plugin;

packages/builder/src/Models/Item.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Moox\Builder\Models;
46

57
use Illuminate\Database\Eloquent\Factories\HasFactory;

packages/builder/src/Resources/ItemResource.php

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Moox\Builder\Resources;
46

5-
use Camya\Filament\Forms\Components\TitleWithSlugInput;
6-
use Filament\Forms\Components\Actions;
7-
use Filament\Forms\Components\DateTimePicker;
8-
use Filament\Forms\Components\FileUpload;
7+
use Filament\Forms\Form;
8+
use Filament\Tables\Table;
9+
use Moox\Builder\Models\Item;
10+
use Filament\Resources\Resource;
911
use Filament\Forms\Components\Grid;
10-
use Filament\Forms\Components\MarkdownEditor;
11-
use Filament\Forms\Components\Section;
1212
use Filament\Forms\Components\Select;
13+
use Filament\Forms\Components\Actions;
14+
use Filament\Forms\Components\Section;
1315
use Filament\Forms\Components\Textarea;
14-
use Filament\Forms\Form;
15-
use Filament\Resources\Resource;
16-
use Filament\Tables\Actions\DeleteBulkAction;
1716
use Filament\Tables\Actions\EditAction;
18-
use Filament\Tables\Actions\RestoreBulkAction;
1917
use Filament\Tables\Actions\ViewAction;
20-
use Filament\Tables\Columns\ImageColumn;
2118
use Filament\Tables\Columns\TextColumn;
19+
use Filament\Tables\Columns\ImageColumn;
20+
use Filament\Forms\Components\FileUpload;
2221
use Filament\Tables\Filters\SelectFilter;
23-
use Filament\Tables\Table;
2422
use Illuminate\Database\Eloquent\Builder;
23+
use Filament\Forms\Components\DateTimePicker;
24+
use Filament\Forms\Components\MarkdownEditor;
25+
use Filament\Tables\Actions\DeleteBulkAction;
2526
use Illuminate\Database\Eloquent\SoftDeletes;
26-
use Moox\Builder\Models\Item;
27-
use Moox\Builder\Resources\ItemResource\Pages\CreateItem;
27+
use Filament\Tables\Actions\RestoreBulkAction;
28+
use Camya\Filament\Forms\Components\TitleWithSlugInput;
2829
use Moox\Builder\Resources\ItemResource\Pages\EditItem;
29-
use Moox\Builder\Resources\ItemResource\Pages\ListItem;
3030
use Moox\Builder\Resources\ItemResource\Pages\ViewItem;
31+
use Moox\Builder\Resources\ItemResource\Pages\ListItems;
32+
use Moox\Builder\Resources\ItemResource\Pages\CreateItem;
3133
use Moox\Builder\Resources\ItemResource\Widgets\ItemWidgets;
3234

3335
//use Moox\Core\Forms\Components\TitleWithSlugInput;
@@ -64,17 +66,18 @@ public static function form(Form $form): Form
6466
fieldSlug: 'slug', // The name of the field in your model that will store the slug.
6567
),
6668

67-
/*
68-
...TitleWithSlugInput::make('title')
69+
70+
/*TitleWithSlugInput::make('title')
6971
->titleLabel(__('core::core.title'))
7072
->slugLabel(__('core::core.slug'))
71-
->showSlugInput(fn ($record) => ! $record ||
72-
(config('builder.allow_slug_change_after_saved') || ! $record->exists) &&
73-
(config('builder.allow_slug_change_after_publish') || ! $record->published_at)
73+
->showSlugInput(
74+
fn($record) => ! $record ||
75+
(config('builder.allow_slug_change_after_saved') || ! $record->exists) &&
76+
(config('builder.allow_slug_change_after_publish') || ! $record->published_at)
7477
)
75-
->slugPrefix(url('/').'/'.config('builder.url_slug', 'items/'))
76-
->components(),
77-
*/
78+
->slugPrefix(url('/') . '/' . config('builder.url_slug', 'items/'))
79+
->components(),*/
80+
7881
FileUpload::make('featured_image_url')
7982
->label(__('core::core.featured_image_url')),
8083
MarkdownEditor::make('content')
@@ -99,8 +102,8 @@ public static function form(Form $form): Form
99102
->color('success')
100103
->button()
101104
->extraAttributes(['class' => 'w-full'])
102-
->action(fn ($record) => $record->restore())
103-
->visible(fn ($livewire, $record) => $record && $record->trashed() && $livewire instanceof ViewItem),
105+
->action(fn($record) => $record->restore())
106+
->visible(fn($livewire, $record) => $record && $record->trashed() && $livewire instanceof ViewItem),
104107
Actions\Action::make('save')
105108
->label(__('core::core.save'))
106109
->color('primary')
@@ -109,7 +112,7 @@ public static function form(Form $form): Form
109112
->action(function ($livewire) {
110113
$livewire instanceof CreateItem ? $livewire->create() : $livewire->save();
111114
})
112-
->visible(fn ($livewire) => $livewire instanceof CreateItem || $livewire instanceof EditItem),
115+
->visible(fn($livewire) => $livewire instanceof CreateItem || $livewire instanceof EditItem),
113116
Actions\Action::make('publish')
114117
->label(__('core::core.publish'))
115118
->color('success')
@@ -123,7 +126,7 @@ public static function form(Form $form): Form
123126
$livewire->form->fill($data);
124127
$livewire instanceof CreateItem ? $livewire->create() : $livewire->save();
125128
})
126-
->hidden(fn ($livewire, $record) => $record && $record->trashed()),
129+
->hidden(fn($livewire, $record) => $record && $record->trashed()),
127130
Actions\Action::make('saveAndCreateAnother')
128131
->label(__('core::core.save_and_create_another'))
129132
->color('secondary')
@@ -132,35 +135,35 @@ public static function form(Form $form): Form
132135
->action(function ($livewire) {
133136
$livewire->saveAndCreateAnother();
134137
})
135-
->visible(fn ($livewire) => $livewire instanceof CreateItem),
138+
->visible(fn($livewire) => $livewire instanceof CreateItem),
136139
Actions\Action::make('cancel')
137140
->label(__('core::core.cancel'))
138141
->color('secondary')
139142
->outlined()
140143
->extraAttributes(['class' => 'w-full'])
141-
->url(fn () => static::getUrl('index'))
142-
->visible(fn ($livewire) => $livewire instanceof CreateItem),
144+
->url(fn() => static::getUrl('index'))
145+
->visible(fn($livewire) => $livewire instanceof CreateItem),
143146
Actions\Action::make('edit')
144147
->label(__('core::core.edit'))
145148
->color('primary')
146149
->button()
147150
->extraAttributes(['class' => 'w-full'])
148-
->url(fn ($record) => static::getUrl('edit', ['record' => $record]))
149-
->visible(fn ($livewire, $record) => $livewire instanceof ViewItem && ! $record->trashed()),
151+
->url(fn($record) => static::getUrl('edit', ['record' => $record]))
152+
->visible(fn($livewire, $record) => $livewire instanceof ViewItem && ! $record->trashed()),
150153
Actions\Action::make('restore')
151154
->label(__('core::core.restore'))
152155
->color('success')
153156
->button()
154157
->extraAttributes(['class' => 'w-full'])
155-
->action(fn ($record) => $record->restore())
156-
->visible(fn ($livewire, $record) => $record && $record->trashed() && $livewire instanceof EditItem),
158+
->action(fn($record) => $record->restore())
159+
->visible(fn($livewire, $record) => $record && $record->trashed() && $livewire instanceof EditItem),
157160
Actions\Action::make('delete')
158161
->label(__('core::core.delete'))
159162
->color('danger')
160163
->link()
161164
->extraAttributes(['class' => 'w-full'])
162-
->action(fn ($record) => $record->delete())
163-
->visible(fn ($livewire, $record) => $record && ! $record->trashed() && $livewire instanceof EditItem),
165+
->action(fn($record) => $record->delete())
166+
->visible(fn($livewire, $record) => $record && ! $record->trashed() && $livewire instanceof EditItem),
164167
]),
165168
Select::make('type')
166169
->options(static::getModel()::getTypeOptions())
@@ -172,11 +175,11 @@ public static function form(Form $form): Form
172175

173176
Select::make('author_id')
174177
->label(__('core::core.author'))
175-
->options(fn () => static::getAuthorOptions())
176-
->default(fn () => auth()->id())
178+
->options(fn() => static::getAuthorOptions())
179+
->default(fn() => auth()->id())
177180
->required()
178181
->searchable()
179-
->visible(fn () => static::shouldShowAuthorField()),
182+
->visible(fn() => static::shouldShowAuthorField()),
180183
]),
181184
// TODO: Taxonomy Plugin
182185
])
@@ -219,22 +222,22 @@ public static function table(Table $table): Table
219222
->toggleable(),
220223
ImageColumn::make('author.avatar_url')
221224
->label(__('core::core.author'))
222-
->tooltip(fn ($record) => $record->author?->name)
225+
->tooltip(fn($record) => $record->author?->name)
223226
->alignment('center')
224227
->circular()
225-
->visible(fn () => static::shouldShowAuthorField())
228+
->visible(fn() => static::shouldShowAuthorField())
226229
->toggleable(),
227230
TextColumn::make('type')
228231
->label(__('core::core.type'))
229232
->visible(! empty(config('builder.types')))
230-
->formatStateUsing(fn ($record): string => config('builder.types')[$record->type] ?? ucfirst($record->type))
233+
->formatStateUsing(fn($record): string => config('builder.types')[$record->type] ?? ucfirst($record->type))
231234
->sortable(),
232235
TextColumn::make('status')
233236
->label(__('core::core.status'))
234237
->alignment('center')
235238
->badge()
236-
->formatStateUsing(fn (string $state): string => strtoupper($state))
237-
->color(fn (string $state): string => match ($state) {
239+
->formatStateUsing(fn(string $state): string => strtoupper($state))
240+
->color(fn(string $state): string => match ($state) {
238241
'draft' => 'primary',
239242
'published' => 'success',
240243
'scheduled' => 'info',
@@ -253,7 +256,7 @@ public static function table(Table $table): Table
253256
->defaultSort('slug', 'desc')
254257
->actions([
255258
ViewAction::make(),
256-
EditAction::make()->hidden(fn () => in_array(static::getCurrentTab(), ['trash', 'deleted'])),
259+
EditAction::make()->hidden(fn() => in_array(static::getCurrentTab(), ['trash', 'deleted'])),
257260
])
258261
->bulkActions([
259262
DeleteBulkAction::make()->hidden(function () use ($currentTab) {
@@ -284,7 +287,7 @@ public static function getRelations(): array
284287
public static function getPages(): array
285288
{
286289
return [
287-
'index' => ListItem::route('/'),
290+
'index' => ListItems::route('/'),
288291
'edit' => EditItem::route('/{record}/edit'),
289292
'create' => CreateItem::route('/create'),
290293
'view' => ViewItem::route('/{record}'),

packages/builder/src/Resources/ItemResource/Pages/CreateItem.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Moox\Builder\Resources\ItemResource\Pages;
46

57
use Filament\Resources\Pages\CreateRecord;

packages/builder/src/Resources/ItemResource/Pages/EditItem.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Moox\Builder\Resources\ItemResource\Pages;
46

57
use Filament\Actions\DeleteAction;

0 commit comments

Comments
 (0)