<?php

namespace App\Http\Controllers\Api\Elementos;

use App\Danoral\Elementos\ListItem;
use Illuminate\Http\Request;

use App\Http\Controllers\Controller;
use App\Http\Resources\ListItem as ListItemResource;

class ListItemController extends Controller
{
    protected $listItem;

    public function __construct(ListItem $listItem){
        $this->listItem = $listItem;
    }

    public function getListItem(Request $request){
        if(isset($request->idListItem)) {
            $listItem = ListItem::find($request->idListItem);

            if($listItem){
                $listItem->loadColumns();
                return response()->json(new ListItemResource($listItem), 200);
            }
        }
        return response()->json('ERROR', 200);
    }
}
