Friday, April 27, 2018

date_format() expects parameter 1 to be DateTimeInterface, null given (View: /home/vagrant/code/blog/resources/views/singlePost.blade.php) - development

date_format() expects parameter 1 to be DateTimeInterface, null given (View: /home/vagrant/code/blog/resources/views/singlePost.blade.php)

i cant find whats wrong with my code.I have tried looking at the whole code but i cant put my finger on it. it would be really helpful if someone pointed out my mistake. it is saying that something is wrong with the date but i cant see what i typed wrong

@extends('layouts.master')
@section('content')

    <!-- Page Header -->
    <header class="masthead" style="background-image: url('')">
      <div class="overlay"></div>
      <div class="container">
        <div class="row">
          <div class="col-lg-8 col-md-10 mx-auto">
            <div class="post-heading">
              <h1></h1>
              <span class="meta">Posted by
                <a href="#"></a>
                on </span>
            </div>
          </div>
        </div>
      </div>
    </header>

    <!-- Post Content -->
    <article>
      <div class="container">
        <div class="row">
          <div class="col-lg-8 col-md-10 mx-auto">
            {!!nl2br($post->content)!!}
          </div>
        </div>
<div class="comments">
  <hr>
  <h2>Comments</h2>
  <hr>
  @foreach($post->comments as $comment)
  <p> <br>
  <p><small>by , on </small></p>
  <hr>
  @endforeach

@if(Auth::check())
<form action="" method="POST">
  @csrf
  <div class="form-group">
<textarea class="form-control" placeholder="Comment..." name="comment" id="" cols="30" rows="4"></textarea>
<input type="hidden" name="post" value="">
</div>
<div class="form-group">
  <button class ="btn btn-primary" type="submit">Make Comment</button>
</div>
</form>
@endif

</div>
</article>
    @endsection


comments.blade.php code



from Laravel Questions and Answers https://laravelquestions.com/php/date_format-expects-parameter-1-to-be-datetimeinterface-null-given-view-home-vagrant-code-blog-resources-views-singlepost-blade-php/
via Lzo Media

1 comment:

  1. Thank you again for all the knowledge you distribute,Good post. I was very interested in the article, it's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing! Regards,
    custom mobile app development

    ReplyDelete