-
app/Http/Resources/ReservationResource.php
Open in GitHubuse Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class ReservationResource extends JsonResource { public function toArray($request) { return [ 'id' => $this->id, 'spot_id' => (string)$this->spot_id, 'start' => $this->start->toDateTimeString(), 'end' => $this->end->toDateTimeString(), 'paid_at' => optional($this->paid_at)->toDateTimeString(), 'paid_amount' => $this->paid_amount, 'created_at' => $this->created_at->toDateTimeString() ]; } }
-
app/Http/Controllers/Api/ReservationController.php
Open in GitHubuse App\Http\Controllers\Controller; use App\Http\Resources\ReservationResource; use App\Models\Reservation; use Illuminate\Http\Request; class ReservationController extends Controller { public function show(Request $request, Reservation $reservation): ReservationResource { return new ReservationResource($reservation); } // |