<?php
/**
 * This is a file auto generated within the module that generates a json output of the values of the model. This file
 * then can be used when an ajax script wants the retrieve the models values. Or can also be used to feed to the CMS2+
 * pagedata select boxes dynamic options (see http://wiki.mtcmedia.co.uk/index.php?title=CMS2#Field_Type:_select for
 * more info) http://wiki.mtcmedia.co.uk/index.php?title=Module_Builder_1#cms_json.php
 * @author Rihards Siliņš
 * @version 1 09/03/2016
 * @copyright MTC media Ltd.
 */
$path = '../../../';
require_once $path.'core/includes/header.inc.php';
require_once 'includes/settings.php'; // MODEL SETTINGS

$model_class_name = MODEL_CLASS_NAMESPACE_PREFIX.MODEL_CLASS_NAME;
$page['title'] = 'Manage '.ucwords(MODEL_PLURAL);

$model_list = $model_class_name::orderBy('name')->get();

$json_list = array();

foreach ($model_list as $key => $model_list_item) {
    $json_list[$model_list_item->id] = $model_list_item->name;
}

die(json_encode($json_list));
