firumon/makhzun
firumon/makhzun is a Laravel/PHP package that provides Makhzun functionality for your application, packaged for easy installation via Composer. Use it to integrate the library into your project and extend it with your own configuration and code.
Installation
composer require firumon/makhzun
Publish the package assets and configuration:
php artisan vendor:publish --provider="Firumon\Makhzun\MakhzunServiceProvider" --tag="migrations"
php artisan vendor:publish --provider="Firumon\Makhzun\MakhzunServiceProvider" --tag="config"
php artisan vendor:publish --provider="Firumon\Makhzun\MakhzunServiceProvider" --tag="public"
php artisan migrate
First Use Case: Adding a Product
/products route (or /inventory if configured differently).Where to Look First
config/makhzun.php for customizable settings (e.g., default routes, storage paths).database/migrations/ for schema details (e.g., products, categories, transactions tables).routes/web.php for predefined routes (e.g., products, categories, reports).resources/views/makhzun/ for UI templates (e.g., products/index.blade.php).Product Management
Product model:
use Firumon\Makhzun\Models\Product;
$product = Product::create([
'name' => 'Laptop',
'sku' => 'LP-001',
'quantity' => 10,
'price' => 999.99,
]);
Inventory Tracking
Transaction model:
use Firumon\Makhzun\Models\Transaction;
Transaction::create([
'product_id' => $product->id,
'quantity' => 2,
'type' => 'out', // 'in' or 'out'
'reference' => 'Sale #123',
]);
Categorization
$category = \Firumon\Makhzun\Models\Category::create(['name' => 'Electronics']);
$product->categories()->attach($category);
Reporting
/reports route or programmatically:
$lowStock = \Firumon\Makhzun\Models\Product::where('quantity', '<', 5)->get();
Route::apiResource('api/products', \Firumon\Makhzun\Http\Controllers\ProductController::class);
Product model to add fields (e.g., barcode, expiry_date):
php artisan make:model ProductExtension -m
Then update migrations and models accordingly.ProductUpdated, TransactionCreated) for notifications or logging:
use Firumon\Makhzun\Events\ProductUpdated;
ProductUpdated::dispatch($product);
Migration Conflicts
products table, reset migrations or manually merge changes before running php artisan migrate.php artisan migrate:fresh in a staging environment.Quantity Overflows
if ($product->quantity < $request->quantity && $request->type === 'out') {
throw new \Exception("Insufficient stock for product {$product->name}.");
}
Route Collisions
/products) may conflict with existing routes. Override in routes/web.php:
Route::prefix('admin')->group(function () {
Route::resource('inventory/products', \Firumon\Makhzun\Http\Controllers\ProductController::class);
});
Missing Dependencies
laravel/ui or laravelcollective/html is installed for Blade components (e.g., forms, tables):
composer require laravelcollective/html
config/database.php to debug slow inventory operations:
'log' => env('DB_LOG_QUERIES', false),
auth or can middleware is applied to sensitive routes (e.g., /products/create).Custom Validation
ProductRequest or TransactionRequest in app/Http/Requests to add rules (e.g., SKU uniqueness):
public function rules()
{
return [
'sku' => 'required|unique:products,sku,' . $this->product,
];
}
Storage Backends
// config/makhzun.php
'storage' => [
'driver' => 'redis',
'connection' => 'cache',
],
Localization
php artisan vendor:publish --tag=lang
resources/lang/{locale}/makhzun.php.Testing
$this->assertDatabaseHas('products', ['name' => 'Laptop', 'quantity' => 8]);
How can I help you explore Laravel packages today?