show.blade.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. @extends('layouts.master')
  2. @section('content')
  3. <div class="col-sm-8 blog-main">
  4. <h1>{{ $post->title }}</h1>
  5. <p class="blog-post-meta">
  6. {{ $post->created_at->toFormattedDateString() }}
  7. by <a href="#">{{ $post->user->name }}</a>
  8. </p>
  9. @if (count($post->tags))
  10. <ul>
  11. @foreach ($post->tags as $tag)
  12. <li><a href="/posts/tags/{{ $tag->name }}">{{ $tag->name }}</a></li>
  13. @endforeach
  14. </ul>
  15. @endif
  16. {{ $post->body }}
  17. @if (count($post->comments))
  18. <hr />
  19. <div class="comments">
  20. <ul class="list-group">
  21. @foreach($post->comments as $comment)
  22. <li class="list-group-item">
  23. <strong>{{ $comment->created_at->diffForHumans() }}</strong>
  24. :&nbsp;
  25. {{ $comment->body }}
  26. </li>
  27. @endforeach
  28. </ul>
  29. </div>
  30. @endif
  31. {{-- Add a comment --}}
  32. <div class="card">
  33. <div class="card-block">
  34. <form method="post" action="/posts/{{ $post->id }}/comments">
  35. {{-- Only needed for methods other than GET/POST, since most
  36. browsers only support those two --}}
  37. {{ method_field('POST') }}
  38. {{ csrf_field() }}
  39. @include('layouts.errors')
  40. <div class="form-group">
  41. <textarea required class="form-control" name="body" placeholder="Your comment here">
  42. </textarea>
  43. </div>
  44. <div class="form-group">
  45. <button type="submit" class="btn btn-primary">Add comment</button>
  46. </div>
  47. </form>
  48. </div>
  49. </div>
  50. </div>
  51. @endsection