middleware('auth'); $this->_service = 'wall'; $this->_module = 'wallbanner'; $this->_viewname = 'banner'; $this->_title = 'Banner'; $this->_base_url = '/banner'; } protected function get_list_fields(){ return [ 'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ], 'media_url' => ['title' => 'Media', 'type' => 'image'], 'title' => ['title' => 'Title', '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 [ 'title' => ['title' => 'Title', 'type' => 'text', 'required' => true], 'channels' => ['title' => 'Channels', 'type' => 'multiselect', 'required' => true, 'values' => $channels_dd ], 'scheduled' => ['title' => 'Scheduled', 'type' => 'yesno', 'required' => true, 'fullwidth' => true], 'schedule_start_date' => ['title' => 'Schedule start date', 'type' => 'date'], 'schedule_end_date' => ['title' => 'Schedule end date', 'type' => 'date'], 'media_url' => ['title' => 'Banner Image', 'type' => 'image', 'required' => true], ]; } 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'); } return $data; } protected function _beforeform($type, $values) { if($type == 'edit') { $values->channels = explode('#', $values->channels); } return $values; } }