Rapport-Laravel/app/Http/Controllers/MetricController.php

47 lines
1.9 KiB
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests\LambdaRequest;
use DB;
class MetricController extends Controller
{
public function __construct()
{
$this->middleware('auth');
$this->_service = 'metric';
$this->_module = 'metric';
$this->_viewname = 'metric';
$this->_title = 'Metric';
$this->_base_url = '/metric';
}
protected function get_list_fields(){
return [
'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ],
'name' => ['title' => 'Metric Name', 'type' => 'text'],
'metric_type' => ['title' => 'Metric type', 'type' => 'text'],
'allow_negetive' => ['title' => 'Allow Negetive', 'type' => 'text'],
'status' => ['title' => 'Status', 'type' => 'select'],
];
}
protected function get_form_fields($type, $values){
$channels = $this->getlambda('get', 'ums', 'channel', 'dropdown');
$channels_dd = [];
foreach($channels->data->items as $channel){
$channels_dd[$channel->id] = $channel->name;
}
return [
'name' => ['title' => 'Magazine Name', 'type' => 'text', 'required' => true],
'channel' => ['title' => 'Channel', 'type' => 'select', 'required' => true, 'values' => $channels_dd ],
'description' => ['title' => 'Description', 'type' => 'textarea', 'required' => true, 'fullwidth' => true],
'metric_type' => ['title' => 'Metric Type', 'type' => 'select', 'required' => true, 'values' => ['normal' => 'Normal', 'calculated' => 'Calculated'] ],
'allow_negetive' => ['title' => 'Allow Negetive', 'type' => 'yesno', 'required' => true],
'unit_type' => ['title' => 'Unit Type', 'type' => 'select', 'required' => true, 'values' => ['primitive' => 'Primitive', 'points' => 'Points', 'percentage' => 'Percentage'] ],
];
}
}