Attendize/app/Http/Controllers/EventTicketsController.php

282 lines
8.6 KiB
PHP
Raw Normal View History

2016-03-05 00:18:10 +00:00
<?php
namespace App\Http\Controllers;
2016-02-29 15:59:36 +00:00
use App\Models\Event;
use App\Models\Ticket;
2016-03-05 00:18:10 +00:00
use Carbon\Carbon;
2016-03-16 14:25:14 +00:00
use Illuminate\Http\Request;
2016-03-05 00:18:10 +00:00
use Log;
2016-02-29 15:59:36 +00:00
/*
Attendize.com - Event Management & Ticketing
*/
2016-03-05 00:18:10 +00:00
class EventTicketsController extends MyBaseController
{
/**
* @param Request $request
* @param $event_id
* @return mixed
*/
2016-03-16 14:25:14 +00:00
public function showTickets(Request $request, $event_id)
2016-03-05 00:18:10 +00:00
{
2016-03-16 14:25:14 +00:00
$allowed_sorts = [
(localization) Several big changes: 1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login 2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers. 3) Edited routes to accomodate point 1 4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used. 5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings). There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense: 1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites. 2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients. 3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code. 4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here. 5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases. and other. There are also some inconveniences, like: 1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys). 2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up. 3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages. 4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable. 5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
'created_at' => trans("Controllers.sort.created_at"),
'title' => trans("Controllers.sort.title"),
'quantity_sold' => trans("Controllers.sort.quantity_sold"),
'sales_volume' => trans("Controllers.sort.sales_volume"),
'sort_order' => trans("Controllers.sort.sort_order"),
2016-03-16 14:25:14 +00:00
];
2016-02-29 15:59:36 +00:00
2016-03-16 14:25:14 +00:00
// Getting get parameters.
$q = $request->get('q', '');
$sort_by = $request->get('sort_by');
2016-06-15 02:31:24 +00:00
if (isset($allowed_sorts[$sort_by]) === false) {
$sort_by = 'sort_order';
2016-06-15 02:31:24 +00:00
}
2016-02-29 15:59:36 +00:00
2016-03-16 14:25:14 +00:00
// Find event or return 404 error.
$event = Event::scope()->find($event_id);
2016-06-15 02:31:24 +00:00
if ($event === null) {
2016-03-16 14:25:14 +00:00
abort(404);
2016-06-15 02:31:24 +00:00
}
2016-02-29 15:59:36 +00:00
2016-03-16 14:25:14 +00:00
// Get tickets for event.
$tickets = empty($q) === false
? $event->tickets()->where('title', 'like', '%' . $q . '%')->orderBy($sort_by, 'asc')->paginate()
: $event->tickets()->orderBy($sort_by, 'asc')->paginate();
2016-02-29 15:59:36 +00:00
2016-03-16 14:25:14 +00:00
// Return view.
return view('ManageEvent.Tickets', compact('event', 'tickets', 'sort_by', 'q', 'allowed_sorts'));
2016-02-29 15:59:36 +00:00
}
/**
* Show the edit ticket modal
*
* @param $event_id
* @param $ticket_id
* @return mixed
*/
2016-03-05 00:18:10 +00:00
public function showEditTicket($event_id, $ticket_id)
{
2016-02-29 15:59:36 +00:00
$data = [
2016-06-15 02:31:24 +00:00
'event' => Event::scope()->find($event_id),
'ticket' => Ticket::scope()->find($ticket_id),
2016-02-29 15:59:36 +00:00
];
2016-03-16 14:32:17 +00:00
return view('ManageEvent.Modals.EditTicket', $data);
2016-02-29 15:59:36 +00:00
}
/**
* Show the create ticket modal
*
* @param $event_id
* @return \Illuminate\Contracts\View\View
*/
2016-03-05 00:18:10 +00:00
public function showCreateTicket($event_id)
{
return view('ManageEvent.Modals.CreateTicket', [
2016-06-15 02:31:24 +00:00
'event' => Event::scope()->find($event_id),
2016-03-05 00:18:10 +00:00
]);
2016-02-29 15:59:36 +00:00
}
/**
* Creates a ticket
*
* @param $event_id
* @return \Illuminate\Http\JsonResponse
*/
public function postCreateTicket(Request $request, $event_id)
2016-03-05 00:18:10 +00:00
{
2016-02-29 15:59:36 +00:00
$ticket = Ticket::createNew();
if (!$ticket->validate($request->all())) {
return response()->json([
2016-06-15 02:31:24 +00:00
'status' => 'error',
'messages' => $ticket->errors(),
2016-03-05 00:18:10 +00:00
]);
2016-02-29 15:59:36 +00:00
}
2016-09-06 20:39:27 +00:00
$ticket->event_id = $event_id;
$ticket->title = $request->get('title');
$ticket->quantity_available = !$request->get('quantity_available') ? null : $request->get('quantity_available');
2016-09-06 20:39:27 +00:00
$ticket->start_sale_date = $request->get('start_sale_date') ? Carbon::createFromFormat('d-m-Y H:i',
$request->get('start_sale_date')) : null;
$ticket->end_sale_date = $request->get('end_sale_date') ? Carbon::createFromFormat('d-m-Y H:i',
$request->get('end_sale_date')) : null;
$ticket->price = $request->get('price');
$ticket->min_per_person = $request->get('min_per_person');
$ticket->max_per_person = $request->get('max_per_person');
$ticket->description = $request->get('description');
$ticket->is_hidden = $request->get('is_hidden') ? 1 : 0;
2016-06-15 02:31:24 +00:00
2016-02-29 15:59:36 +00:00
$ticket->save();
session()->flash('message', 'Successfully Created Ticket');
2016-02-29 15:59:36 +00:00
return response()->json([
2016-06-15 02:31:24 +00:00
'status' => 'success',
'id' => $ticket->id,
(localization) Several big changes: 1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login 2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers. 3) Edited routes to accomodate point 1 4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used. 5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings). There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense: 1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites. 2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients. 3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code. 4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here. 5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases. and other. There are also some inconveniences, like: 1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys). 2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up. 3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages. 4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable. 5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
'message' => trans("Controllers.refreshing"),
2016-06-15 02:31:24 +00:00
'redirectUrl' => route('showEventTickets', [
'event_id' => $event_id,
]),
2016-03-05 00:18:10 +00:00
]);
2016-02-29 15:59:36 +00:00
}
2016-03-05 00:18:10 +00:00
/**
* Pause ticket / take it off sale
*
* @param Request $request
* @return mixed
*/
public function postPauseTicket(Request $request)
2016-03-05 00:18:10 +00:00
{
$ticket_id = $request->get('ticket_id');
2016-02-29 15:59:36 +00:00
$ticket = Ticket::scope()->find($ticket_id);
2016-03-05 00:18:10 +00:00
2016-02-29 15:59:36 +00:00
$ticket->is_paused = ($ticket->is_paused == 1) ? 0 : 1;
2016-03-05 00:18:10 +00:00
2016-02-29 15:59:36 +00:00
if ($ticket->save()) {
return response()->json([
2016-06-15 02:31:24 +00:00
'status' => 'success',
(localization) Several big changes: 1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login 2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers. 3) Edited routes to accomodate point 1 4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used. 5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings). There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense: 1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites. 2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients. 3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code. 4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here. 5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases. and other. There are also some inconveniences, like: 1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys). 2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up. 3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages. 4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable. 5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
'message' => trans("Controllers.ticket_successfully_updated"),
2016-06-15 02:31:24 +00:00
'id' => $ticket->id,
2016-02-29 15:59:36 +00:00
]);
}
Log::error('Ticket Failed to pause/resume', [
2016-03-05 00:18:10 +00:00
'ticket' => $ticket,
2016-02-29 15:59:36 +00:00
]);
return response()->json([
2016-06-15 02:31:24 +00:00
'status' => 'error',
'id' => $ticket->id,
(localization) Several big changes: 1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login 2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers. 3) Edited routes to accomodate point 1 4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used. 5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings). There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense: 1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites. 2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients. 3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code. 4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here. 5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases. and other. There are also some inconveniences, like: 1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys). 2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up. 3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages. 4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable. 5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
'message' => trans("Controllers.whoops"),
2016-02-29 15:59:36 +00:00
]);
}
/**
* Deleted a ticket
*
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function postDeleteTicket(Request $request)
2016-03-05 00:18:10 +00:00
{
$ticket_id = $request->get('ticket_id');
2016-02-29 15:59:36 +00:00
$ticket = Ticket::scope()->find($ticket_id);
/*
* Don't allow deletion of tickets which have been sold already.
*/
2016-02-29 15:59:36 +00:00
if ($ticket->quantity_sold > 0) {
return response()->json([
2016-06-15 02:31:24 +00:00
'status' => 'error',
(localization) Several big changes: 1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login 2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers. 3) Edited routes to accomodate point 1 4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used. 5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings). There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense: 1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites. 2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients. 3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code. 4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here. 5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases. and other. There are also some inconveniences, like: 1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys). 2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up. 3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages. 4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable. 5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
'message' => trans("Controllers.cant_delete_ticket_when_sold"),
2016-06-15 02:31:24 +00:00
'id' => $ticket->id,
2016-02-29 15:59:36 +00:00
]);
}
if ($ticket->delete()) {
return response()->json([
2016-06-15 02:31:24 +00:00
'status' => 'success',
(localization) Several big changes: 1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login 2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers. 3) Edited routes to accomodate point 1 4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used. 5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings). There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense: 1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites. 2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients. 3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code. 4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here. 5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases. and other. There are also some inconveniences, like: 1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys). 2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up. 3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages. 4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable. 5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
'message' => trans("Controllers.ticket_successfully_deleted"),
2016-06-15 02:31:24 +00:00
'id' => $ticket->id,
2016-02-29 15:59:36 +00:00
]);
}
Log::error('Ticket Failed to delete', [
2016-03-05 00:18:10 +00:00
'ticket' => $ticket,
2016-02-29 15:59:36 +00:00
]);
return response()->json([
2016-06-15 02:31:24 +00:00
'status' => 'error',
'id' => $ticket->id,
(localization) Several big changes: 1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login 2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers. 3) Edited routes to accomodate point 1 4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used. 5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings). There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense: 1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites. 2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients. 3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code. 4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here. 5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases. and other. There are also some inconveniences, like: 1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys). 2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up. 3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages. 4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable. 5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
'message' => trans("Controllers.whoops"),
2016-02-29 15:59:36 +00:00
]);
}
/**
* Edit a ticket
*
* @param Request $request
* @param $event_id
* @param $ticket_id
* @return \Illuminate\Http\JsonResponse
*/
public function postEditTicket(Request $request, $event_id, $ticket_id)
2016-03-05 00:18:10 +00:00
{
$ticket = Ticket::scope()->findOrFail($ticket_id);
2016-02-29 15:59:36 +00:00
/*
* Override some validation rules
2016-02-29 15:59:36 +00:00
*/
2016-09-06 20:39:27 +00:00
$validation_rules['quantity_available'] = [
'integer',
'min:' . ($ticket->quantity_sold + $ticket->quantity_reserved)
];
(localization) Several big changes: 1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login 2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers. 3) Edited routes to accomodate point 1 4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used. 5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings). There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense: 1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites. 2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients. 3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code. 4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here. 5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases. and other. There are also some inconveniences, like: 1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys). 2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up. 3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages. 4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable. 5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
$validation_messages['quantity_available.min'] = trans("Controllers.quantity_min_error");
2016-03-05 00:18:10 +00:00
2016-02-29 15:59:36 +00:00
$ticket->rules = $validation_rules + $ticket->rules;
$ticket->messages = $validation_messages + $ticket->messages;
if (!$ticket->validate($request->all())) {
return response()->json([
2016-06-15 02:31:24 +00:00
'status' => 'error',
'messages' => $ticket->errors(),
2016-03-05 00:18:10 +00:00
]);
2016-02-29 15:59:36 +00:00
}
2016-09-06 20:39:27 +00:00
$ticket->title = $request->get('title');
$ticket->quantity_available = !$request->get('quantity_available') ? null : $request->get('quantity_available');
2016-09-06 20:39:27 +00:00
$ticket->price = $request->get('price');
$ticket->start_sale_date = $request->get('start_sale_date') ? Carbon::createFromFormat('d-m-Y H:i',
$request->get('start_sale_date')) : null;
$ticket->end_sale_date = $request->get('end_sale_date') ? Carbon::createFromFormat('d-m-Y H:i',
$request->get('end_sale_date')) : null;
$ticket->description = $request->get('description');
$ticket->min_per_person = $request->get('min_per_person');
$ticket->max_per_person = $request->get('max_per_person');
$ticket->is_hidden = $request->get('is_hidden') ? 1 : 0;
2016-02-29 15:59:36 +00:00
$ticket->save();
return response()->json([
2016-06-15 02:31:24 +00:00
'status' => 'success',
'id' => $ticket->id,
(localization) Several big changes: 1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login 2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers. 3) Edited routes to accomodate point 1 4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used. 5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings). There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense: 1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites. 2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients. 3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code. 4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here. 5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases. and other. There are also some inconveniences, like: 1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys). 2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up. 3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages. 4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable. 5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
'message' => trans("Controllers.refreshing"),
2016-06-15 02:31:24 +00:00
'redirectUrl' => route('showEventTickets', [
'event_id' => $event_id,
]),
2016-03-05 00:18:10 +00:00
]);
2016-02-29 15:59:36 +00:00
}
/**
* Updates the sort order of tickets
*
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function postUpdateTicketsOrder(Request $request)
{
$ticket_ids = $request->get('ticket_ids');
$sort = 1;
foreach ($ticket_ids as $ticket_id) {
$ticket = Ticket::scope()->find($ticket_id);
$ticket->sort_order = $sort;
$ticket->save();
$sort++;
}
return response()->json([
'status' => 'success',
(localization) Several big changes: 1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login 2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers. 3) Edited routes to accomodate point 1 4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used. 5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings). There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense: 1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites. 2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients. 3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code. 4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here. 5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases. and other. There are also some inconveniences, like: 1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys). 2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up. 3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages. 4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable. 5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
'message' => trans("Controllers.ticket_order_successfully_updated"),
]);
}
2016-02-29 15:59:36 +00:00
}