i have post with category
$response=Post::groupBy('post_category','id')->get();
The above query will return all posts with category in the order of category.
Now i need to group all post inside category. Now i have one possible solution is i need to loop response and inside loop i have to check for category and create array.
Is there a option to make it in a query something like groupconcat.?
My question is: Is it possible to create an array of category so key of an array is category_name and inside of category all post?
Updated
Post table
id | post_name | post_description | category_name | etc..
Here category name is not using any other table since its predefined values like news, sports, cricket something like... When i am inserting news, sports, political in categoryname.