From 3c1124375a435aad861e28caf6bc83ef98f0fe99 Mon Sep 17 00:00:00 2001 From: raccoon254 Date: Fri, 17 May 2024 16:05:53 +0300 Subject: [PATCH] Added deliveries and message attachments --- app/Models/Attachment.php | 21 ++++++++++++ app/Models/Delivery.php | 22 ++++++++++++ app/Models/Message.php | 6 ++++ database/factories/MessageFactory.php | 23 +++++++++++++ database/factories/UserFactory.php | 1 + ..._05_17_125635_create_attachments_table.php | 32 ++++++++++++++++++ ...4_05_17_125922_create_deliveries_table.php | 29 ++++++++++++++++ scholarspace | Bin 0 -> 126976 bytes 8 files changed, 134 insertions(+) create mode 100644 app/Models/Attachment.php create mode 100644 app/Models/Delivery.php create mode 100644 database/factories/MessageFactory.php create mode 100644 database/migrations/2024_05_17_125635_create_attachments_table.php create mode 100644 database/migrations/2024_05_17_125922_create_deliveries_table.php create mode 100644 scholarspace diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php new file mode 100644 index 0000000..08ed500 --- /dev/null +++ b/app/Models/Attachment.php @@ -0,0 +1,21 @@ +belongsTo(Message::class, 'message_id'); + } +} diff --git a/app/Models/Delivery.php b/app/Models/Delivery.php new file mode 100644 index 0000000..3e2ebd3 --- /dev/null +++ b/app/Models/Delivery.php @@ -0,0 +1,22 @@ +belongsTo(Order::class, 'order_id'); + } +} diff --git a/app/Models/Message.php b/app/Models/Message.php index 6d2b421..8b612af 100644 --- a/app/Models/Message.php +++ b/app/Models/Message.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; class Message extends Model { @@ -26,4 +27,9 @@ public function receiver(): BelongsTo { return $this->belongsTo(User::class, 'receiver_id'); } + + public function attachments(): HasMany + { + return $this->hasMany(Attachment::class); + } } diff --git a/database/factories/MessageFactory.php b/database/factories/MessageFactory.php new file mode 100644 index 0000000..ff5110d --- /dev/null +++ b/database/factories/MessageFactory.php @@ -0,0 +1,23 @@ + + */ +class MessageFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 584104c..c067f8f 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -26,6 +26,7 @@ public function definition(): array return [ 'name' => fake()->name(), 'email' => fake()->unique()->safeEmail(), + 'role' => rand(0, 1) ? 'client' : 'writer', 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), 'remember_token' => Str::random(10), diff --git a/database/migrations/2024_05_17_125635_create_attachments_table.php b/database/migrations/2024_05_17_125635_create_attachments_table.php new file mode 100644 index 0000000..9057a99 --- /dev/null +++ b/database/migrations/2024_05_17_125635_create_attachments_table.php @@ -0,0 +1,32 @@ +id(); + $table->foreignId('message_id')->constrained()->onDelete('cascade'); + $table->string('name'); + $table->string('path'); + $table->string('type'); + $table->integer('size'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('attachments'); + } +}; diff --git a/database/migrations/2024_05_17_125922_create_deliveries_table.php b/database/migrations/2024_05_17_125922_create_deliveries_table.php new file mode 100644 index 0000000..d5e263b --- /dev/null +++ b/database/migrations/2024_05_17_125922_create_deliveries_table.php @@ -0,0 +1,29 @@ +id(); + $table->foreignId('order_id')->constrained()->onDelete('cascade'); + $table->string('status'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('deliveries'); + } +}; diff --git a/scholarspace b/scholarspace new file mode 100644 index 0000000000000000000000000000000000000000..3e0ed3821ed09a41a0f21392a692a71b2d3b8ac6 GIT binary patch literal 126976 zcmeI(O>f-B83*vCwOZyx=QF(P>HaeSWZ+UEmGKZ7O0BEO>7xSS_I69J1a5f zl53JHS$#QZ75CChFFo{96g}kBQ;+=yz4g=&kyDQaiUNIR__D(l=|pN#po_l{S-UgC zm-)>zGbD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