Procházet zdrojové kódy

feat: ajusta ordem

ebagabee před 1 měsícem
rodič
revize
2c65790730

+ 4 - 0
app/Http/Resources/FranchiseeContractResource.php

@@ -34,6 +34,10 @@ public function toArray(Request $request): array
             'marketing_fund_percentage'    => $this->marketing_fund_percentage,
             'maintance_tax_percentage'     => $this->maintance_tax_percentage,
             'inhabitant_classification_id' => $this->inhabitant_classification_id,
+            'inhabitant_classification'    => $this->whenLoaded('inhabitantClassification', fn() => [
+                'id'          => $this->inhabitantClassification->id,
+                'description' => $this->inhabitantClassification->description,
+            ]),
             'validity_months'              => $this->validity_months,
             'contract_month_current'       => $contractMonthCurrent,
             'created_at'                   => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),

+ 1 - 0
app/Services/FranchiseeContractService.php

@@ -37,6 +37,7 @@ public function getByUnitId(int $unitId): Collection
         return FranchiseeContract::with('inhabitantClassification')
             ->where('unit_id', $unitId)
             ->orderBy('created_at', 'desc')
+            ->orderBy('id', 'desc')
             ->get();
     }
 

+ 3 - 1
app/Services/InhabitantClassificationService.php

@@ -17,7 +17,9 @@ public function getAll(): Collection
     public function getSelectList(): Collection
     {
         return InhabitantClassification::orderBy('id')
-            ->get(['id', 'description', 'start', 'end', 'tbr_percentage']);
+            ->get(['id', 'description', 'start', 'end', 'tbr_percentage'])
+            ->unique('description')
+            ->values();
     }
 
     public function findById(int $id): ?InhabitantClassification