<?php

namespace App\Http\Controllers\Api\V1\PostBranch;

use App\Http\Controllers\Controller;
use App\Models\Post\PostBranch;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class PostBranchController extends Controller
{
    /**
     * All post branches
     */
    public function index(Request $request): JsonResponse
    {
        return response()->rest(
            PostBranch::query()
                ->get()
                ->map(fn ($postBranch) => [
                    'id' => $postBranch->id,
                    'province_id' => $postBranch->province_id,
                    'name' => $postBranch->name,
                    'address' => $postBranch->address,
                    'description' => $postBranch->description,
                ])
        );
    }
}
