Hi
Im stuck on exacly the same problem as discussed here
https://laracasts.com/discuss/channels/general-discussion/carbonparse-not-working-as-expected
In the laravel 5 fundamental videos, jeff shows how the timestamp of future posts can be reset to 00:00:00,
instead of using the current time by using a Set Attribute on published_at in the Article Eloquent Model.
He converts the published_at to Carbon and uses Carbon::parse($date)
protected $dates = ['published_at'];
public function setPublishedAtAttribute($date)
{
$this->attributes['published_at'] = Carbon::parse($date);
}
This works fine, in the database, post are recieving a 00:00:00 timestamp.
But for some reason this doesn´t affect jeffs Articles he creates that are not future posts.
They recieve a timestamp with the current time.
My problem is that this carbon::parse($date) is affecting all my new articles.
So whem I post a new one for today they also get the 00:00:00 timestamp.
In my form view the published_at input field looks like this
<div class="form-group">
{!! Form::label('published_at', 'Publish On:') !!}
{!! Form::input('date', 'published_at', date('Y-m-d'), ['class' => 'form-control']) !!}
</div>
my controller
public function index()
{
$articles = Article::latest('published_at')->published()->get();
return view('articles.index', compact('articles'));
}
Thanks for your reply