<?php

namespace App\Http\Controllers;

use App\TicketModel;
use Illuminate\Http\Request;
use App\Repositories\TicketRepository;
use App\Repositories\Interfaces\ITicketRepository;


class TicketController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    private $TicketRepository;
    public function __construct(Request  $request, ITicketRepository $TicketRepository) 
    {
        $this->TicketRepository  = $TicketRepository;

    }
    public function obtener_ticket($ruc ,Request $request)
    {
        //try {
            // $ticketModel = new TicketModel();
            //$tickets = $ticketModel->lista_tickets($ruc);
            $tickets=$this->TicketRepository->paginate($ruc, $request->all());
            return response()->json($tickets, 200);
        // } catch (\Throwable $th) {
        //     return response()->json(['error' => 'Error al obtener los tickets'], 500);
        // }
    }
    public function obtener_ticket_detalle($id_ticket){
    {
       // try {
            $detallesTicket=$this->TicketRepository->find($id_ticket);

            return response()->json($detallesTicket);
        //} catch (\Throwable $th) {
        //    return response()->json(['error' => 'Error al obtener los detalles del ticket.'], 500);
        //}
    }
}
}