<?php
/**
 * This script prints items in a json
 * @author Rihards Silins <rihards.silins@mtcmedia.co.uk>
 * @version 1
 */

$path = '../../../';
require_once $path . 'core/includes/header.inc.php';

use Mtc\Shop\Item;

$item_array = Item::select('id', 'name')->orderBy("name")->get();

$result = [0 => "-- Select item --"];

for ($i=0; $i < count($item_array); $i++) {
    $result[$item_array[$i]->id] = $item_array[$i]->name;
}

die(json_encode($result));
