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

151
Vistas
Is it a good idea to store shopping carts in database with Laravel

I am developing an e-commerce website and I am expecting the users to visit the website from both mobiles and computers, so I can't store the cart in a session like in darryldecode/cart

Is it a good practice to store the cart in the database ?

like this

    public function up()
{
    Schema::create('cart', function (Blueprint $table) {
        $table->id();
        $table->integer('user_id');
        $table->unsignedBigInteger('product_id');
        $table->timestamps();
        $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        $table->foreign('product_id')->references('id')->on('products')->onUpdate('cascade');

    });
}

However, I have a cart that works with $.ajax that store the cart immediately in a session when the user clicks "add to cart" button. Is there any good alternatives ? Can the cart in darryldecode/cart be stored in the database directly?

about 4 years ago · Juan Pablo Isaza
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