147 lines
6.5 KiB
PHP
147 lines
6.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Requests\LambdaRequest;
|
|
use DB;
|
|
|
|
class DetailingcontestresponseController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
$this->_service = 'detailing';
|
|
$this->_module = 'contest_response';
|
|
$this->_viewname = 'detailingcontestresponse';
|
|
$this->_title = 'Detailing Contests Responses';
|
|
$this->_base_url = '/detailingcontestresponse';
|
|
}
|
|
|
|
public function list(Request $request) {
|
|
$con_id = $request->session()->get('con_id');
|
|
if($con_id === 0) {
|
|
return redirect('/magazines')->withError('Magazine not found!');
|
|
}
|
|
$response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/get_all', ['con_id' => $con_id]);
|
|
echo '<pre>'; print_r($response->data); exit;
|
|
$items = [];
|
|
foreach ($response->data->items as $item) {
|
|
$item->user_name = $item->user_info->name;
|
|
$item->avatar = $item->user_info->avatar;
|
|
$items[] = $item;
|
|
}
|
|
|
|
$fields = $this->get_list_fields();
|
|
return $this->view('list')->with([
|
|
'title' => $this->_title . ' : ' . $response->data->contest->name,
|
|
'fields' => $fields,
|
|
'base_url' => $this->_base_url,
|
|
'items' => $items,
|
|
//'evaluations' => $response->data->evaluations,
|
|
'buttons' => $this->get_list_buttons()
|
|
]);
|
|
}
|
|
|
|
//['title' => 'Add New', 'link' => $this->_base_url.'/addnew' ],
|
|
protected function get_list_buttons() {
|
|
return [ ['title' => 'Back to Detailing Contests', 'link' => '/detailingcontests'] ];
|
|
}
|
|
|
|
protected function get_list_fields(){
|
|
return [
|
|
'actions' => ['title' => 'Actions', 'buttons' => [ 'view' => ['icon' => 'eye', 'querystring' => 'id={ID}'], 'delete', 'evaluations' => ['icon' => 'book-check', 'querystring' => 'id={ID}'] ] ],
|
|
'avatar' => ['title' => 'User Avatar', 'type' => 'image'],
|
|
'user_name' => ['title' => 'User Name', 'type' => 'text'],
|
|
'title' => ['title' => 'Media Name', 'type' => 'text'],
|
|
'media_type' => ['title' => 'Media Type', 'type' => 'text'],
|
|
'createdAt' => ['title' => 'Submitted On', 'type' => 'date'],
|
|
'marks' => ['title' => 'Avg. Marks', 'type' => 'text'],
|
|
'total' => ['title' => 'Avg. Total', 'type' => 'text'],
|
|
'result' => ['title' => 'Result', 'type' => 'text'],
|
|
'no_of_evaluations' => ['title' => 'No of Evaluations', 'type' => 'text'],
|
|
'likes_count' => ['title' => 'Likes', 'type' => 'text'],
|
|
'comments_count' => ['title' => 'Comments', 'type' => 'text'],
|
|
//'status' => ['title' => 'Status', 'type' => 'select'],
|
|
];
|
|
}
|
|
|
|
protected function get_form_fields($type, $values){
|
|
$groups = $this->getlambda('get', 'ums', 'group', 'dropdown');
|
|
$groups_dd = [];
|
|
foreach($groups->data->items as $group){
|
|
$groups_dd[$group->id] = $group->name;
|
|
}
|
|
$fields = [
|
|
'name' => ['title' => 'Media Name', 'type' => 'text', 'required' => true],
|
|
'points' => ['title' => 'Points', 'type' => 'text', 'required' => true],
|
|
'description' => ['title' => 'Media Description', 'type' => 'textarea', 'required' => true, 'fullwidth' => true],
|
|
'media_type' => ['title' => 'Media Types', 'type' => 'select', 'required' => true, 'values' => ['image' => 'Image', 'video' => 'Video', 'pdf' => 'PDF', 'audio' => 'Audio', 'gallery' => 'Gallery', 'form' => 'Form', 'external' => 'External Url', 'scorm' => 'Scorm'] ],
|
|
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
|
|
|
|
//'media_thumb' => ['title' => 'Media Thumb', 'type' => 'image', 'required' => true],
|
|
'media_url' => ['title' => 'Media File (image, video, pdf, audio, scorm) (for gallery, upload zip file with all images)', 'type' => 'file'],
|
|
'gallery' => ['title' => 'Multiple Media File (only for gallery)', 'type' => 'multiimage'],
|
|
'ext_url' => ['title' => 'Media Url (form, external)', 'type' => 'text'],
|
|
];
|
|
return $fields;
|
|
}
|
|
|
|
protected function _beforesave($type, $request) {
|
|
$data = $request->except('_token');
|
|
$data['magazine_id'] = $request->session()->get('mag_id');
|
|
// if( $request->file('media_thumb') ) {
|
|
// $data['media_thumb'] = $this->_uploadMedia($request, 'media_thumb', 'magazine_media_thumb');
|
|
// }
|
|
if( $request->file('media_url') ) {
|
|
$data['media_url'] = $this->_uploadMedia($request, 'media_url', 'magazine_media');
|
|
}
|
|
if($data['media_type'] == 'form' || $data['media_type'] == 'external') {
|
|
$data['media_url'] = $data['ext_url'];
|
|
}
|
|
if($data['media_type'] == 'gallery') {
|
|
$galleries = [];
|
|
if($request->file('gallery')) {
|
|
foreach($request->file('gallery') as $img) {
|
|
$galleries[] = env('AWS_URL').'/'.$img->store('magazine_media', 's3');
|
|
}
|
|
}
|
|
if(isset($data['gallery_existing'])) {
|
|
foreach($data['gallery_existing'] as $gallery_existing) {
|
|
$galleries[] = $gallery_existing;
|
|
}
|
|
}
|
|
$data['media_url'] = json_encode($galleries);
|
|
}
|
|
unset($data['gallery_existing']);
|
|
unset($data['gallery']);
|
|
unset($data['ext_url']);
|
|
//echo '<pre>'; print_r($data); exit;
|
|
return $data;
|
|
}
|
|
|
|
protected function _beforeform($type, $values) {
|
|
if($type == 'edit') {
|
|
if($values->media_type == 'form' || $values->media_type == 'external') {
|
|
$values->ext_url = $values->media_url;
|
|
} else {
|
|
$values->ext_url = '';
|
|
}
|
|
if($values->media_type == 'gallery' ) {
|
|
$values->gallery = json_decode($values->media_url);
|
|
}
|
|
unset($values->user_info);
|
|
unset($values->likes);
|
|
unset($values->likes_users);
|
|
unset($values->comments);
|
|
unset($values->views);
|
|
unset($values->comments_users);
|
|
unset($values->likes_count);
|
|
unset($values->comments_count);
|
|
|
|
//echo '<pre>'; print_r($values); exit;
|
|
}
|
|
return $values;
|
|
}
|
|
|
|
}
|