Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
23a5491
feat: adding pages and sections resource with test and other things
Aug 1, 2025
236f929
reverting User workbench
Aug 1, 2025
d7de82a
fix: remove unnecessary enums sections
Aug 1, 2025
40cc2fe
refactor: implement feedback and clean up tests
Aug 8, 2025
9366788
refactor: remove redundant code and standardize test naming
Aug 10, 2025
3567d7b
refactor: remove redundant code and standardize test naming
Aug 10, 2025
e1d0861
Merge branch 'main' of github.com:thapacodes4u/eclipsephp-cms-plugin …
Aug 23, 2025
b84cbc2
feat: implement pages and sections with tenant scoping & navigation
Sep 3, 2025
a2590b6
Refactor: Using right URL for dynamic section & Page filtering accord…
Sep 3, 2025
e492285
Refactor: renaming the query string & also adding it to the create ac…
Sep 3, 2025
cc92be7
Fixing: SQL error when creating new page
Sep 3, 2025
a05dd92
feat: separate pages and sections management with improved navigation
Sep 30, 2025
02a769e
refactor: improve seeder and remove unnecessary view permissions
Sep 30, 2025
6960fb7
fix: section filter now persists when toggling columns
Sep 30, 2025
ce6a370
Resolving conflict
Oct 8, 2025
c6abc1c
fix: resolving conflict & fixing failing tests
thapacodes4u Oct 16, 2025
dc0a915
fix: failing test
thapacodes4u Oct 16, 2025
0a2382f
fix: reduce section seeding, add WYSIWYG to short description, allow …
thapacodes4u Nov 10, 2025
63915cc
Merge branch 'main' into feat/pages-and-sections
thapacodes4u Nov 12, 2025
88e1d21
refactor: update translatable property format in Section model
SlimDeluxe Mar 25, 2026
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
59 changes: 47 additions & 12 deletions database/factories/PageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,67 @@

namespace Eclipse\Cms\Factories;

use Eclipse\Cms\Enums\PageStatus;
use Eclipse\Cms\Models\Page;
use Eclipse\Cms\Models\Section;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;

/**
* @experimental
*/
class PageFactory extends Factory
{
protected $model = Page::class;

public function definition(): array
{
$englishTitle = $this->faker->sentence(3);
$slovenianTitle = "SI: {$englishTitle}";

$englishShortText = $this->faker->text(200);
$slovenianShortText = "SI: {$englishShortText}";

$englishLongText = $this->faker->text(500);
$slovenianLongText = "SI: {$englishLongText}";

$slug = $this->faker->slug();

return [
'title' => $this->faker->word(),
'short_text' => $this->faker->text(),
'long_text' => $this->faker->text(),
'sef_key' => $this->faker->word(),
'code' => $this->faker->word(),
'status' => $this->faker->word(),
'type' => $this->faker->word(),
'title' => [
'en' => $englishTitle,
'sl' => $slovenianTitle,
],
'short_text' => [
'en' => $englishShortText,
'sl' => $slovenianShortText,
],
'long_text' => [
'en' => $englishLongText,
'sl' => $slovenianLongText,
],
'sef_key' => [
'en' => $slug,
'sl' => "{$slug}-si",
],
'code' => $this->faker->unique()->numerify('page-###-####'),
'status' => $this->faker->randomElement([PageStatus::Draft, PageStatus::Published]),
'type' => 'page',
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),

'section_id' => Section::factory(),
];
}

public function configure()
{
return $this->afterMaking(function (Page $page) {
if (! $page->section_id) {
$page->section_id = Section::factory()->create()->id;
}
});
}

public function forSection($section): static
{
return $this->state([
'section_id' => $section->id,
]);
}
}
43 changes: 35 additions & 8 deletions database/factories/SectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Eclipse\Cms\Enums\SectionType;
use Eclipse\Cms\Models\Section;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;

Expand All @@ -15,18 +14,46 @@ class SectionFactory extends Factory

