Add CMS module
Static content pages (CmsPage) manageable from a new Filament resource and readable via a public API endpoint. Wired into the admin panel with its own CmsPlugin and "CMS" navigation group.
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "modules/cms",
|
||||||
|
"description": "",
|
||||||
|
"type": "library",
|
||||||
|
"version": "1.0",
|
||||||
|
"license": "proprietary",
|
||||||
|
"require": {},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Modules\\Cms\\": "src/",
|
||||||
|
"Modules\\Cms\\Tests\\": "tests/",
|
||||||
|
"Modules\\Cms\\Database\\Factories\\": "database/factories/",
|
||||||
|
"Modules\\Cms\\Database\\Seeders\\": "database/seeders/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Modules\\Cms\\Providers\\CmsServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
use Modules\Cms\Models\CmsPage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Factory<CmsPage>
|
||||||
|
*/
|
||||||
|
class CmsPageFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'page' => fake()->unique()->slug(),
|
||||||
|
'title' => fake()->sentence(3),
|
||||||
|
'mm_title' => fake()->sentence(3),
|
||||||
|
'meta_tags' => fake()->words(3, true),
|
||||||
|
'meta_keywords' => fake()->words(3, true),
|
||||||
|
'content' => fake()->paragraphs(3, true),
|
||||||
|
'mm_content' => fake()->paragraphs(3, true),
|
||||||
|
'is_active' => true,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('cms_pages', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('page')->unique();
|
||||||
|
$table->string('title');
|
||||||
|
$table->string('mm_title');
|
||||||
|
$table->string('meta_tags')->nullable();
|
||||||
|
$table->string('meta_keywords')->nullable();
|
||||||
|
$table->longText('content')->nullable();
|
||||||
|
$table->longText('mm_content')->nullable();
|
||||||
|
$table->boolean('is_active')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cms_pages');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Modules\Cms\Http\Controllers\CmsPageController;
|
||||||
|
|
||||||
|
// CMS content (FAQ, About Us, Terms, etc.) is public and typically shown
|
||||||
|
// before the user logs in, so unlike the catalog/routing endpoints this
|
||||||
|
// group skips api.auth — throttle:api-read still rate-limits it by IP.
|
||||||
|
Route::prefix('api/v1')->middleware(['api', 'throttle:api-read'])->group(function () {
|
||||||
|
Route::get('/cms-pages', [CmsPageController::class, 'index'])->name('cms.pages.index');
|
||||||
|
Route::get('/cms-pages/{page}', [CmsPageController::class, 'show'])->name('cms.pages.show');
|
||||||
|
});
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms;
|
||||||
|
|
||||||
|
use Filament\Contracts\Plugin;
|
||||||
|
use Filament\Panel;
|
||||||
|
|
||||||
|
class CmsPlugin implements Plugin
|
||||||
|
{
|
||||||
|
public function getId(): string
|
||||||
|
{
|
||||||
|
return 'cms';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register(Panel $panel): void
|
||||||
|
{
|
||||||
|
$panel
|
||||||
|
->discoverResources(
|
||||||
|
in: __DIR__.'/Filament/Resources',
|
||||||
|
for: 'Modules\Cms\Filament\Resources',
|
||||||
|
)
|
||||||
|
->discoverPages(
|
||||||
|
in: __DIR__.'/Filament/Pages',
|
||||||
|
for: 'Modules\Cms\Filament\Pages',
|
||||||
|
)
|
||||||
|
->discoverWidgets(
|
||||||
|
in: __DIR__.'/Filament/Widgets',
|
||||||
|
for: 'Modules\Cms\Filament\Widgets',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function boot(Panel $panel): void {}
|
||||||
|
|
||||||
|
public static function make(): static
|
||||||
|
{
|
||||||
|
return app(static::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Filament\Resources\CmsPages;
|
||||||
|
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\Pages\CreateCmsPage;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\Pages\EditCmsPage;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\Pages\ListCmsPages;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\Schemas\CmsPageForm;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\Tables\CmsPagesTable;
|
||||||
|
use Modules\Cms\Models\CmsPage;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
class CmsPageResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = CmsPage::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedDocumentText;
|
||||||
|
|
||||||
|
protected static string|UnitEnum|null $navigationGroup = 'CMS';
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return CmsPageForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return CmsPagesTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListCmsPages::route('/'),
|
||||||
|
'create' => CreateCmsPage::route('/create'),
|
||||||
|
'edit' => EditCmsPage::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Filament\Resources\CmsPages\Pages;
|
||||||
|
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\CmsPageResource;
|
||||||
|
|
||||||
|
class CreateCmsPage extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CmsPageResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Filament\Resources\CmsPages\Pages;
|
||||||
|
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\CmsPageResource;
|
||||||
|
|
||||||
|
class EditCmsPage extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CmsPageResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
DeleteAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Filament\Resources\CmsPages\Pages;
|
||||||
|
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\CmsPageResource;
|
||||||
|
|
||||||
|
class ListCmsPages extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = CmsPageResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Filament\Resources\CmsPages\Schemas;
|
||||||
|
|
||||||
|
use Filament\Forms\Components\RichEditor;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Components\Toggle;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class CmsPageForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
TextInput::make('meta_tags')
|
||||||
|
->maxLength(255),
|
||||||
|
TextInput::make('meta_keywords')
|
||||||
|
->maxLength(255),
|
||||||
|
TextInput::make('page')
|
||||||
|
->required()
|
||||||
|
->unique(ignoreRecord: true)
|
||||||
|
->maxLength(255)
|
||||||
|
->helperText('Unique key used to look up this page, e.g. "miniapp_faq".'),
|
||||||
|
TextInput::make('title')
|
||||||
|
->required()
|
||||||
|
->maxLength(255),
|
||||||
|
TextInput::make('mm_title')
|
||||||
|
->required()
|
||||||
|
->maxLength(255),
|
||||||
|
RichEditor::make('content')
|
||||||
|
->columnSpanFull(),
|
||||||
|
RichEditor::make('mm_content')
|
||||||
|
->columnSpanFull(),
|
||||||
|
Toggle::make('is_active')
|
||||||
|
->required()
|
||||||
|
->default(true),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Filament\Resources\CmsPages\Tables;
|
||||||
|
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Tables\Columns\IconColumn;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class CmsPagesTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('page')
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('title')
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('mm_title')
|
||||||
|
->searchable(),
|
||||||
|
IconColumn::make('is_active')
|
||||||
|
->boolean(),
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->defaultSort('created_at', 'desc')
|
||||||
|
->filters([
|
||||||
|
TernaryFilter::make('is_active'),
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make(),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\Cms\Http\Resources\CmsPageResource;
|
||||||
|
use Modules\Cms\Models\CmsPage;
|
||||||
|
|
||||||
|
class CmsPageController extends Controller
|
||||||
|
{
|
||||||
|
public function index(): AnonymousResourceCollection
|
||||||
|
{
|
||||||
|
return CmsPageResource::collection(
|
||||||
|
CmsPage::query()->where('is_active', true)->paginate()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(string $page): CmsPageResource
|
||||||
|
{
|
||||||
|
$cmsPage = CmsPage::query()
|
||||||
|
->where('page', $page)
|
||||||
|
->where('is_active', true)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
return new CmsPageResource($cmsPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class CmsPageResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'page' => $this->page,
|
||||||
|
'title' => $this->title,
|
||||||
|
'mm_title' => $this->mm_title,
|
||||||
|
'meta_tags' => $this->meta_tags,
|
||||||
|
'meta_keywords' => $this->meta_keywords,
|
||||||
|
'content' => $this->content,
|
||||||
|
'mm_content' => $this->mm_content,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Modules\Cms\Database\Factories\CmsPageFactory;
|
||||||
|
use Spatie\Activitylog\Models\Concerns\LogsActivity;
|
||||||
|
use Spatie\Activitylog\Support\LogOptions;
|
||||||
|
|
||||||
|
class CmsPage extends Model
|
||||||
|
{
|
||||||
|
/** @use HasFactory<CmsPageFactory> */
|
||||||
|
use HasFactory, LogsActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full CRUD audit trail — CMS content writes are staff-only and
|
||||||
|
* infrequent, so logging every attribute change is affordable
|
||||||
|
* (domain.md §6; T6.2).
|
||||||
|
*/
|
||||||
|
public function getActivitylogOptions(): LogOptions
|
||||||
|
{
|
||||||
|
return LogOptions::defaults()
|
||||||
|
->logFillable()
|
||||||
|
->logOnlyDirty()
|
||||||
|
->dontLogEmptyChanges()
|
||||||
|
->useLogName('cms');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'page',
|
||||||
|
'title',
|
||||||
|
'mm_title',
|
||||||
|
'meta_tags',
|
||||||
|
'meta_keywords',
|
||||||
|
'content',
|
||||||
|
'mm_content',
|
||||||
|
'is_active',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Cms\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class CmsServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
public function register(): void {}
|
||||||
|
|
||||||
|
public function boot(): void {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\Pages\CreateCmsPage;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\Pages\EditCmsPage;
|
||||||
|
use Modules\Cms\Filament\Resources\CmsPages\Pages\ListCmsPages;
|
||||||
|
use Modules\Cms\Models\CmsPage;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
|
use function Pest\Laravel\assertDatabaseHas;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
Role::findOrCreate('admin', 'web');
|
||||||
|
|
||||||
|
$this->admin = User::factory()->create()->assignRole('admin');
|
||||||
|
$this->actingAs($this->admin);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('can list cms pages', function () {
|
||||||
|
$pages = CmsPage::factory()->count(3)->create();
|
||||||
|
|
||||||
|
Livewire::test(ListCmsPages::class)
|
||||||
|
->assertOk()
|
||||||
|
->assertCanSeeTableRecords($pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('can create a cms page', function () {
|
||||||
|
$page = CmsPage::factory()->make();
|
||||||
|
|
||||||
|
Livewire::test(CreateCmsPage::class)
|
||||||
|
->fillForm([
|
||||||
|
'page' => $page->page,
|
||||||
|
'title' => $page->title,
|
||||||
|
'mm_title' => $page->mm_title,
|
||||||
|
'meta_tags' => $page->meta_tags,
|
||||||
|
'meta_keywords' => $page->meta_keywords,
|
||||||
|
'content' => $page->content,
|
||||||
|
'mm_content' => $page->mm_content,
|
||||||
|
'is_active' => true,
|
||||||
|
])
|
||||||
|
->call('create')
|
||||||
|
->assertNotified()
|
||||||
|
->assertRedirect();
|
||||||
|
|
||||||
|
assertDatabaseHas(CmsPage::class, [
|
||||||
|
'page' => $page->page,
|
||||||
|
'title' => $page->title,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('can edit a cms page', function () {
|
||||||
|
$page = CmsPage::factory()->create();
|
||||||
|
|
||||||
|
Livewire::test(EditCmsPage::class, ['record' => $page->getRouteKey()])
|
||||||
|
->assertOk()
|
||||||
|
->fillForm(['title' => 'Updated Title'])
|
||||||
|
->call('save')
|
||||||
|
->assertNotified();
|
||||||
|
|
||||||
|
assertDatabaseHas(CmsPage::class, [
|
||||||
|
'id' => $page->id,
|
||||||
|
'title' => 'Updated Title',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('requires a unique page slug', function () {
|
||||||
|
CmsPage::factory()->create(['page' => 'miniapp_faq']);
|
||||||
|
$page = CmsPage::factory()->make(['page' => 'miniapp_faq']);
|
||||||
|
|
||||||
|
Livewire::test(CreateCmsPage::class)
|
||||||
|
->fillForm([
|
||||||
|
'page' => $page->page,
|
||||||
|
'title' => $page->title,
|
||||||
|
'mm_title' => $page->mm_title,
|
||||||
|
])
|
||||||
|
->call('create')
|
||||||
|
->assertHasFormErrors(['page' => 'unique']);
|
||||||
|
});
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Modules\Cms\Models\CmsPage;
|
||||||
|
|
||||||
|
test('lists active cms pages', function () {
|
||||||
|
$active = CmsPage::factory()->create(['is_active' => true]);
|
||||||
|
CmsPage::factory()->create(['is_active' => false]);
|
||||||
|
|
||||||
|
$this->getJson('/api/v1/cms-pages')
|
||||||
|
->assertSuccessful()
|
||||||
|
->assertJsonCount(1, 'data')
|
||||||
|
->assertJsonFragment(['id' => $active->id]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('does not require authentication', function () {
|
||||||
|
CmsPage::factory()->create(['is_active' => true]);
|
||||||
|
|
||||||
|
$this->getJson('/api/v1/cms-pages')->assertSuccessful();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('shows an active cms page by its page slug', function () {
|
||||||
|
$page = CmsPage::factory()->create(['page' => 'miniapp_faq', 'is_active' => true]);
|
||||||
|
|
||||||
|
$this->getJson('/api/v1/cms-pages/miniapp_faq')
|
||||||
|
->assertSuccessful()
|
||||||
|
->assertJsonFragment(['id' => $page->id, 'page' => 'miniapp_faq']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns not found for an inactive page', function () {
|
||||||
|
CmsPage::factory()->create(['page' => 'miniapp_faq', 'is_active' => false]);
|
||||||
|
|
||||||
|
$this->getJson('/api/v1/cms-pages/miniapp_faq')->assertNotFound();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns not found for an unknown page slug', function () {
|
||||||
|
$this->getJson('/api/v1/cms-pages/unknown-page')->assertNotFound();
|
||||||
|
});
|
||||||
@@ -23,6 +23,7 @@ use Illuminate\Session\Middleware\StartSession;
|
|||||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||||
use Modules\Booking\BookingPlugin;
|
use Modules\Booking\BookingPlugin;
|
||||||
use Modules\Catalog\CatalogPlugin;
|
use Modules\Catalog\CatalogPlugin;
|
||||||
|
use Modules\Cms\CmsPlugin;
|
||||||
use Modules\Identity\IdentityPlugin;
|
use Modules\Identity\IdentityPlugin;
|
||||||
use Modules\Payment\PaymentPlugin;
|
use Modules\Payment\PaymentPlugin;
|
||||||
use Modules\Reporting\ReportingPlugin;
|
use Modules\Reporting\ReportingPlugin;
|
||||||
@@ -49,6 +50,7 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
NavigationGroup::make()->label('Routing'),
|
NavigationGroup::make()->label('Routing'),
|
||||||
NavigationGroup::make()->label('Operations'),
|
NavigationGroup::make()->label('Operations'),
|
||||||
NavigationGroup::make()->label('Reports'),
|
NavigationGroup::make()->label('Reports'),
|
||||||
|
NavigationGroup::make()->label('CMS'),
|
||||||
])
|
])
|
||||||
->plugins([
|
->plugins([
|
||||||
CatalogPlugin::make(),
|
CatalogPlugin::make(),
|
||||||
@@ -57,6 +59,7 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
PaymentPlugin::make(),
|
PaymentPlugin::make(),
|
||||||
IdentityPlugin::make(),
|
IdentityPlugin::make(),
|
||||||
ReportingPlugin::make(),
|
ReportingPlugin::make(),
|
||||||
|
CmsPlugin::make(),
|
||||||
// T6.5 — ops convenience for browsing storage/logs/*.log
|
// T6.5 — ops convenience for browsing storage/logs/*.log
|
||||||
// in-browser; distinct from the structured, per-model audit
|
// in-browser; distinct from the structured, per-model audit
|
||||||
// trail (AuditLogResource, T6.2). No extra permission gate:
|
// trail (AuditLogResource, T6.2). No extra permission gate:
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"internachi/modular": "^3.0",
|
"internachi/modular": "^3.0",
|
||||||
"modules/booking": "*",
|
"modules/booking": "*",
|
||||||
"modules/catalog": "*",
|
"modules/catalog": "*",
|
||||||
|
"modules/cms": "*",
|
||||||
"modules/identity": "*",
|
"modules/identity": "*",
|
||||||
"modules/payment": "*",
|
"modules/payment": "*",
|
||||||
"modules/reporting": "*",
|
"modules/reporting": "*",
|
||||||
|
|||||||
Generated
+33
-1
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "b3018ca42fa6d16d0da6113b3aa6b1a8",
|
"content-hash": "00ca2f59b7cce7ed3ade4856855a5d51",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "anourvalar/eloquent-serialize",
|
"name": "anourvalar/eloquent-serialize",
|
||||||
@@ -4727,6 +4727,38 @@
|
|||||||
"relative": true
|
"relative": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "modules/cms",
|
||||||
|
"version": "1.0",
|
||||||
|
"dist": {
|
||||||
|
"type": "path",
|
||||||
|
"url": "app-modules/cms",
|
||||||
|
"reference": "1269139b9cd2314b5afa6f734a2fdf3462717e4f"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Modules\\Cms\\Providers\\CmsServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Modules\\Cms\\": "src/",
|
||||||
|
"Modules\\Cms\\Tests\\": "tests/",
|
||||||
|
"Modules\\Cms\\Database\\Factories\\": "database/factories/",
|
||||||
|
"Modules\\Cms\\Database\\Seeders\\": "database/seeders/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"license": [
|
||||||
|
"proprietary"
|
||||||
|
],
|
||||||
|
"transport-options": {
|
||||||
|
"symlink": true,
|
||||||
|
"relative": true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "modules/identity",
|
"name": "modules/identity",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user