Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions admin/app/Filament/Resources/FaqResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources;

use App\Filament\Resources\FaqResource\Pages\CreateFaq;
use App\Filament\Resources\FaqResource\Pages\EditFaq;
use App\Filament\Resources\FaqResource\Pages\ListFaqs;
use App\Models\Faq;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class FaqResource extends Resource
{
protected static ?string $model = Faq::class;

protected static string | \UnitEnum | null $navigationGroup = 'Content';

protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-question-mark-circle';

protected static ?int $navigationSort = 7;

public static function form(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('heading')
->required()
->maxLength(255)
->columnSpanFull()
->hintIcon('heroicon-o-information-circle')
->hintIconTooltip('The question text shown to the visitor.'),
Textarea::make('content')
->required()
->rows(5)
->columnSpanFull()
->hintIcon('heroicon-o-information-circle')
->hintIconTooltip('The answer to the question.'),
TextInput::make('order')
->numeric()
->default(0)
->hintIcon('heroicon-o-information-circle')
->hintIconTooltip('Display order — lower numbers appear first.'),
TextInput::make('position')
->nullable()
->maxLength(100)
->hintIcon('heroicon-o-information-circle')
->hintIconTooltip('Leave empty to show on the main FAQ page. Set a value (e.g. "homepage", "products") to display in that specific position.'),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('heading')
->limit(50)
->wrap()
->searchable(),
TextColumn::make('order')
->sortable(),
TextColumn::make('position')
->placeholder('FAQ page')
->sortable(),
TextColumn::make('created_at')
->dateTime()
->toggleable(isToggledHiddenByDefault: true),
TextColumn::make('updated_at')
->dateTime()
->toggleable(isToggledHiddenByDefault: true),
])
->defaultSort('order')
->filters([
//
])
->recordActions([
EditAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}

public static function getRelations(): array
{
return [];
}

public static function getPages(): array
{
return [
'index' => ListFaqs::route('/'),
'create' => CreateFaq::route('/create'),
'edit' => EditFaq::route('/{record}/edit'),
];
}
}
18 changes: 18 additions & 0 deletions admin/app/Filament/Resources/FaqResource/Pages/CreateFaq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\FaqResource\Pages;

use App\Filament\Resources\FaqResource;
use Filament\Resources\Pages\CreateRecord;

class CreateFaq extends CreateRecord
{
protected static string $resource = FaqResource::class;

protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}
}
26 changes: 26 additions & 0 deletions admin/app/Filament/Resources/FaqResource/Pages/EditFaq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\FaqResource\Pages;

use App\Filament\Resources\FaqResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;

class EditFaq extends EditRecord
{
protected static string $resource = FaqResource::class;

protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}

protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
23 changes: 23 additions & 0 deletions admin/app/Filament/Resources/FaqResource/Pages/ListFaqs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\FaqResource\Pages;

use App\Filament\Resources\FaqResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;

class ListFaqs extends ListRecords
{
protected static string $resource = FaqResource::class;

protected ?string $subheading = 'Manage frequently asked questions shown on the FAQ page and other positions (e.g. homepage).';

protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
27 changes: 27 additions & 0 deletions admin/app/Models/Faq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace App\Models;

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

/**
* @property positive-int $id
* @property string $heading
* @property string $content
* @property int $order
* @property string|null $position
*/
class Faq extends Model
{
use HasFactory;

protected $fillable = [
'heading',
'content',
'order',
'position',
];
}
27 changes: 27 additions & 0 deletions admin/database/factories/FaqFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\Faq;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends Factory<Faq>
*/
class FaqFactory extends Factory
{
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'heading' => fake()->sentence(6),
'content' => fake()->paragraph(),
'order' => fake()->numberBetween(0, 100),
'position' => fake()->optional()->randomElement(['homepage', 'products']),
];
}
}
27 changes: 27 additions & 0 deletions admin/database/migrations/2026_06_20_000007_create_faqs_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::create('faqs', function (Blueprint $table): void {
$table->id();
$table->string('heading');
$table->text('content');
$table->unsignedSmallInteger('order')->default(0);
$table->string('position')->nullable();
$table->timestamps();
});
}

public function down(): void
{
Schema::dropIfExists('faqs');
}
};
18 changes: 18 additions & 0 deletions admin/database/seeders/FaqSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Database\Seeders;

use App\Models\Faq;
use Illuminate\Database\Seeder;

class FaqSeeder extends Seeder
{
public function run(): void
{
Faq::all()->each->delete();

Faq::factory()->count(20)->create();
}
}
1 change: 1 addition & 0 deletions admin/database/seeders/TestSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function run(): void
SliderSeeder::class,
MenuSeeder::class,
PageSeeder::class,
FaqSeeder::class,
]);
}
}
1 change: 1 addition & 0 deletions admin/docs/CACHE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Legend: `[ ]` not started, `[x]` implemented.
| 6 | `products.category.{category_id}` | Published products list for a category page | 15 min | Product saved / deleted |
| 7 | `varieties.product.{product_id}` | All varieties for a product (price, inventory, status) | 15 min | Variety saved / deleted |
| 9 | `pages.{slug}` | Single published page record | 1 hour | Page saved / deleted |
| 10 | `faqs.{position}` | FAQs for a given position (null = main FAQ page) | 1 hour | FAQ saved / deleted |

---

Expand Down
5 changes: 4 additions & 1 deletion admin/docs/IMPLEMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ Catalog layer and platform basics.
- [x] Sliders + Slides (each slide has one polymorphic image via `images` table)
- [x] Menus + Menu Items (nested via `parent_id`; optional polymorphic image per item)
- [x] Pages (CMS static pages; polymorphic image; SCHEDULED status with `published_at`)
- [x] FAQs (question + answer; `order` and nullable `position` for placement context)
- [~] Addresses (model only, no resource yet)

Sample data for manual admin testing lives in `TestSeeder` (`php artisan db:seed --class=TestSeeder`); `DatabaseSeeder` holds only necessary data.

Cross-cutting improvements landed:
- Navigation groups reorganized: Catalog / Promotions / Attribute / Content / Address.
- `CACHE.md` added to track identified-but-not-implemented cache keys.
- `ColorPicker` added to Variety form; `ColorColumn` in the table. Auto-fill from attribute only triggers when `attribute_id` changes, preserving manual overrides.
- Documentation reorganized into `docs/` directory (`ShoFlow db doc.md`, `VARIETY_GUIDE.md`, `IMPLEMENTATION.md`, `CACHE.md`).

## Phase 0 - Finish current branch (`implement_variety`)

Expand Down Expand Up @@ -66,7 +69,7 @@ Depend mostly on Images only.
- [x] Sliders + Slides
- [x] Menus + Menu Items
- [x] Pages
- [ ] FAQs
- [x] FAQs
- [ ] Reviews
- [ ] Wishlists
- [ ] Tags
Expand Down
Loading
Loading