tastyigniter/core
TastyIgniter Core powers the TastyIgniter restaurant platform, providing the backend foundation for online food ordering and table reservations. Use it as the core package behind the TastyIgniter application and extensions.
Installation:
composer require tastyigniter/core
Ensure your composer.json specifies PHP 8.3–8.4 compatibility.
Publish Core Configurations:
php artisan vendor:publish --provider="TastyIgniter\Core\Providers\CoreServiceProvider"
This publishes:
config/admin.php)config/media.php)config/dashboard.php)First Use Case: Admin Panel Integration
Register a custom admin route in routes/admin.php:
Route::resource('custom-module', \TastyIgniter\Core\Http\Controllers\Admin\CustomModuleController::class);
Extend the base AdminController for CRUD operations:
use TastyIgniter\Core\Http\Controllers\Admin\AdminController;
class CustomModuleController extends AdminController
{
protected $model = \App\Models\CustomModule::class;
protected $view = 'admin.custom-modules.index';
}
Verify Extensions Check installed extensions via:
php artisan igniter:extensions
Update dependencies with:
php artisan igniter:update
TastyIgniter\Core\Foundation\Application (bootstrapping)TastyIgniter\Core\Http\Controllers\Admin\AdminController (base admin controller)TastyIgniter\Core\Services\TemplateSandbox (sanitization logic)config/admin.php, config/media.php (critical for customization).php artisan list | grep igniter # Lists core commands
Create a Custom Admin Module:
php artisan make:model CustomModule -m
AdminController (as shown above) and define views in resources/views/admin/custom-modules/./admin/custom-module.Pattern: Extend AdminController for CRUD.
class PostsController extends AdminController
{
protected $model = \App\Models\Post::class;
protected $view = 'admin.posts.index';
protected $columns = ['title', 'published_at']; // Customize columns
}
Key Methods:
index(): Lists records (uses $columns).create()/edit(): Renders forms (uses makeForm()).store()/update(): Handles validation (uses validate()).Form Handling:
Use makeForm() to define fields:
protected function makeForm()
{
return [
'title' => 'text',
'content' => 'textarea',
'published_at' => 'datetime',
];
}
Pattern: Create a custom extension (e.g., for payments).
/extensions/PaymentGateway/
├── config/
├── resources/
├── src/
│ ├── Http/Controllers/
│ ├── Providers/
│ └── Services/
└── composer.json
config/extensions.php:
'payment-gateway' => [
'path' => base_path('extensions/PaymentGateway'),
'enabled' => true,
],
php artisan vendor:publish --tag=payment-gateway-assets
Key Classes:
ExtensionServiceProvider: Bootstraps extension logic.ExtensionController: Handles routes (e.g., /admin/payment-gateway).Pattern: Use TemplateSandbox for user-generated templates.
use TastyIgniter\Core\Services\TemplateSandbox;
$sandbox = new TemplateSandbox();
$sanitized = $sandbox->sanitize($userInputTemplate);
Common Use Cases:
resources/views/emails/custom.blade.php).Custom Rules:
Extend TemplateSandbox:
class CustomSandbox extends TemplateSandbox
{
protected function getAllowedTags()
{
return parent::getAllowedTags() + ['custom-tag'];
}
}
use TastyIgniter\Core\Traits\HasMedia;
class Post extends Model
{
use HasMedia;
}
$post = new Post();
$post->addMediaFromPath($path)->toMediaCollection('images');
$post->save();
config/media.php for storage (e.g., S3, local).config/dashboard.php:
'widgets' => [
'custom' => [
'class' => \App\Widgets\CustomWidget::class,
'priority' => 10,
],
],
WidgetInterface:
class CustomWidget implements WidgetInterface
{
public function render()
{
return view('widgets.custom');
}
}
auth() helper or extend TastyIgniter\Core\Auth\AuthManager.extension.installed):
event(new ExtensionInstalled($extension));
media_attachments, languages, etc., as shown in v4.2.0.CacheMaker trait:
use TastyIgniter\Core\Traits\CacheMaker;
class MyService
{
use CacheMaker;
public function getCachedData($key)
{
return $this->cache->remember($key, now()->addHours(1), function () {
return $this->fetchData();
});
}
}
TastyIgniter\Core\Models\Language.trans() or extend the Language model:
$language = Language::find(2);
$translation = $language->translations()->where('key', 'welcome')->first();
/admin/logs (admin panel).FlashBag:
flash()->success('Action completed!')->withActionUrl('/admin/posts');
TemplateSandbox may strip custom Blade directives.
getAllowedDirectives():
protected function getAllowedDirectives()
{
return ['customDirective'];
}
@verbatim for complex components:
@verbatim
{{!! $unsafeComponent !!}
@endverbatim
composer.json is missing.
extra.igniter config:
{
"extra": {
"igniter": {
"type": "extension",
"name": "payment-gateway"
}
}
}
igniter:update --check to validate dependencies.config/media.php paths and run:
php artisan storage:link
media:optimize to regenerate thumbnails:
php artisan media:optimize
Route::prefix('custom
How can I help you explore Laravel packages today?