nitra/e-commerce-admin-extensionsbundle
Admin extensions bundle for Nitra e-commerce: adds ready-made features and integrations to speed up back-office development. Includes configurable modules and utilities to extend the admin panel with common commerce tools and workflows.
Installation Add the package via Composer:
composer require nitra/e-commerce-admin-extensionsbundle
Register the bundle in config/app.php under providers:
Nitra\AdminExtensionsBundle\AdminExtensionsBundle::class,
Publish Assets Run the publish command to generate config and migrations:
php artisan vendor:publish --provider="Nitra\AdminExtensionsBundle\AdminExtensionsBundle" --tag="config"
php artisan vendor:publish --provider="Nitra\AdminExtensionsBundle\AdminExtensionsBundle" --tag="migrations"
Migrate the database:
php artisan migrate
First Use Case: Extending Admin Panels
Use the AdminExtension trait in your admin controller to enable extensions:
use Nitra\AdminExtensionsBundle\Traits\AdminExtension;
class ProductAdminController extends Controller
{
use AdminExtension;
public function index()
{
$this->extendAdminPanel('product.index'); // Extend the product index view
return view('admin.product.index');
}
}
Dynamic Admin Panel Extensions Override or extend admin views without modifying core templates:
// In a service provider or controller
$this->extendAdminPanel('product.edit', function ($view) {
$view->with('customData', ['key' => 'value']);
});
Event-Based Extensions Listen to admin events to inject logic:
// In a service provider
event(new \Nitra\AdminExtensionsBundle\Events\AdminPanelExtensionEvent('product.index'));
Custom Admin Actions Add custom buttons or actions to admin grids:
$this->extendAdminGrid('product.grid', function ($grid) {
$grid->addAction('custom_action', 'Custom Label', 'admin.product.custom_action', ['id' => '$id']);
});
Leverage Laravel’s Service Container Bind custom extension services for reusable logic:
$this->app->bind('custom.extension.service', function () {
return new CustomExtensionService();
});
Use Blade Directives Create reusable directives for extensions:
Blade::directive('adminExtension', function ($expression) {
return "<?php echo \$this->extendAdminPanel($expression); ?>";
});
Localization Support Extend translations dynamically:
$this->extendAdminTranslations('product', [
'custom_label' => 'Custom Label',
]);
View Override Conflicts
product.index vs. product.index.blade.php).dd($this->getExtendedViews()) to debug registered extensions.Event Timing Issues
Event::listenFirst() if needed:
Event::listenFirst(\Nitra\AdminExtensionsBundle\Events\AdminPanelExtensionEvent::class, function ($event) {
// Your logic here
});
CSRF Token Mismatches
@csrf_field()
in extended views.Database Schema Conflicts
database/migrations/ before running migrate.Log Extensions
Enable debug mode in config/admin-extensions.php:
'debug' => env('APP_DEBUG', false),
Check logs for extension registration errors.
Inspect Registered Extensions Dump extensions in a controller:
dd(\Nitra\AdminExtensionsBundle\Facades\AdminExtensions::getExtensions());
Clear Cached Views If extensions don’t appear, clear the view cache:
php artisan view:clear
Custom Extension Providers Create a provider to register extensions globally:
class CustomAdminExtensionsProvider extends ServiceProvider
{
public function register()
{
$this->app->make(\Nitra\AdminExtensionsBundle\Contracts\AdminExtensionRegistrar::class)
->registerExtensions([
'product.index' => function ($view) {
$view->with('customData', 'value');
},
]);
}
}
Override Default Behaviors
Extend the base AdminExtension trait:
trait CustomAdminExtension
{
public function extendAdminPanel($hook, $callback = null)
{
// Custom logic before/after parent call
parent::extendAdminPanel($hook, $callback);
}
}
Asset Management Load custom CSS/JS for admin panels:
$this->extendAdminAssets('product.*', [
'css' => ['/path/to/custom.css'],
'js' => ['/path/to/custom.js'],
]);
How can I help you explore Laravel packages today?