Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

450
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda