cURL
curl --request GET \ --url https://api.example.com/api/post/user/{id}
{ "status": "<string>", "posts": [ { "id": 123, "user_id": 123, "category_id": 123, "title": "<string>", "content": "<string>", "image": "<string>", "created_at": "<string>", "updated_at": "<string>" } ] }
Retrieve all blog posts created by a specific user
GET /api/post/user/{id}
Show Post object properties
curl -X GET "https://api.example.com/api/post/user/2"
{ "status": "success", "posts": [ { "id": 3, "user_id": 2, "category_id": 1, "title": "My First Blog Post", "content": "This is my inaugural post on the blog...", "image": "1709564730first.jpg", "created_at": "2024-03-01T09:00:00.000000Z", "updated_at": "2024-03-01T09:00:00.000000Z" }, { "id": 7, "user_id": 2, "category_id": 3, "title": "Travel Photography Tips", "content": "Here are my top tips for capturing stunning travel photos...", "image": "1709568920travel.jpg", "created_at": "2024-03-03T14:30:00.000000Z", "updated_at": "2024-03-03T14:30:00.000000Z" }, { "id": 9, "user_id": 2, "category_id": 2, "title": "Cooking Italian Cuisine", "content": "Authentic Italian recipes from my kitchen...", "image": "1709571200cooking.jpg", "created_at": "2024-03-04T08:00:00.000000Z", "updated_at": "2024-03-04T08:00:00.000000Z" } ] }
$posts = Post::where('user_id', $id)->get();
posts