How To Retrive Maximun Version Related To Post?
I have two tables:
table posts id text table old_posts id post_id text version
the relation is one to many between
old_posts when the user edits his/her post I save the old version in
old_posts but I need to increment the version number so I have first to get the maximum version for that post.
how I achieve this?
in this situation, you don't need to use the version column within the database table, instead of that you just need to count the number of the old_post's rows table.
the query should be like below with eloquent:
$versions = Old_post::where('post_id', $post_id)->count();
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms