86 lines
2.9 KiB
PHP
86 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Requests\LambdaRequest;
|
|
use DB;
|
|
use \stdClass;
|
|
|
|
class ContactlistController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
$this->_service = 'contact';
|
|
$this->_module = 'contact_list';
|
|
$this->_viewname = 'contactlist';
|
|
$this->_title = 'Contact List';
|
|
$this->_base_url = '/contactlist';
|
|
}
|
|
|
|
protected function get_list_fields()
|
|
{
|
|
return [
|
|
'actions' => ['title' => 'Actions', 'buttons' => ['edit', 'delete']],
|
|
'name' => ['title' => 'Name', 'type' => 'text'],
|
|
'status' => ['title' => 'Status', 'type' => 'select']
|
|
];
|
|
}
|
|
|
|
protected function get_form_fields($type, $values)
|
|
{
|
|
// $teams = $this->getlambda('get', 'communication', 'template', 'dropdown');
|
|
// // echo '<pre>'; print_r($teams); exit;
|
|
// $templates = [];
|
|
// foreach ($teams->data->items as $team) {
|
|
// $templates[$team->template_code] = $team->name;
|
|
// }
|
|
|
|
// $chans = $this->getlambda('get', 'communication', 'channel', 'dropdown');
|
|
// // echo '<pre>'; print_r($teams); exit;
|
|
// $channels = [];
|
|
// foreach ($chans->data->items as $chan) {
|
|
// $channels[$chan->id] = $chan->name;
|
|
// }
|
|
|
|
return [
|
|
'name' => ['title' => 'Name', 'type' => 'text', 'required' => true],
|
|
'type' => ['title' => 'Type', 'type' => 'select', 'values' => ["normal" => "Normal","dynamic" => "Dynamic"], 'required' => true],
|
|
'conditions' => ['title' => 'Conditions', 'type' => 'textarea', 'fullwidth' => true],
|
|
|
|
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled']],
|
|
];
|
|
}
|
|
|
|
public function form($type, $id = null)
|
|
{
|
|
$values = [];
|
|
if ($type == 'edit') {
|
|
$response = LambdaRequest::signedrequest('get', $this->_service, $this->_module . '/get_one', ['id' => $id]);
|
|
$values = $response->data->item;
|
|
// echo '<pre>'; print_r($values); exit;
|
|
}
|
|
//echo '<pre>'; print_r($values); exit;
|
|
$data = $this->_beforeform($type, $values);
|
|
$fields = $this->get_form_fields($type, $values);
|
|
//echo '<pre>'; print_r($fields); exit;
|
|
return $this->view('form')->with([
|
|
'title' => $this->_title,
|
|
'mode' => $type,
|
|
'fields' => $fields,
|
|
'base_url' => $this->_base_url,
|
|
'item' => $values,
|
|
]);
|
|
}
|
|
|
|
protected function _beforesave($type, $request)
|
|
{
|
|
$data = $request->except('_token');
|
|
if ($request->file('image')) {
|
|
$data['image'] = $this->_uploadMedia($request, 'image', 'template');
|
|
}
|
|
return $data;
|
|
}
|
|
}
|