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 0000000..3e0ed38 Binary files /dev/null and b/scholarspace differ