瀏覽代碼

completed implementing comments

ttreasure 1 年之前
父節點
當前提交
3c49f2f309
共有 3 個文件被更改,包括 8 次插入9 次删除
  1. 1 1
      app/Models/Idea.php
  2. 3 0
      resources/views/ideas/show.blade.php
  3. 4 8
      resources/views/shared/comments-box.blade.php

+ 1 - 1
app/Models/Idea.php

@@ -16,6 +16,6 @@ class Idea extends Model
 
     public function comments()
     {
-        $this->hasMany(Comments::class)
+        return $this->hasMany(Comment::class, "idea_id", "id");
     }
 }

+ 3 - 0
resources/views/ideas/show.blade.php

@@ -6,6 +6,9 @@
                 @include('shared.left-sidebar')
             </div>
             <div class="col-6">
+                @include('shared.success-message')
+                @include('shared.error-message')
+                @include('shared.submit-idea')
                     <div class="mt-3">
                         @include('shared.idea-card')
                     </div>

+ 4 - 8
resources/views/shared/comments-box.blade.php

@@ -9,6 +9,7 @@
     </div>
     </form>
     <hr>
+    @foreach($idea->comments as $comment)
     <div class="d-flex align-items-start">
         <img style="width:35px" class="me-2 avatar-sm rounded-circle"
              src="https://api.dicebear.com/6.x/fun-emoji/svg?seed=Luigi"
@@ -17,17 +18,12 @@
             <div class="d-flex justify-content-between">
                 <h6 class="">Luigi
                 </h6>
-                <small class="fs-6 fw-light text-muted"> 3 hour
-                    ago</small>
+                <small class="fs-6 fw-light text-muted">{{$comment->created_at}}</small>
             </div>
             <p class="fs-6 mt-3 fw-light">
-                and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and
-                Evil)
-                by
-                Cicero, written in 45 BC. This book is a treatise on the theory of ethics,
-                very
-                popular during the Renaissan
+                {{$comment->content}}
             </p>
         </div>
     </div>
+    @endforeach
 </div>