Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

449
Views
Can I have a Laravel Model without a database table?

I would like to have a Laravel Model with all of the features and functions of a Laravel Model, but the data for the model is completely static and will never change. I could create a database table for it, but that leaves the possibility of someone modifying the table directly.

For example:

    //  Model Data for Log Levels
    name      | icon                | color
    -------------------------------------------
    Emergency | fas fa-ambulance    | red
    Alert     | fas fa-bullhorn     | yellow
    Critical  | fas fa-heartbeast   | orange
    ....

This would be the data, stored in the model file the same as if it was a DB table, but can never be changed. Is this possible?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can use Sushi for that.

Eloquent's missing "array" driver.

Sometimes you want to use Eloquent, but without dealing with a database.

class State extends Model
{
    use \Sushi\Sushi;

    protected $rows = [
        [
            'name' => 'Emergency',
            'icon' => 'fas fa-ambulance',
            'color' => 'red'
        ],
        [
            'name' => 'Alert',
            'icon' => 'fas fa-bullhorn',
            'color' => 'yellow'
        ],
        [
            'name' => 'Critical',
            'icon' => 'fas fa-heartbeast',
            'color' => 'orange'
        ],
    ];
}

https://github.com/calebporzio/sushi

over 4 years ago · Santiago Trujillo Report

0

I think you can use a simple model, without creating forms for injecting data, and a seeder to inculde your data at first time (when you run migrate).

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!