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

69 lines
2.6 KiB
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests\LambdaRequest;
use DB;
class BrandController extends Controller
{
public function __construct()
{
$this->middleware('auth');
$this->_service = 'catalog';
$this->_module = 'brand';
$this->_viewname = 'brand';
$this->_title = 'Brand';
$this->_base_url = '/brand';
}
protected function get_list_fields(){
return [
'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ],
'name' => ['title' => 'Brand Name', 'type' => 'text'],
'type' => ['title' => 'Brand Type', 'type' => 'text'],
'division' => ['title' => 'Division', 'type' => 'text'],
'company' => ['title' => 'Company', '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' => 'Brand Name', 'type' => 'text', 'required' => true],
'type' => ['title' => 'Brand Type', 'type' => 'select', 'values' => ['MDI'=>'MDI', 'DPI'=>'DPI', 'Oral'=>'Oral'] ],
'division' => ['title' => 'Division', 'type' => 'text'],
'company' => ['title' => 'Company', 'type' => 'text'],
'focus_brand' => ['title' => 'Focus Brand', 'type' => 'text'],
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
];
}
protected function _beforesave($type, $request) {
$data = $request->except('_token');
// if($type == 'edit') {
// $values->channels = explode('#', $values->channels);
// }
if( $request->file('media_url') ) {
$data['media_url'] = $this->_uploadMedia($request, 'media_url', 'banners');
}
$data['type'] = isset($data['type']) ? $data['type'] : '';
$data['division'] = isset($data['division']) ? $data['division'] : '';
$data['company'] = isset($data['company']) ? $data['company'] : '';
$data['focus_brand'] = isset($data['focus_brand']) ? $data['focus_brand'] : '';
return $data;
}
protected function _beforeform($type, $values) {
// if($type == 'edit') {
// $values->channels = explode('#', $values->channels);
// }
return $values;
}
}