diff --git a/app/Models/Comment.php b/app/Models/Comment.php new file mode 100644 index 0000000..2c077f5 --- /dev/null +++ b/app/Models/Comment.php @@ -0,0 +1,55 @@ + + */ + protected function casts(): array + { + return [ + 'entities' => 'array', + 'likes' => 'integer', + 'replies' => 'integer', + 'can_reply' => 'boolean', + 'is_pinned' => 'boolean', + 'is_edited' => 'boolean', + 'is_hidden' => 'boolean', + 'is_sensitive' => 'boolean', + ]; + } + + public function profile(): BelongsTo + { + return $this->belongsTo(Profile::class); + } + + public function shareUrl(): string + { + return "c:id:1"; + } + + public function video() + { + return $this->belongsTo(Video::class); + } +} diff --git a/database/migrations/2024_03_28_105059_create_comments_table.php b/database/migrations/2024_03_28_105059_create_comments_table.php new file mode 100644 index 0000000..9b9236b --- /dev/null +++ b/database/migrations/2024_03_28_105059_create_comments_table.php @@ -0,0 +1,41 @@ +bigIncrements('id'); + $table->unsignedBigInteger('video_id')->index(); + $table->unsignedBigInteger('profile_id'); + $table->text('caption')->nullable(); + $table->json('entities')->nullable(); + $table->unsignedInteger('likes')->default(0); + $table->unsignedInteger('replies')->default(0); + $table->boolean('can_reply')->default(true); + $table->boolean('is_pinned')->default(false); + $table->boolean('is_edited')->default(false); + $table->boolean('is_hidden')->default(false); + $table->boolean('is_sensitive')->default(false); + + $table->foreign('video_id')->references('id')->on('videos')->cascadeOnDelete(); + $table->foreign('profile_id')->references('id')->on('profiles')->cascadeOnDelete(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('comments'); + } +};