public function definition(): array
{
$attrs = [
'name' => Str::of($this->faker->words(asText: true))->ucwords(),
'type' => $this->faker->randomElement(Arr::pluck(SectionType::cases(), 'name')),
$englishName = Str::of($this->faker->words(asText: true))->ucwords();
$slovenianName = "SI: {$englishName}";

return [
'name' => [
'en' => $englishName,
'sl' => $slovenianName,
],
'type' => $this->faker->randomElement(SectionType::cases()),
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
}

public function configure()
{
return $this->afterMaking(function (Section $section) {
if (config('eclipse-cms.tenancy.enabled')) {
$foreignKey = config('eclipse-cms.tenancy.foreign_key');
$currentValue = $section->getAttribute($foreignKey);

if (config('eclipse-cms.tenancy.enabled') && empty($attrs[config('eclipse-cms.tenancy.foreign_key')])) {
$class = config('eclipse-cms.tenancy.model');
$attrs[config('eclipse-cms.tenancy.foreign_key')] = $class::inRandomOrder()->first()?->id ?? $class::factory()->create()->id;
if (! $currentValue || $currentValue === null) {
$class = config('eclipse-cms.tenancy.model');
if (class_exists($class)) {
$newValue = $class::inRandomOrder()->first()?->id ?? $class::factory()->create()->id;
$section->setAttribute($foreignKey, $newValue);
}
}
}
});
}

public function forSite($site): static
{
if (config('eclipse-cms.tenancy.enabled')) {
return $this->state([
config('eclipse-cms.tenancy.foreign_key') => $site->id,
]);
}

return $attrs;
return $this;
}
}
49 changes: 47 additions & 2 deletions database/seeders/CmsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,62 @@

namespace Eclipse\Cms\Seeders;

use Eclipse\Cms\Models\Page;
use Eclipse\Cms\Models\Section;
use Illuminate\Database\Seeder;

class CmsSeeder extends Seeder
{
public function run(): void
{
Section::factory()
->count(3)
if (config('eclipse-cms.tenancy.enabled')) {
$tenantModel = config('eclipse-cms.tenancy.model');
$tenants = $tenantModel::all();

if ($tenants->isEmpty()) {
$tenants = collect([$tenantModel::factory()->create()]);
}

$tenants->each(function ($tenant): void {
$this->seedForTenant($tenant);
});
} else {
$this->seedWithoutTenancy();
}
}

protected function seedForTenant($tenant): void
{
$sections = Section::factory()
->forSite($tenant)
->count(2)
->create();

$sections->each(function (Section $section): void {
Page::factory()
->count(rand(2, 5))
->forSection($section)
->create();
});

$this
->call(BannerSeeder::class)
->call(MenuSeeder::class);
}

protected function seedWithoutTenancy(): void
{
$sections = Section::factory()
->count(2)
->create();

$sections->each(function (Section $section): void {
Page::factory()
->count(rand(2, 5))
->forSection($section)
->create();
});

$this
->call(BannerSeeder::class)
->call(MenuSeeder::class);
Expand Down
2 changes: 2 additions & 0 deletions src/Admin/Filament/Resources/BannerPositionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class BannerPositionResource extends Resource implements HasShieldPermissions

protected static ?string $pluralModelLabel = 'Banners';

protected static ?int $navigationSort = 202;

public static function getPermissionPrefixes(): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Eclipse\Cms\Models\Banner;
use Eclipse\Cms\Rules\BannerImageDimensionRule;
use Eclipse\Common\Filament\Tables\Columns\ImageColumn;
use Eclipse\Common\Helpers\MediaHelper;
use Filament\Actions;
use Filament\Forms;
Expand All @@ -14,6 +13,7 @@
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
use Filament\Tables;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
Expand Down Expand Up @@ -45,7 +45,6 @@ protected function getDynamicImageColumns(): array
return $imageTypes->map(function ($imageType) {
return ImageColumn::make("image_type_{$imageType->id}")
->label($imageType->name)
->preview()
->getStateUsing(function (Banner $record) use ($imageType) {
$locale = $this->activeLocale ?? app()->getLocale();
$image = $record->images->where('type_id', $imageType->id)->first();
Expand All @@ -64,12 +63,6 @@ protected function getDynamicImageColumns(): array

return null;
})
->title(function (Banner $record) use ($imageType) {
$locale = $this->activeLocale ?? app()->getLocale();

return $record->getTranslation('name', $locale).' - '.$imageType->name;
})
->link(fn (Banner $record) => $record->link ?? '#')
->sortable(false);
})->toArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Filament/Resources/MenuResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MenuResource extends Resource implements HasShieldPermissions

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

protected static ?int $navigationSort = 3;
protected static ?int $navigationSort = 201;

public static function form(Schema $schema): Schema
{
Expand Down
Loading
Loading