From 283953d64d8a7f0aad7f633e2db07518ccb2a33e Mon Sep 17 00:00:00 2001 From: "m.zargarov" Date: Wed, 10 Jan 2024 11:38:25 +0400 Subject: [PATCH] Added models and migration --- app/Models/Car.php | 17 +++++++++++ app/Models/Delivery.php | 18 +++++++++++ app/Models/User.php | 4 +++ app/Models/Warehouse.php | 16 ++++++++++ .../2014_10_12_000000_create_users_table.php | 4 +++ ...4_01_10_065857_create_warehouses_table.php | 29 ++++++++++++++++++ .../2024_01_10_065906_create_cars_table.php | 30 +++++++++++++++++++ ...4_01_10_065912_create_deliveries_table.php | 30 +++++++++++++++++++ ...2024_01_10_072938_create_delivery_user.php | 29 ++++++++++++++++++ 9 files changed, 177 insertions(+) create mode 100644 app/Models/Car.php create mode 100644 app/Models/Delivery.php create mode 100644 app/Models/Warehouse.php create mode 100644 database/migrations/2024_01_10_065857_create_warehouses_table.php create mode 100644 database/migrations/2024_01_10_065906_create_cars_table.php create mode 100644 database/migrations/2024_01_10_065912_create_deliveries_table.php create mode 100644 database/migrations/2024_01_10_072938_create_delivery_user.php diff --git a/app/Models/Car.php b/app/Models/Car.php new file mode 100644 index 0000000..65fff20 --- /dev/null +++ b/app/Models/Car.php @@ -0,0 +1,17 @@ +id(); $table->string('name'); + $table->string('surname'); + $table->string('patronymic'); + $table->string('phone_number'); + $table->unsignedInteger('role'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); diff --git a/database/migrations/2024_01_10_065857_create_warehouses_table.php b/database/migrations/2024_01_10_065857_create_warehouses_table.php new file mode 100644 index 0000000..753582e --- /dev/null +++ b/database/migrations/2024_01_10_065857_create_warehouses_table.php @@ -0,0 +1,29 @@ +id(); + $table->string('address'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('warehouses'); + } +}; diff --git a/database/migrations/2024_01_10_065906_create_cars_table.php b/database/migrations/2024_01_10_065906_create_cars_table.php new file mode 100644 index 0000000..c4a5362 --- /dev/null +++ b/database/migrations/2024_01_10_065906_create_cars_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('name'); + $table->string('number'); + $table->foreignId('driver_id')->constrained('users'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('cars'); + } +}; diff --git a/database/migrations/2024_01_10_065912_create_deliveries_table.php b/database/migrations/2024_01_10_065912_create_deliveries_table.php new file mode 100644 index 0000000..15cd6e6 --- /dev/null +++ b/database/migrations/2024_01_10_065912_create_deliveries_table.php @@ -0,0 +1,30 @@ +id(); + $table->unsignedInteger('status'); + $table->date('sending_date'); + $table->date('delivery_date'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('deliveries'); + } +}; diff --git a/database/migrations/2024_01_10_072938_create_delivery_user.php b/database/migrations/2024_01_10_072938_create_delivery_user.php new file mode 100644 index 0000000..2bbf59b --- /dev/null +++ b/database/migrations/2024_01_10_072938_create_delivery_user.php @@ -0,0 +1,29 @@ +id(); + $table->foreignId('user_id')->constrained('users')->onDelete('cascade'); + $table->foreignId('delivery_id')->constrained('deliveries')->onDelete('cascade'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('delivery_user'); + } +};