Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda