78 lines
2.6 KiB
PHP
78 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Requests\LambdaRequest;
|
|
use DB;
|
|
use \stdClass;
|
|
|
|
class TopicController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
$this->_service = 'communication';
|
|
$this->_module = 'topic';
|
|
$this->_viewname = 'topic';
|
|
$this->_title = 'Topics';
|
|
$this->_base_url = '/topic';
|
|
}
|
|
|
|
protected function get_list_fields()
|
|
{
|
|
return [
|
|
'actions' => ['title' => 'Actions', 'buttons' => ['edit', 'delete']],
|
|
'name' => ['title' => 'Template Name', 'type' => 'text'],
|
|
'message' => ['title' => 'Message', 'type' => 'text'],
|
|
'description' => ['title' => 'Description', 'type' => 'text'],
|
|
'status' => ['title' => 'Status', 'type' => 'select']
|
|
];
|
|
}
|
|
|
|
protected function get_form_fields($type, $values)
|
|
{
|
|
return [
|
|
'name' => ['title' => 'Template Name', 'type' => 'text', 'required' => true],
|
|
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled']],
|
|
'description' => ['title' => 'Description', 'type' => 'text', 'required' => true, 'fullwidth' => true],
|
|
'message' => ['title' => 'Message', 'type' => 'textarea', 'required' => true, 'fullwidth' => true],
|
|
'image' => ['title' => 'Template Image', 'type' => 'image', 'required' => true]
|
|
];
|
|
}
|
|
|
|
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 ($type == 'edit') {
|
|
// $values->channels = explode('#', $values->channels);
|
|
// }
|
|
|
|
if ($request->file('image')) {
|
|
$data['image'] = $this->_uploadMedia($request, 'image', 'template');
|
|
}
|
|
return $data;
|
|
}
|
|
}
|