I am creating a blog where users can post and other users can edit there posts.
When someone edits a post the version should be updated and saved, this works.
Now I want to display only the latest version to the readers.
Not 100% sure how this should work.
I created a function within the model that would select the version based on a simple MAX query. Here is the model:
public function getlatestversion(){
$lastest = DB::table('contentPost')->max('version');
return $this->$lastest;
}
My Blade View:
Partial:
{{ Str::limit($post->content_posts()->getlatestversion()['content'], 140) }}
Can I use this directly in my blade view? Or should it also be in my controller? The error that I get is:
"Call to undefined method... getlatestversion()"
Does it have something to do that it is not in my controller, or am I passing it the wrong way?
Thanks