<?php

namespace App\Http\Controllers\API;

use App\Http\Controllers\Controller;
use App\Http\Resources\RequestPaginationResource;
use App\Http\Resources\ServiceRequestResource;
use App\Models\ServiceRequest as ModelsServiceRequest;
use App\Models\PartnerRequest as ModelsPartnerRequest;
class RequestsController extends Controller
{
    public function getServiceRequests()
    {
        $user = request()->user();

        $requests = ModelsServiceRequest::where('user_id', $user->id)->orderBy('id', 'desc')->paginate(10);

        return (new RequestPaginationResource($requests))->response();
    }

    public function getPartnerRequests()
    {
        $user = request()->user();

        $requests = ModelsPartnerRequest::where('user_id', $user->id)->orderBy('id', 'desc')->paginate(10);
        

        return (new RequestPaginationResource($requests))->response();
    }

    public function show($service_request_id)
    {
        $user = request()->user();
        $request = ModelsServiceRequest::where('user_id', $user->id)->where('id', $service_request_id)->firstOrFail();

        return new ServiceRequestResource($request);
    }
}
