mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-11 18:54:33 +00:00
Add comments to migrations,
Work on CartItem schema,
This commit is contained in:
@@ -13,12 +13,20 @@ class CreateShoppingcartTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create(Config::get('cart.database.tables.cart'), function (Blueprint $table) {
|
||||
$table->string('identifier');
|
||||
$table->string('instance');
|
||||
$table->longText('content');
|
||||
$table->nullableTimestamps();
|
||||
/* Primary identifier of the cart, i.e. uinque user id */
|
||||
$table->string('identifier')->index();
|
||||
|
||||
/* Instance of the cart to allow for multiple carts per identifier */
|
||||
$table->string('instance')->index();
|
||||
|
||||
/* Make primary key a combination of booth */
|
||||
$table->primary(['identifier', 'instance']);
|
||||
|
||||
/* Content of the cart */
|
||||
$table->longText('content');
|
||||
|
||||
/* Allow empty timestamps */
|
||||
$table->nullableTimestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateShoppingcartItemsTable extends Migration
|
||||
@@ -12,6 +13,25 @@ class CreateShoppingcartItemsTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create(Config::get('cart.database.tables.cart_item'), function (Blueprint $table) {
|
||||
/* RowID of the CartItem, based on id and options */
|
||||
$table->string('row_id', 32)->index();
|
||||
|
||||
/* Relation CartItem to Cart */
|
||||
$table->unsignedBigInteger('cart_id');
|
||||
$table->foreign('cart_id')->references('id')->on(Config::get('cart.database.tables.cart'));
|
||||
|
||||
/* Make id and rowid primary so there can not be duplicates */
|
||||
$table->primary(['cart_id', 'row_id']);
|
||||
|
||||
/* The price of the CartItem */
|
||||
$table->unsignedBigInteger('price')->nullable();
|
||||
$table->unsignedFloat('discount_rate')->nullable();
|
||||
$table->unsignedBigInteger('discount_fixed')->nullable();
|
||||
$table->unsignedFloat('taxRate')->nullable();
|
||||
|
||||
/* Custom-Options of the CartItem */
|
||||
$table->json('options');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user