Skip to main content
Back to packages
3,003 GitHub stars

calebporzio/sushi

View on GitHub

Description

Eloquent's missing "array" driver. Sometimes you want to use Eloquent, but without dealing with a database.

Install

composer require calebporzio/sushi

Use

Using this package consists of two steps:

  1. Add the Sushi trait to a model.
  2. Add a $rows property to the model.

That's it.

class State extends Model
{
use \Sushi\Sushi;
 
protected $rows = [
[
'abbr' => 'NY',
'name' => 'New York',
],
[
'abbr' => 'CA',
'name' => 'California',
],
];
}

Now, you can use this model anywhere you like, and it will behave as if you created a table with the rows you provided.

$stateName = State::whereAbbr('NY')->first()->name;

This is really useful for "Fixture" data, like states, countries, zip codes, user_roles, sites_settings, etc...

Recent Courses on Laravel Daily

Laravel 13 Starter Kit Teams and Customizations

10 lessons
33 min

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read

How to Structure Laravel 13 Projects

16 lessons
1 h 32 min read

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.