<?php

namespace App\Http\Controllers\Api\Transacciones;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

use App\Danoral\Transacciones\Trans ;
use App\Http\Controllers\Controller;

use App\Http\Resources\Trans as TransResources;

class TransController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  bigint  $idT
     * @return \Illuminate\Http\Response
     */
    public function show($idT)
    {
        return response()->json(
            new TransResources(Trans::find($idT)), 
            200);
    
    }
    

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }



    public function getTypeT() {
        $typesT = DB::table('config.trans_types')->get();

        return response()->json($typesT, 200);
    }

    public function getInicialEntidad(Request $request){
        /*
        return response()->json(Trans::getInicialEntidad($request->idE, $request->anoT), 
            200);
        */
        return response()->json(
            new TransResources(Trans::getInicialEntidad($request->idE, $request->anoT)), 
            200);
    }



}
