<?php

namespace App\Domains\CostUnit\Controllers;

use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;

class DistanceAllowanceController extends CommonController {
    public function __invoke(int $costUnitId) : JsonResponse {
        $distanceAllowance = 0.00;
        $costUnit = $this->costUnits->getById($costUnitId, true);
        if (null !== $costUnit) {
            $distanceAllowance = $costUnit->distance_allowance;
        }

        return response()->json([
            'distanceAllowance' => $distanceAllowance
        ]);
    }
}
