Laravel 11 Shopping Add to Cart with Ajax Example using Vite, Jquery and Bootstrap 5

Raviya Technical
5 min readOct 30, 2024
Laravel 11 Shopping Add to Cart with Ajax Example using Vite, Jquery and Bootstrap 5
php artisan make:model Product -mfs

Creating file of model, factory,migration and Seeder

Model [example-app\app\Models\Product.php] created successfully.  
Factory [example-app\database\factories\ProductFactory.php] created successfully.
Migration [example-app\database\migrations/2024_10_30_121011_create_products_table.php] created successfully.
Seeder [example-app\database\seeders\ProductSeeder.php] created successfully.

Change Migration
location:database/migrations/xxx_create_products_table.php

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('image')->nullable();
$table->string('name', 151);
$table->decimal('price', 6, 2);
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('products');
}
};

--

--