98 lines
3.6 KiB
PHP
98 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Requests\LambdaRequest;
|
|
use DB;
|
|
|
|
class DomainController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
$this->_service = 'ums';
|
|
$this->_module = 'domain';
|
|
$this->_viewname = 'domain';
|
|
$this->_title = 'Domain';
|
|
$this->_base_url = '/domain';
|
|
}
|
|
|
|
public function form($type, $id = null) {
|
|
$values = [];
|
|
if($type == 'edit') {
|
|
$response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/get_one');
|
|
//echo '<pre>'; print_r($response); exit;
|
|
$values = $response->data->item;
|
|
}
|
|
$data = $this->_beforeform($type, $values);
|
|
$fields = $this->get_form_fields($type, $values);
|
|
//echo '<pre>'; print_r($data); exit;
|
|
return $this->view('form')->with([
|
|
'title' => $this->_title,
|
|
'mode' => $type,
|
|
'fields' => $fields,
|
|
'base_url' => $this->_base_url,
|
|
'item' => $values,
|
|
]);
|
|
}
|
|
|
|
protected function get_form_fields($type, $values){
|
|
$designations = [
|
|
'PM' => 'PM',
|
|
'MM' => 'MM',
|
|
'BH' => 'BH',
|
|
'DSH' => 'DSH',
|
|
'NSM' => 'NSM',
|
|
'ZBM' => 'ZBM',
|
|
'RBM' => 'RBM',
|
|
'SBM' => 'SBM',
|
|
'ABM' => 'ABM',
|
|
'STM' => 'Sr. TM',
|
|
'TM' => 'TM',
|
|
];
|
|
$territories = [
|
|
'Country' => 'Country',
|
|
'Zone' => 'Zone',
|
|
'State' => 'State',
|
|
'Region' => 'Region',
|
|
'Area' => 'Area',
|
|
'Pool Territory' => 'Pool Territory',
|
|
'Territory' => 'Territory',
|
|
];
|
|
return [
|
|
'id' => ['title' => '', 'type' => 'hidden'],
|
|
'name' => ['title' => 'Domain Name', 'type' => 'text', 'required' => true],
|
|
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
|
|
'designations' => ['title' => 'Designations', 'type' => 'multiselect', 'required' => true, 'values' => $designations ],
|
|
'territory_types' => ['title' => 'Territory Types', 'type' => 'multiselect', 'required' => true, 'values' => $territories ],
|
|
'logo' => ['title' => 'Group Image or Icon', 'type' => 'image', 'required' => true],
|
|
'description' => ['title' => 'Description', 'type' => 'textarea', 'required' => true],
|
|
'terms_text' => ['title' => 'Login Terms & Conditions Text', 'type' => 'textarea', 'required' => true, 'fullwidth' => true],
|
|
|
|
];
|
|
}
|
|
|
|
protected function _beforesave($type, $request) {
|
|
$data = $request->except('_token');
|
|
if( $request->file('logo') ) {
|
|
$data['logo'] = $this->_uploadMedia($request, 'logo', 'domain');
|
|
}
|
|
return $data;
|
|
}
|
|
|
|
public function save($type, $request ) {
|
|
if($type == 'edit') {
|
|
$url = '/update';
|
|
} else {
|
|
$url = '/create';
|
|
}
|
|
$data = $this->_beforesave($type, $request);
|
|
$response = LambdaRequest::signedrequest('post', $this->_service, $this->_module.$url, $data);
|
|
if($response->statusCode == 200 && $response->status == "success") {
|
|
return redirect($this->_base_url.'/edit')->withMessage('Successfully Saved !!!');
|
|
} else {
|
|
return \Redirect::back()->withMessage('Some Error occured!');
|
|
}
|
|
}
|
|
}
|