|
|
@@ -0,0 +1,60 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Http\Resources;
|
|
|
+
|
|
|
+use Carbon\Carbon;
|
|
|
+use Illuminate\Http\Request;
|
|
|
+use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
+use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
|
|
+use App\Models\TbrCalculation;
|
|
|
+
|
|
|
+class TbrCalculationResource extends JsonResource
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * Transform the resource into an array.
|
|
|
+ *
|
|
|
+ * @return array<string, mixed>
|
|
|
+ */
|
|
|
+ public function toArray(Request $request): array
|
|
|
+ {
|
|
|
+ return [
|
|
|
+ 'id' => $this->id,
|
|
|
+ 'unit_id' => $this->unit_id,
|
|
|
+ 'revenue_value' => $this->revenue_value,
|
|
|
+ 'contract_month_reference' => $this->contract_month_reference,
|
|
|
+ 'tbr_value' => $this->tbr_value,
|
|
|
+ 'royalties_bracket_id' => $this->royalties_bracket_id,
|
|
|
+ 'royalties_bracket_percentage' => $this->royalties_bracket_percentage,
|
|
|
+ 'royalties_bracket_value' => $this->royalties_bracket_value,
|
|
|
+ 'fnm_bracket_id' => $this->fnm_bracket_id,
|
|
|
+ 'fnm_bracket_percentage' => $this->fnm_bracket_percentage,
|
|
|
+ 'fnm_bracket_value' => $this->fnm_bracket_value,
|
|
|
+ 'maintenance_bracket_id' => $this->maintenance_bracket_id,
|
|
|
+ 'maintenance_bracket_percentage' => $this->maintenance_bracket_percentage,
|
|
|
+ 'maintenance_bracket_value' => $this->maintenance_bracket_value,
|
|
|
+ 'royalties_effective_percentage' => $this->royalties_effective_percentage,
|
|
|
+ 'royalties_effective_value' => $this->royalties_effective_value,
|
|
|
+ 'fnm_effective_percentage' => $this->fnm_effective_percentage,
|
|
|
+ 'fnm_effective_value' => $this->fnm_effective_value,
|
|
|
+ 'maintenance_effective_percentage' => $this->maintenance_effective_percentage,
|
|
|
+ 'maintenance_effective_value' => $this->maintenance_effective_value,
|
|
|
+ 'bracket_subtotal' => $this->bracket_subtotal,
|
|
|
+ 'subtotal' => $this->subtotal,
|
|
|
+ 'final_value' => $this->final_value,
|
|
|
+ 'user_id' => $this->user_id,
|
|
|
+ 'royalties_applied_criteria' => $this->royalties_applied_criteria,
|
|
|
+ 'receivable_generated' => $this->receivable_generated,
|
|
|
+ 'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
|
|
|
+ 'updated_at' => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param \Illuminate\Database\Eloquent\Collection<TbrCalculation> $resource
|
|
|
+ * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection<TbrCalculationResource>
|
|
|
+ */
|
|
|
+ public static function collection($resource): AnonymousResourceCollection
|
|
|
+ {
|
|
|
+ return parent::collection($resource);
|
|
|
+ }
|
|
|
+}
|