Obviously your comments needs to be on a separate table .. and one to many relationship will return the comments. just inserting the comment id as a hash to the comment link will do ?
I thinked same your idea. But when i deleted a comment or many comments of the post, that value have change.
astroanu said:
Obviously your comments needs to be on a separate table .. and one to many relationship will return the comments. just inserting the comment id as a hash to the comment link will do ?
This should work, because each comment will have a unique id. Something like:
?post_Id=thepostid&Id=thecommenttobookmark
Have to have info for both to bookmark. Something like this.
I made a function for this work. If you have any idea bester use function of Laravel, please tell me.
/*
* Function count position of the comment in post
* @param: $id [ID of comment]
* @param: $arr [array id of all comment $post->comments()->lists('id')]
* @return: number
* */
function position_comment($id,$arr){
$comments_per_page = 10;
$pos = array_search($id,$arr);
$pos = $pos+1;
return ceil($pos/$comments_per_page);
}
See reply above, position don't matter, it can change, id won't. I am going to try your function later.
I am Vietnamese. And, I making a forum for Vietnamese Laraveler like this forum. In address
I used $post->comments->lists('id') to ensure the order comments in view (templates) and don't query database
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community