wpstarter/c-sushi
Use Eloquent models backed by in-memory arrays instead of a database. Add the Sushi trait and a $rows dataset, then query, relate, eager load, and even validate with exists rules—great for fixture data like states, roles, and settings.
Installation
composer require wpstarter/c-sushi
Publish the package config (if available):
php artisan vendor:publish --provider="WpStarter\CSushi\CSushiServiceProvider"
Basic Usage
Register the package in config/app.php under providers:
WpStarter\CSushi\CSushiServiceProvider::class,
First Use Case Use the facade to generate a simple sushi recipe (hypothetical example):
use WpStarter\CSushi\Facades\CSushi;
$recipe = CSushi::make('vegetable')
->addIngredient('avocado')
->addIngredient('cucumber')
->roll();
Recipe Generation
$sushi = CSushi::make('type')
->addIngredient('ingredient1')
->addIngredient('ingredient2')
->addTopping('topping1')
->roll();
Integration with WpStarter
wpstarter/c-sushi is a plugin for WpStarter, integrate it into your WpStarter-based project:
// Example: Add sushi recipes to a menu
$menu = new \WpStarter\Menu\Menu();
$menu->addItem('sushi', CSushi::make('vegetable')->roll());
Dependency Injection
$this->app->bind('sushi.type.custom', function () {
return new \WpStarter\CSushi\Recipes\CustomSushi();
});
Command-Line Usage
php artisan sushi:generate --type=vegetable --ingredients=avocado,cucumber
Missing Config
config/c-sushi.php (create it if missing).return [
'default_type' => 'vegetable',
'ingredients' => [
'vegetable' => ['avocado', 'cucumber'],
'salmon' => ['raw_salmon'],
],
];
Recipe Validation
if (!CSushi::validateRecipe('vegetable', ['avocado'])) {
throw new \InvalidArgumentException("Invalid recipe ingredients.");
}
Namespace Conflicts
CSushi conflicts with other facades, use the fully qualified class name:
\WpStarter\CSushi\Facades\CSushi::make('type');
Laravel Version Compatibility
composer.json for laravel/framework constraints.Log Recipe Steps Enable debug mode in config:
'debug' => env('SUSHI_DEBUG', false),
Then inspect logs for recipe generation steps.
Override Defaults
Extend the base Sushi class to customize behavior:
namespace App\Extensions;
use WpStarter\CSushi\Sushi;
class CustomSushi extends Sushi {
public function addSauce($sauce) {
$this->ingredients[] = $sauce;
return $this;
}
}
Custom Recipes
Create new recipe classes by extending WpStarter\CSushi\Recipes\BaseRecipe:
namespace App\Recipes;
use WpStarter\CSushi\Recipes\BaseRecipe;
class SpicyTuna extends BaseRecipe {
protected $type = 'spicy_tuna';
protected $ingredients = ['tuna', 'spicy_mayo'];
}
Service Provider Hooks
Register custom recipes in a service provider’s boot method:
public function boot() {
CSushi::extend('spicy_tuna', function () {
return new \App\Recipes\SpicyTuna();
});
}
Event Listeners Listen for sushi-related events (if the package emits them):
\Event::listen('sushi.rolled', function ($sushi) {
\Log::info("Sushi rolled: {$sushi->type}");
});
How can I help you explore Laravel packages today?