- How do I use c-sushi in a Laravel project to replace database fixtures?
- Install via Composer (`composer require calebporzio/sushi`), then add the `Sushi` trait to a model and define your static data in a `$rows` array. Query it like a database table—ideal for states, countries, or config-driven records without migrations.
- Does c-sushi work with Laravel 10+? What versions are supported?
- The package is designed for modern Laravel (tested with recent versions). Check the [GitHub repo](https://github.com/wpstarter/c-sushi) for exact compatibility, but it leverages Eloquent’s core features, so it should work with Laravel 8+.
- Can I use c-sushi in WordPress with WpStarter? Will it conflict with Laravel dependencies?
- Yes, but with caution. If your WordPress project uses Laravel’s service container (e.g., via `laravel-wordpress-polyfill`), it may work. Otherwise, isolate it to WpStarter environments or use standalone PHP classes to avoid autoload conflicts.
- How do relationships work between Sushi models and regular Eloquent models?
- Relationships function normally (e.g., `belongsTo`, `hasMany`), but `whereHas` won’t work since Sushi models are in-memory. Use `associate()`, eager loading (`with()`), and direct queries like `whereLabel('admin')->first()` for associations.
- Is c-sushi suitable for production? Any performance concerns?
- Yes, it’s lightweight and memory-efficient for static data. Avoid heavy operations like `whereHas` or complex joins. For large datasets, consider caching or splitting into smaller models to minimize memory usage.
- How do I validate data against Sushi models in Laravel forms?
- Use Laravel’s `exists:` validation rule (e.g., `'role_id' => 'required|exists:roles,id'`). The package mimics database behavior, so standard validation rules work seamlessly for in-memory data.
- Are there alternatives to c-sushi for static data in Laravel?
- Yes. For simple cases, use Laravel’s `config()` or `cache()` with static arrays. For Eloquent-like behavior, consider `spatie/laravel-model-states` or `laravel-shift/eloquent-static`. For WordPress, `wpdb` with custom tables is often lighter.
- Can I extend Sushi models with custom query scopes or accessors?
- Absolutely. Add scopes or accessors to your model class like normal Eloquent models. For example, `public function scopeActive($query) { return $query->where('status', 'active'); }` works as expected.
- What’s the maintenance status of c-sushi? Is it actively updated?
- The package is now open-source (previously sponsorware) and appears stable. Check the [GitHub repo](https://github.com/wpstarter/c-sushi) for updates, but since it’s a utility, major changes are unlikely. Always test in staging first.
- How do I test Sushi models in PHPUnit? Do I need a database?
- No database is needed. Write unit tests by instantiating models directly and asserting results. Example: `$state = new State(); $this->assertEquals('New York', $state->whereAbbr('NY')->first()->name);`. Mock relationships if required.