capell-app/core
Capell Core is the platform package behind Capell CMS, owning the shared content model for sites, domains, languages, pages and URLs, plus the package registry, install and upgrade orchestration, settings schemas and extension contracts. It is not an admin UI or public renderer.
Installation
composer require capell-app/core
Add the service provider to config/app.php:
'providers' => [
// ...
Capell\App\Core\Providers\CoreServiceProvider::class,
],
Publish Config & Migrations
php artisan vendor:publish --provider="Capell\App\Core\Providers\CoreServiceProvider"
Run migrations:
php artisan migrate
First Use Case: Content Model
Define a basic content model in app/Models/Content/MyModel.php:
namespace App\Models\Content;
use Capell\App\Core\Models\ContentModel;
class MyModel extends ContentModel
{
protected $modelName = 'my_model';
}
Register Model in config/capell.php
'models' => [
'my_model' => [
'class' => \App\Models\Content\MyModel::class,
],
],
CRUD via API
Use the built-in API endpoints (e.g., /api/content/my_model).
// Create
$data = $this->contentService->create('my_model', ['title' => 'Test']);
// Fetch
$item = $this->contentService->find('my_model', 1);
Event-Driven Extensions
Listen to model events (e.g., ContentModelCreated):
use Capell\App\Core\Events\ContentModelCreated;
event(new ContentModelCreated($model));
Dependency Injection
Bind services in AppServiceProvider:
$this->app->bind(
\Capell\App\Core\Contracts\ContentService::class,
\Capell\App\Core\Services\ContentService::class
);
Custom Services Extend core services:
namespace App\Services;
use Capell\App\Core\Services\ContentService;
class MyContentService extends ContentService
{
public function customMethod() { ... }
}
Model Extensions Add fields dynamically:
class MyModel extends ContentModel
{
public function getCustomFieldAttribute()
{
return $this->attributes['custom_field'] ?? null;
}
}
Middleware for Content Protect routes:
Route::middleware(['capell.auth'])->group(function () {
// ...
});
Migration Conflicts
If php artisan migrate fails, check config/capell.php for reserved table names.
Fix: Rename tables in config/capell.php under database.tables.
Caching Issues Clear caches after extending models:
php artisan config:clear
php artisan cache:clear
Event Listener Registration
Ensure listeners are registered in EventServiceProvider:
protected $listen = [
ContentModelCreated::class => [
\App\Listeners\HandleModelCreated::class,
],
];
Log Model Events
Enable debug mode in config/capell.php:
'debug' => env('APP_DEBUG', false),
Check Contracts
Verify implemented contracts (e.g., ContentService) match the package’s expectations.
Dynamic Field Validation
Override getRules() in models:
public function getRules()
{
return [
'title' => 'required|string|max:255',
'custom_field' => 'nullable|string',
];
}
API Resource Customization
Extend Capell\App\Core\Http\Resources\ContentResource for custom responses.
Localization
Use config/capell.php to set default locale:
'locale' => 'en',
How can I help you explore Laravel packages today?