Search
Search
Search
Search
Information
Information
Light
Dark
Open actions menu
Basic upload method
Bypass upload method
Tips!
If you encounter an error (by firewall) while uploading using both methods,
try changing extension of the file before uploading it and rename it right after.
This uploader supports multiple file upload.
Submit
~
var
www
multi-event-cfp.bitkit.dk
httpdocs
app
Http
Controllers
File Content:
EventController.php
<?php namespace App\Http\Controllers; use App\Http\Requests\EventRequest; use App\Jobs\SendEventCreatedMails; use App\Models\Event; use App\Models\File; use App\Models\Score; use App\Models\User; use App\Repositories\EventRepository; use App\Support\Entity; use Exception; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\Storage; use Illuminate\Validation\ValidationException; use Symfony\Component\HttpFoundation\StreamedResponse; class EventController extends Controller { protected $repository; public function __construct(EventRepository $eventRepository) { $this->repository = $eventRepository; } /** * @throws AuthorizationException * @throws Exception */ public function create(EventRequest $request) { try { $this->authorize('create', Event::class); $data = $this->repository->create($request); $this->dispatch(new SendEventCreatedMails($data)); $data->offsetUnset('new_user_passwords'); $event = $data->event; activity('event.create') ->causedBy(authUser()) ->log('Event created'); $eventData = new Entity([ 'id' => $event->id, 'event_name' => $event->event_name, 'year' => $event->year, 'published' => $event->published, 'publish_step' => $event->publish_step, 'published_date' => $event->published_date, 'slug_name' => $event->slug_name, 'edition_ids' => $event->edition_ids, 'division' => $event->division, 'created_at' => $event->created_at->format('Y-m-d h:i:s'), 'updated_at' => $event->updated_at->format('Y-m-d h:i:s'), 'event_admins' => $data['event_admins'] ]); return response([ 'status' => true, 'message' => 'Event created successfully', 'event' => $eventData ]); } catch (Exception $exception) { return $this->handleException($exception, __FUNCTION__, __CLASS__); } } /** * @throws AuthorizationException * @throws ValidationException * @throws Exception */ public function update(Request $request, $id) { try { $this->authorize('update', Event::class); $request->merge([ 'id' => $id ]); $data = $this->repository->update($request); $event = $data->event; $this->dispatch(new SendEventCreatedMails($data)); activity('event.update') ->causedBy(authUser()) ->performedOn($event) ->log('Event updated'); $eventData = new Entity([ 'id' => $event->id, 'event_name' => $event->event_name, 'year' => $event->year, 'published' => $event->published, 'publish_step' => $event->publish_step, 'published_date' => $event->published_date, 'slug_name' => $event->slug_name, 'edition_ids' => $event->edition_ids, 'division' => $event->division, 'created_at' => $event->created_at->format('Y-m-d h:i:s'), 'updated_at' => $event->updated_at->format('Y-m-d h:i:s'), 'event_admins' => $data['event_admins'] ]); return response([ 'status' => true, 'message' => 'Event updated successfully', 'event' => $eventData ]); } catch (Exception $exception) { return $this->handleException($exception, __FUNCTION__, __CLASS__); } } /** * @throws Exception */ public function delete(Request $request, $id) { try { $this->authorize('delete', Event::class); $this->repository->delete($id); activity('event.delete') ->causedBy(authUser()) ->log('Event deleted - ' . $id); return response([ 'status' => true, 'message' => 'Event deleted successfully' ]); } catch (Exception $exception) { return $this->handleException($exception, __FUNCTION__, __CLASS__); } } /** * @throws AuthorizationException * @throws Exception */ public function list(Request $request, $paginate = true) { try { $this->authorize('view', Event::class); $request->merge(['user' => 'event_admin']); $data = $this->repository->listing($request, $paginate); $total = $data->count(); $data = $data->toArray(); unset($data['links']); $paging = $request->get('paging', '10'); return response([ 'status' => true, 'events' => $paging == 'All' ? ['data' => $data, 'total' => $total] : $data ]); } catch (Exception $exception) { return $this->handleException($exception, __FUNCTION__, __CLASS__); } } /** * @throws AuthorizationException * @throws Exception */ public function view(Request $request, $id) { try { $event = is_numeric($id) ? Event::find($id) : Event::whereSlugName($id)->first(); if (!$event) validationErrorResponse(['Invalid event id or slug name']); $this->authorize('view', [Event::class, $event]); $eventAdmins = $event->users('event_admin')->get(); $admins = []; foreach ($eventAdmins as $eventAdmin) { $eventUser = getEventUser($event->id, $eventAdmin->id); $admin['email'] = $eventAdmin->email; $admin['developer_options'] = $eventUser->developer_options; $admin['all_user_api_access'] = $eventUser->all_user_api_access; $admin['user_export_access'] = $eventUser->user_export_access; $admin['abstract_export_access'] = $eventUser->abstract_export_access; $admin['presentation_files_download_access'] = $eventUser->presentation_files_download_access; $admin['access_level'] = $eventUser->access_level; $admin['vip_categories'] = $eventUser->vip_categories ?? []; $admins[] = $admin; } $count = $this->repository->getEventCounts($event); $event->admins = $admins; // scored abstracts count $scoredAbstractsCount = Score::where('event_id', $event->id)->count(); // is there is scored abstracts $hasScoredAbstracts = $scoredAbstractsCount > 0; // score settings $scoreSettings = $event->score_settings; // return first score as well if ($hasScoredAbstracts) { $firstScore = Score::select('score')->where('event_id', $event->id)->first(); $scoreSettings['first_score'] = $firstScore; } // update score settings $scoreSettings['scored_abstracts'] = $hasScoredAbstracts; $event->score_settings = $scoreSettings; return response([ 'status' => true, 'event' => $event, 'count' => $count ]); } catch (Exception $exception) { return $this->handleException($exception, __FUNCTION__, __CLASS__); } } /** * @param Request $request * @param $eventId * @return Entity|Application|ResponseFactory|Response * @throws Exception */ public function publish(Request $request, $eventId) { try { $event = Event::find($eventId); if (!$event) validationErrorResponse(['Invalid event id']); $this->authorize('publish', [Event::class, $event, $request->get('event_user')]); $request->merge(['id' => $eventId]); [$event, $message] = $this->repository->publishEvent($request, $event); activity('event.publish') ->causedBy(authUser()) ->log('Event publish step ' . $event->publish_step); return response([ 'status' => true, 'event' => $event, 'message' => $message ]); } catch (Exception $exception) { return $this->handleException($exception, __FUNCTION__, __CLASS__); } } /** * @param Request $request * @param $event * @return Entity|Application|ResponseFactory|Response * @throws Exception */ public function eventCounts(Request $request, $event) { try { $event = Event::find($event); if (!$event) validationErrorResponse(['Event not found']); $data = $this->repository->getEventCounts($event); return response([ 'status' => true, 'data' => $data ]); } catch (Exception $exception) { return $this->handleException($exception, __FUNCTION__, __CLASS__); } } /** * @param Request $request * @param $event * @param null $page * @return Entity|Application|ResponseFactory|Response * @throws Exception */ public function meta(Request $request, $event, $page = null) { try { $event = Event::whereSlugName($event)->first(); if (!$event) validationErrorResponse(['Event not found']); $role = $request->get('role'); if (!$event->published && $role != 'event_admin') return response([ 'status' => false, 'message' => "Not found" ], 404); $meta = $this->repository->getEventMetaData($event, $page); return response([ 'status' => true, 'meta' => $meta, ]); } catch (Exception $exception) { return $this->handleException($exception, __FUNCTION__, __CLASS__); } } /** * @param Request $request * @param $fileId * @return Entity|Application|ResponseFactory|Response|StreamedResponse * @throws Exception */ public function downloadTemplateFile(Request $request, $fileId) { try { $event = $request->get('event'); $file = File::whereId($fileId) ->whereModelId($event->id) ->whereModel(Event::class) ->first(); if (!$file) return response([ 'status' => false, 'message' => "File not found" ]); $filePath = $file->filepath . $file->save_name; return Storage::download($filePath, $file->filename); } catch (Exception $exception) { return $this->handleException($exception, __FUNCTION__, __CLASS__); } } /** * @param Request $request * @param $id * @return Response * @throws Exception */ public function updateStatus(Request $request) { try { // event id $eventId = $request->get('eventId'); // event status $status = $request->get('newStatus'); // event $event = Event::find($eventId); if (!$event) { return response([ 'status' => false, 'message' => "Event not found" ]); } $event->status = $status; $event->save(); return response([ 'status' => true, 'message' => 'Event status updated successfully', 'event' => $event ]); } catch (Exception $exception) { return $this->handleException($exception, __FUNCTION__, __CLASS__); } } }
Edit
Download
Unzip
Chmod
Delete