update state charges

This commit is contained in:
edmondlang
2022-04-19 13:28:56 +08:00
parent 1814352780
commit 7b88fd5c3c
5 changed files with 65 additions and 38 deletions
+6 -1
View File
@@ -1,8 +1,9 @@
<?php
namespace App\Http\Resources;
use App\Models\SegmentConstant;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Classes\ValueObjects\Constants\SegmentConstants;
class StateResource extends JsonResource
{
@@ -14,10 +15,14 @@ class StateResource extends JsonResource
*/
public function toArray($request)
{
$segmentConstant = (array) SegmentConstant::where('reference', SegmentConstants::STATE_RATE)->get()->first()->value;
return [
'id' => $this->id,
'name' => $this->name,
'country' => $this->country,
'stateCharges' => array_key_exists($this->id, $segmentConstant) ? $segmentConstant[$this->id] : null,
];
}
}