- First commit
This commit is contained in:
commit
a3320dd598
|
|
@ -0,0 +1,24 @@
|
|||
APP_ENV=production
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://dev.attendize.com
|
||||
APP_CIPHER=rijndael-128
|
||||
APP_KEY=SomeRandomString
|
||||
APP_TIMEZONE
|
||||
|
||||
DB_TYPE=mysql
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=attendize
|
||||
DB_USERNAME
|
||||
DB_PASSWORD
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_PORT=587
|
||||
MAIL_ENCRYPTION=tls
|
||||
MAIL_HOST=smtp.mandrillapp.com
|
||||
MAIL_FROM_ADDRESS=info@attendize.com
|
||||
MAIL_FROM_NAME=Attendize.com
|
||||
MAIL_PASSWORD=b038a015-8162-4a7a-bb8b-abb63fa7c112
|
||||
MAIL_USERNAME=dave.m.earley@gmail.com
|
||||
|
||||
|
||||
LOG=single
|
||||
|
|
@ -0,0 +1 @@
|
|||
* text=auto
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
/public/vendor
|
||||
/vendor
|
||||
/node_modules
|
||||
.env
|
||||
.idea
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
module.exports = function(grunt) {
|
||||
|
||||
//Initializing the configuration object
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
// Task configuration
|
||||
less: {
|
||||
development: {
|
||||
options: {
|
||||
compress: true, //minifying the result
|
||||
},
|
||||
files: {
|
||||
//compiling frontend.less into frontend.css
|
||||
"./public/assets/stylesheet/application.css":"./public/assets/stylesheet/application.less",
|
||||
"./public/assets/stylesheet/frontend.css":"./public/assets/stylesheet/frontend.less",
|
||||
//compiling backend.less into backend.css
|
||||
//"./public/assets/stylesheets/backend.css":"./app/assets/stylesheets/backend.less"
|
||||
}
|
||||
},
|
||||
website: {
|
||||
options: {
|
||||
compress: true, //minifying the result
|
||||
},
|
||||
files: {
|
||||
"./public/website_assets/stylesheet/main.css":"./public/website_assets/stylesheet/main.less",
|
||||
}
|
||||
}
|
||||
},
|
||||
concat: {
|
||||
options: {
|
||||
separator: ';',
|
||||
stripBanners: true,
|
||||
|
||||
},
|
||||
js_frontend: {
|
||||
src: [
|
||||
'./public/vendor/jquery/jquery.js',
|
||||
'./public/vendor/bootstrap/dist/js/bootstrap.js',
|
||||
'./public/vendor/jquery-form/jquery.form.js',
|
||||
'./public/vendor/RRSSB/js/rrssb.js',
|
||||
'./public/vendor/humane-js/humane.js',
|
||||
'./public/vendor/jquery-backstretch/jquery.backstretch.js',
|
||||
'./public/assets/javascript/app-public.js'
|
||||
],
|
||||
dest: './public/assets/javascript/frontend.js',
|
||||
},
|
||||
js_backend: {
|
||||
src: [
|
||||
'./public/vendor/modernizr/modernizr.js',
|
||||
'./public/vendor/bootstrap/dist/js/bootstrap.js',
|
||||
'./public/vendor/jquery-form/jquery.form.js',
|
||||
'./public/vendor/humane-js/humane.js',
|
||||
'./public/vendor/RRSSB/js/rrssb.js',
|
||||
'./public/vendor/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.js',
|
||||
'./public/vendor/curioussolutions-datetimepicker/dist/DateTimePicker.js',
|
||||
'./public/assets/javascript/app.js'
|
||||
],
|
||||
dest: './public/assets/javascript/backend.js',
|
||||
},
|
||||
},
|
||||
uglify: {
|
||||
options: {
|
||||
mangle: true, // Use if you want the names of your functions and variables unchanged
|
||||
preserveComments: false,
|
||||
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
|
||||
'<%= grunt.template.today("yyyy-mm-dd") %> */',
|
||||
|
||||
},
|
||||
frontend: {
|
||||
files: {
|
||||
'./public/assets/javascript/frontend.js': './public/assets/javascript/frontend.js',
|
||||
}
|
||||
},
|
||||
backend: {
|
||||
files: {
|
||||
'./public/assets/javascript/backend.js': './public/assets/javascript/backend.js',
|
||||
}
|
||||
},
|
||||
},
|
||||
phpunit: {
|
||||
classes: {
|
||||
},
|
||||
options: {
|
||||
}
|
||||
},
|
||||
// watch: {
|
||||
// js_frontend: {
|
||||
// files: [
|
||||
// //watched files
|
||||
// './bower_components/jquery/jquery.js',
|
||||
// './bower_components/bootstrap/dist/js/bootstrap.js',
|
||||
// './app/assets/javascript/frontend.js'
|
||||
// ],
|
||||
// tasks: ['concat:js_frontend','uglify:frontend'], //tasks to run
|
||||
// options: {
|
||||
// livereload: true //reloads the browser
|
||||
// }
|
||||
// },
|
||||
// js_backend: {
|
||||
// files: [
|
||||
// //watched files
|
||||
// './bower_components/jquery/jquery.js',
|
||||
// './bower_components/bootstrap/dist/js/bootstrap.js',
|
||||
// './app/assets/javascript/backend.js'
|
||||
// ],
|
||||
// tasks: ['concat:js_backend','uglify:backend'], //tasks to run
|
||||
// options: {
|
||||
// livereload: true //reloads the browser
|
||||
// }
|
||||
// },
|
||||
// less: {
|
||||
// files: ['./app/assets/stylesheets/*.less'], //watched files
|
||||
// tasks: ['less'], //tasks to run
|
||||
// options: {
|
||||
// livereload: true //reloads the browser
|
||||
// }
|
||||
// },
|
||||
// tests: {
|
||||
// files: ['app/controllers/*.php','app/models/*.php'], //the task will run only when you save files in this location
|
||||
// tasks: ['phpunit']
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
// Plugin loading
|
||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
//grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-contrib-less');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
//grunt.loadNpmTasks('grunt-phpunit');
|
||||
|
||||
// Task definition
|
||||
//grunt.registerTask('default', ['watch']);
|
||||
grunt.registerTask('default', ['less', 'concat']);
|
||||
grunt.registerTask('deploy', ['less', 'concat', 'uglify']);
|
||||
grunt.registerTask('js', ['concat']);
|
||||
grunt.registerTask('styles', ['concat']);
|
||||
grunt.registerTask('minify', ['uglify']);
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
Attribution Assurance License
|
||||
Copyright (c) 2016 by Dave Earley (dave@attendize.com)
|
||||
http://www.attendize.com
|
||||
|
||||
All Rights Reserved
|
||||
ATTRIBUTION ASSURANCE LICENSE (adapted from the original BSD license)
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the conditions below are met.
|
||||
These conditions require a modest attribution to Attendize.com. The hope
|
||||
is that its promotional value may help justify the thousands of dollars in
|
||||
otherwise billable time invested in writing this and other freely available,
|
||||
open-source software.
|
||||
|
||||
1. Redistributions of source code, in whole or part and with or without
|
||||
modification requires the express permission of the author and must prominently
|
||||
display "Powered by Attendize" or the Attendize logo in verifiable form
|
||||
with hyperlink to said site.
|
||||
2. Neither the name nor any trademark of the Author may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
3. Users are entirely responsible, to the exclusion of the Author and
|
||||
any other persons, for compliance with (1) regulations set by owners or
|
||||
administrators of employed equipment, (2) licensing terms of any other
|
||||
software, and (3) local regulations regarding use, including those
|
||||
regarding import, export, and use of encryption software.
|
||||
|
||||
THIS FREE SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE AUTHOR OR ANY CONTRIBUTOR BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
EFFECTS OF UNAUTHORIZED OR MALICIOUS NETWORK ACCESS;
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<?php namespace App\Attendize;
|
||||
|
||||
|
||||
class Utils
|
||||
{
|
||||
|
||||
public static function isRegistered()
|
||||
{
|
||||
return Auth::check() && Auth::user()->is_registered;
|
||||
}
|
||||
|
||||
public static function isConfirmed()
|
||||
{
|
||||
return Auth::check() && Auth::user()->is_confirmed;
|
||||
}
|
||||
|
||||
public static function isDatabaseSetup()
|
||||
{
|
||||
try {
|
||||
if (Schema::hasTable('accounts')) {
|
||||
return true;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Are we the cloud version of attendize or in dev enviornment?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isAttendize() {
|
||||
return self::isAttendizeCloud() || self::isAttendizeDev();
|
||||
}
|
||||
|
||||
/**
|
||||
* Are we the cloud version of Attendize?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isAttendizeCloud()
|
||||
{
|
||||
return isset($_ENV['ATTENDIZE_CLOUD']) && $_ENV['ATTENDIZE_CLOUD'] == 'true';
|
||||
}
|
||||
|
||||
/**
|
||||
* Are we in a dev enviornment?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isAttendizeDev()
|
||||
{
|
||||
return isset($_ENV['ATTENDIZE_DEV']) && $_ENV['ATTENDIZE_DEV'] == 'true';
|
||||
}
|
||||
|
||||
public static function isDownForMaintenance()
|
||||
{
|
||||
return file_exists(storage_path() . '/framework/down');
|
||||
}
|
||||
|
||||
public static function isProd()
|
||||
{
|
||||
return App::environment() == ENV_PRODUCTION;
|
||||
}
|
||||
|
||||
public static function file_upload_max_size() {
|
||||
static $max_size = -1;
|
||||
|
||||
if ($max_size < 0) {
|
||||
// Start with post_max_size.
|
||||
$max_size = self::parse_size(ini_get('post_max_size'));
|
||||
|
||||
// If upload_max_size is less, then reduce. Except if upload_max_size is
|
||||
// zero, which indicates no limit.
|
||||
$upload_max = self::parse_size(ini_get('upload_max_filesize'));
|
||||
if ($upload_max > 0 && $upload_max < $max_size) {
|
||||
$max_size = $upload_max;
|
||||
}
|
||||
}
|
||||
return $max_size;
|
||||
}
|
||||
|
||||
public static function parse_size($size) {
|
||||
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
|
||||
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
|
||||
if ($unit) {
|
||||
// Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
|
||||
return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
|
||||
}
|
||||
else {
|
||||
return round($size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
define('OUTGOING_EMAIL_NOREPLY', env('MAIL_FROM_ADDRESS'));
|
||||
define('OUTGOING_EMAIL', env('MAIL_FROM_ADDRESS'));
|
||||
define('OUTGOING_EMAIL_NAME', 'Attendize Event Ticketing');
|
||||
define('INCOMING_EMAIL', env('MAIL_FROM_ADDRESS'));
|
||||
|
||||
define('APP_URL', env('APP_URL'));
|
||||
define('APP_NAME', 'Attendize Event Ticketing');
|
||||
|
||||
define('EVENT_DEFAULT_BG_COLOR', '#B23333');
|
||||
|
||||
/* paths */
|
||||
define('EVENT_IMAGES_PATH', 'user_content/event_images/'.date('my'));
|
||||
define('ORGANISER_IMAGES_PATH', 'user_content/organiser_images/'.date('my'));
|
||||
define('EVENT_PDF_TICKETS_PATH', 'user_content/pdf_tickets/'.date('my'));
|
||||
define('EVENT_BG_IMAGES', 'assets/images/public/EventPage/backgrounds');
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
define('FALLBACK_ORGANISER_LOGO_URL', '/assets/images/logo-100x100-lightBg.png');
|
||||
define('CDN_URL', '');
|
||||
|
||||
define('MAX_TICKETS_PER_PERSON', 50);
|
||||
|
||||
/* Time in minutes which a user can reserve tickets */
|
||||
define('CHECKOUT_TIMEOUT_AFTER', 8);
|
||||
|
||||
define('TICKET_STATUS_SOLD_OUT', 1);
|
||||
define('TICKET_STATUS_AFTER_SALE_DATE', 2);
|
||||
define('TICKET_STATUS_BEFORE_SALE_DATE', 3);
|
||||
define('TICKET_STATUS_ON_SALE', 4);
|
||||
define('TICKET_STATUS_OFF_SALE', 5);
|
||||
|
||||
/* The fee which we charge users for buying tikets. Fixed fee + % of ticket sale. */
|
||||
define('TICKET_BOOKING_FEE_FIXED', .0);
|
||||
define('TICKET_BOOKING_FEE_PERCENTAGE', .0);
|
||||
|
||||
|
||||
define('ORDER_COMPLETE', 1);
|
||||
define('ORDER_REFUNDED', 2);
|
||||
define('ORDER_PARTIALLY_REFUNDED', 3);
|
||||
define('ORDER_CANCELLED', 4);
|
||||
|
||||
define('DEFAULT_TIMEZONE', 30); // Europe/Dublin
|
||||
define('DEFAULT_CURRENCY', 2); // Euro
|
||||
define('DEFAULT_DATE_FORMAT', 'j M, Y');
|
||||
define('DEFAULT_DATE_PICKER_FORMAT', 'd M, yyyy');
|
||||
define('DEFAULT_DATETIME_FORMAT', 'F j, Y, g:i a');
|
||||
define('DEFAULT_QUERY_CACHE', 120); // minutes
|
||||
define('DEFAULT_LOCALE', 'en');
|
||||
|
||||
|
||||
define('CDN_URL_USER_ASSETS', '');
|
||||
define('CDN_URL_STATIC_ASSETS', '');
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
<?php namespace App\Attendize\handlers;
|
||||
|
||||
use App\Attendize\mailers\OrderMailer;
|
||||
use Order;
|
||||
use Attendee;
|
||||
//use PDF;
|
||||
|
||||
class QueueHandler {
|
||||
|
||||
protected $orderMailer;
|
||||
|
||||
public function __construct(OrderMailer $orderMailer) {
|
||||
$this->orderMailer = $orderMailer;
|
||||
}
|
||||
|
||||
|
||||
public function handleOrder($job, $data) {
|
||||
echo "Starting Job {$job->getJobId()}\n";
|
||||
|
||||
$order = Order::findOrfail($data['order_id']);
|
||||
|
||||
/*
|
||||
* Steps :
|
||||
* 1 Notify event organiser
|
||||
* 2 Order Confirmation email to buyer
|
||||
* 3 Generate / Send Tickets
|
||||
*/
|
||||
|
||||
$data = [
|
||||
'order' => $order,
|
||||
'event' => $order->event,
|
||||
'tickets' => $order->event->tickets,
|
||||
'attendees' => $order->attendees
|
||||
];
|
||||
|
||||
$pdf_file = storage_path().'/'.$order->order_reference;
|
||||
exit($pdf_file);
|
||||
|
||||
|
||||
PDF::setOutputMode('F'); // force to file
|
||||
PDF::html('Public.ViewEvent.Partials.PDFTicket', $data, $pdf_file);
|
||||
|
||||
|
||||
//1
|
||||
$this->orderMailer->sendOrderNotification($order);
|
||||
//2
|
||||
$this->orderMailer->sendOrderConfirmation($order);
|
||||
//3
|
||||
|
||||
$this->orderMailer->sendTickets($order);
|
||||
|
||||
$job->delete();
|
||||
}
|
||||
|
||||
public function messageAttendees($job, $data) {
|
||||
|
||||
echo "Starting Job {$job->getJobId()}\n";
|
||||
|
||||
$message_object = Message::find($data['message_id']);
|
||||
$event = $message_object->event;
|
||||
|
||||
$attendees = ($message_object->recipients == 0) ? $event->attendees : Attendee::where('ticket_id', '=', $message_object->recipients)->where('account_id', '=', $message_object->account_id)->get();
|
||||
|
||||
$toFields = [];
|
||||
foreach ($attendees as $attendee) {
|
||||
$toFields[$attendee->email] = $attendee->full_name;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'event' => $event,
|
||||
'message_content' => $message_object->message,
|
||||
'subject' => $message_object->subject
|
||||
];
|
||||
|
||||
Mail::send('Emails.messageAttendees', $data, function($message) use ($toFields, $event, $message_object) {
|
||||
$message->to($toFields)
|
||||
->from(OUTGOING_EMAIL_NOREPLY, $event->organiser->name)
|
||||
->replyTo($event->organiser->email, $event->organiser->name)
|
||||
->subject($message_object->subject);
|
||||
});
|
||||
|
||||
|
||||
|
||||
$message_object->is_sent = 1;
|
||||
$message_object->save();
|
||||
//$message->sent
|
||||
|
||||
$job->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Attendize\mailers;
|
||||
|
||||
use Mail;
|
||||
use App\Models\Attendee;
|
||||
use App\Models\Message;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class AttendeeMailer extends Mailer {
|
||||
|
||||
public function sendMessageToAttendees(Message $message_object) {
|
||||
|
||||
$event = $message_object->event;
|
||||
|
||||
$attendees = ($message_object->recipients == 0)
|
||||
? $event->attendees // all attendees
|
||||
: Attendee::where('ticket_id', '=', $message_object->recipients)->where('account_id', '=', $message_object->account_id)->get();
|
||||
|
||||
$toFields = [];
|
||||
foreach ($attendees as $attendee) {
|
||||
$toFields[$attendee->email] = $attendee->full_name;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'event' => $event,
|
||||
'message_content' => $message_object->message,
|
||||
'subject' => $message_object->subject
|
||||
];
|
||||
|
||||
/*
|
||||
* Mandril lets us send the email to multiple people at once.
|
||||
*/
|
||||
Mail::send('Emails.messageAttendees', $data, function($message) use ($toFields, $event, $message_object) {
|
||||
$message->to($toFields)
|
||||
->from(OUTGOING_EMAIL_NOREPLY, $event->organiser->name)
|
||||
->replyTo($event->organiser->email, $event->organiser->name)
|
||||
->subject($message_object->subject);
|
||||
});
|
||||
|
||||
|
||||
|
||||
$message_object->is_sent = 1;
|
||||
$message_object->sent_at = Carbon::now();
|
||||
$message_object->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php namespace App\Attendize\mailers;
|
||||
|
||||
use Mail;
|
||||
|
||||
class Mailer
|
||||
{
|
||||
|
||||
public function sendTo($toEmail, $fromEmail, $fromName, $subject, $view, $data = [], $attachment = FALSE)
|
||||
{
|
||||
Mail::send($view, $data, function ($message) use ($toEmail, $fromEmail, $fromName, $subject, $attachment) {
|
||||
$replyEmail = $fromEmail;
|
||||
$fromEmail = OUTGOING_EMAIL;
|
||||
|
||||
if ($attachment) {
|
||||
$message->attach($attachment);
|
||||
}
|
||||
|
||||
$message
|
||||
->to($toEmail)
|
||||
->from($fromEmail, $fromName)
|
||||
->replyTo($replyEmail, $fromName)
|
||||
->subject($subject);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php namespace App\Attendize\mailers;
|
||||
|
||||
use App\Models\Order;
|
||||
|
||||
class OrderMailer extends Mailer {
|
||||
|
||||
|
||||
public function sendOrderNotification(Order $order) {
|
||||
$this->sendTo($order->account->email, OUTGOING_EMAIL, OUTGOING_EMAIL_NAME, 'New order received on the event '. $order->event->title .' ['. $order->order_reference .']', 'Emails.OrderNotification', [
|
||||
'order' => $order
|
||||
]);
|
||||
}
|
||||
|
||||
public function sendOrderConfirmation(Order $order) {
|
||||
|
||||
$ticket_pdf = public_path($order->ticket_pdf_path);
|
||||
|
||||
if(!file_exists($ticket_pdf)){
|
||||
$ticket_pdf = FALSE;
|
||||
}
|
||||
|
||||
$this->sendTo($order->email, OUTGOING_EMAIL, $order->event->organiser->name, 'Your tickets & order confirmation for the event '. $order->event->title .' ['. $order->order_reference .']', 'Emails.OrderConfirmation', [
|
||||
'order' => $order,
|
||||
'email_logo' => $order->event->organiser->full_logo_path
|
||||
], $ticket_pdf);
|
||||
}
|
||||
|
||||
public function sendTickets(Order $order) {
|
||||
// $this->sendTo($order->account->email, OUTGOING_EMAIL, OUTGOING_EMAIL_NAME, 'New order received on the event '. $order->event->title .' ['. $order->order_reference .']', 'Emails.OrderNotification', [
|
||||
// 'order' => $order
|
||||
// ]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of UserMailer
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class UserMailer {
|
||||
//put your code here
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php namespace App\Commands;
|
||||
|
||||
abstract class Command {
|
||||
|
||||
//
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use Log;
|
||||
use App\Commands\Command;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldBeQueued;
|
||||
use App\Attendize\mailers\AttendeeMailer;
|
||||
use Illuminate\Contracts\Bus\SelfHandling;
|
||||
|
||||
class MessageAttendeesCommand extends Command implements ShouldBeQueued, SelfHandling {
|
||||
|
||||
use InteractsWithQueue,
|
||||
SerializesModels;
|
||||
|
||||
public $attendeeMessage;
|
||||
|
||||
|
||||
public function __construct(\App\Models\Message $attendeeMessage) {
|
||||
$this->attendeeMessage = $attendeeMessage;
|
||||
}
|
||||
|
||||
function handle(AttendeeMailer $mailer) {
|
||||
Log::info(date('d m y H:i') . " - Starting Job {$this->job->getJobId()} ".__CLASS__);
|
||||
|
||||
$mailer->sendMessageToAttendees($this->attendeeMessage);
|
||||
|
||||
Log::info( date('d m y H:i') . " - Finished Job {$this->job->getJobId()} ".__CLASS__);
|
||||
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use Log;
|
||||
use App\Commands\Command;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldBeQueued;
|
||||
use App\Attendize\mailers\OrderMailer;
|
||||
use Illuminate\Contracts\Bus\SelfHandling;
|
||||
|
||||
class OrderTicketsCommand extends Command implements ShouldBeQueued, SelfHandling {
|
||||
|
||||
use InteractsWithQueue,
|
||||
SerializesModels;
|
||||
|
||||
public $ticketOrder, $sendOrderConfirmation;
|
||||
private $outSeperator = "\n ---------------------- \n";
|
||||
|
||||
/**
|
||||
* OrderTicketsCommand constructor.
|
||||
* @param \App\Models\Order $ticketOrder
|
||||
* @param bool|TRUE $sendOrderConfirmation
|
||||
*/
|
||||
public function __construct(\App\Models\Order $ticketOrder, $sendOrderConfirmation = TRUE) {
|
||||
$this->ticketOrder = $ticketOrder;
|
||||
$this->sendOrderConfirmation = $sendOrderConfirmation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderMailer $mailer
|
||||
*/
|
||||
function handle(OrderMailer $mailer) {
|
||||
|
||||
Log::info(date('d m y H:i') . " - Starting Job {$this->job->getJobId()} ".__CLASS__);
|
||||
|
||||
//1 - Notify event organiser
|
||||
if($this->sendOrderConfirmation) {
|
||||
$mailer->sendOrderNotification($this->ticketOrder);
|
||||
}
|
||||
|
||||
//2 - Generate PDF Tickets
|
||||
$this->ticketOrder->generatePdfTickets();
|
||||
|
||||
//3 - Send Tickets / Order confirmation
|
||||
$mailer->sendOrderConfirmation($this->ticketOrder);
|
||||
|
||||
Log::info(date('d m y H:i') . " - Finished Job {$this->job->getJobId()} ".__CLASS__);
|
||||
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class Inspire extends Command {
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'inspire';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inspiring quote';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel {
|
||||
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
'App\Console\Commands\Inspire',
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('inspire')
|
||||
->hourly();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php namespace App\Events;
|
||||
|
||||
abstract class Event {
|
||||
|
||||
//
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception, Request;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
//use Bugsnag\BugsnagLaravel\BugsnagExceptionHandler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler {
|
||||
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
'Symfony\Component\HttpKernel\Exception\HttpException'
|
||||
];
|
||||
|
||||
/**
|
||||
*
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $e) {
|
||||
return parent::report($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e) {
|
||||
if ($this->isHttpException($e)) {
|
||||
return $this->renderHttpException($e);
|
||||
}
|
||||
|
||||
|
||||
if (config('app.debug')) {
|
||||
return $this->renderExceptionWithWhoops($e);
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception using Whoops.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
protected function renderExceptionWithWhoops(Exception $e) {
|
||||
$whoops = new \Whoops\Run;
|
||||
|
||||
if(Request::ajax()) {
|
||||
$whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler);
|
||||
} else {
|
||||
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
|
||||
}
|
||||
|
||||
return new \Illuminate\Http\Response(
|
||||
$whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $amount
|
||||
* @param string $currency_code
|
||||
* @param int $decimals
|
||||
* @param string $dec_point
|
||||
* @param string $thousands_sep
|
||||
* @return decimal
|
||||
*/
|
||||
function money($amount, $currency_code='', $decimals = 2 ,$dec_point = "." , $thousands_sep = "," ) {
|
||||
|
||||
switch($currency_code) {
|
||||
case 'USD' :
|
||||
case 'AUD' :
|
||||
case 'CAD' :
|
||||
$currency_symbol = '$';
|
||||
break;
|
||||
case 'EUR' :
|
||||
$currency_symbol = '€';
|
||||
break;
|
||||
case 'GBP' :
|
||||
$currency_symbol = '£';
|
||||
break;
|
||||
|
||||
default :
|
||||
$currency_symbol = '';
|
||||
break;
|
||||
}
|
||||
|
||||
return $currency_symbol.number_format($amount, $decimals, $dec_point, $thousands_sep);
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
|
||||
Validator::extend('passcheck', function ($attribute, $value, $parameters)
|
||||
{
|
||||
return \Hash::check($value, \Auth::user()->getAuthPassword());
|
||||
});
|
||||
|
||||
/*
|
||||
* Some macros and blade extensions
|
||||
*/
|
||||
|
||||
Form::macro('rawLabel', function($name, $value = null, $options = array()) {
|
||||
$label = Form::label($name, '%s', $options);
|
||||
|
||||
return sprintf($label, $value);
|
||||
});
|
||||
|
||||
Form::macro('labelWithHelp', function($name, $value = null, $options = array(), $help_text) {
|
||||
$label = Form::label($name, '%s', $options);
|
||||
|
||||
return sprintf($label, $value)
|
||||
.'<a style="margin-left: 4px;font-size: 11px;" href="javascript:showHelp('."'".$help_text."'".');" >'
|
||||
. '<i class="ico ico-question "></i>'
|
||||
. '</a>';
|
||||
});
|
||||
|
||||
|
||||
Form::macro('customCheckbox', function($name, $value, $checked=FALSE, $label = FALSE, $options= []) {
|
||||
|
||||
// $checkbox = Form::checkbox($name, $value = null, $checked, $options);
|
||||
// $label = Form::rawLabel();
|
||||
//
|
||||
// $out = '<div class="checkbox custom-checkbox">
|
||||
// <input type="checkbox" name="send_copy" id="send_copy" value="1">
|
||||
// <label for="send_copy"> Send a copy to <b>{{$attendee->event->organiser->email}}</b></label>
|
||||
// </div>';
|
||||
//
|
||||
// return $out;
|
||||
});
|
||||
|
||||
Form::macro('styledFile', function($name, $multiple = FALSE) {
|
||||
$out = '<div class="styledFile" id="input-'.$name.'">
|
||||
<div class="input-group">
|
||||
<span class="input-group-btn">
|
||||
<span class="btn btn-primary btn-file">
|
||||
Browse… <input name="'.$name.'" type="file" '.($multiple ? 'multiple' : '').'>
|
||||
</span>
|
||||
</span>
|
||||
<input type="text" class="form-control" readonly>
|
||||
<span style="display: none;" class="input-group-btn btn-upload-file">
|
||||
<span class="btn btn-success ">
|
||||
Upload
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
return $out;
|
||||
});
|
||||
|
||||
HTML::macro('sortable_link', function($title, $active_sort, $sort_by, $sort_order, $url_params = [], $class = '', $extra = '') {
|
||||
|
||||
$sort_order = $sort_order == 'asc' ? 'desc' : 'asc';
|
||||
|
||||
$url_params = http_build_query([
|
||||
'sort_by' => $sort_by,
|
||||
'sort_order' => $sort_order
|
||||
] + $url_params);
|
||||
|
||||
$html = "<a href='?$url_params' class='col-sort $class' $extra>";
|
||||
|
||||
$html .= ($active_sort == $sort_by) ? "<b>$title</b>" : $title;
|
||||
|
||||
$html .= ($sort_order == 'desc') ? '<i class="ico-arrow-down22"></i>' : '<i class="ico-arrow-up22"></i>';
|
||||
|
||||
$html .= '</a>';
|
||||
|
||||
return $html;
|
||||
});
|
||||
|
||||
|
||||
|
||||
Blade::directive('money', function($expression) {
|
||||
return "<?php echo number_format($expression, 2); ?>";
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\Registrar;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
|
||||
class AuthController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Registration & Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users, as well as the
|
||||
| authentication of existing users. By default, this controller uses
|
||||
| a simple trait to add these behaviors. Why don't you explore it?
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesAndRegistersUsers;
|
||||
|
||||
/**
|
||||
* Create a new authentication controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\Registrar $registrar
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, Registrar $registrar)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->registrar = $registrar;
|
||||
|
||||
$this->middleware('guest', ['except' => 'getLogout']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class PasswordController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Create a new password controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->passwords = $passwords;
|
||||
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesCommands;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
|
||||
abstract class Controller extends BaseController {
|
||||
|
||||
use DispatchesCommands, ValidatesRequests;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,452 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Input,
|
||||
DB,
|
||||
Auth,
|
||||
Mail,
|
||||
Response,
|
||||
View,
|
||||
Excel,
|
||||
Session,
|
||||
Validator;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventStats;
|
||||
use App\Models\Order;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\Attendee;
|
||||
use App\Models\OrderItem;
|
||||
use App\Models\Message;
|
||||
use App\Commands\MessageAttendeesCommand;
|
||||
use App\Commands\OrderTicketsCommand;
|
||||
|
||||
class EventAttendeesController extends MyBaseController {
|
||||
|
||||
public function showAttendees($event_id) {
|
||||
|
||||
$allowed_sorts = ['first_name', 'email', 'ticket_id', 'order_reference'];
|
||||
|
||||
$searchQuery = Input::get('q');
|
||||
$sort_order = Input::get('sort_order') == 'asc' ? 'asc' : 'desc';
|
||||
$sort_by = (in_array(Input::get('sort_by'), $allowed_sorts) ? Input::get('sort_by') : 'created_at');
|
||||
|
||||
|
||||
|
||||
$event = Event::scope()->find($event_id);
|
||||
//$event = Event::scope()->join('orders', 'orders.event_id', '=', 'attendees.id')->find($event_id);
|
||||
|
||||
if ($searchQuery) {
|
||||
|
||||
$attendees = $event->attendees()
|
||||
->withoutCancelled()
|
||||
->join('orders', 'orders.id', '=', 'attendees.order_id')
|
||||
->where(function($query) use ($searchQuery) {
|
||||
$query->where('orders.order_reference', 'like', $searchQuery . '%')
|
||||
->orWhere('attendees.first_name', 'like', $searchQuery . '%')
|
||||
->orWhere('attendees.email', 'like', $searchQuery . '%')
|
||||
->orWhere('attendees.last_name', 'like', $searchQuery . '%');
|
||||
})
|
||||
->orderBy(($sort_by == 'order_reference' ? 'orders.' : 'attendees.') . $sort_by, $sort_order)
|
||||
->select('attendees.*', 'orders.order_reference')
|
||||
->paginate();
|
||||
} else {
|
||||
$attendees = $event->attendees()
|
||||
->join('orders', 'orders.id', '=', 'attendees.order_id')
|
||||
->withoutCancelled()
|
||||
->orderBy(($sort_by == 'order_reference' ? 'orders.' : 'attendees.') . $sort_by, $sort_order)
|
||||
->select('attendees.*', 'orders.order_reference')
|
||||
->paginate();
|
||||
}
|
||||
|
||||
$data = [
|
||||
'attendees' => $attendees,
|
||||
'event' => $event,
|
||||
'sort_by' => $sort_by,
|
||||
'sort_order' => $sort_order,
|
||||
'q' => $searchQuery ? $searchQuery : ''
|
||||
];
|
||||
|
||||
|
||||
|
||||
return View::make('ManageEvent.Attendees', $data);
|
||||
}
|
||||
|
||||
public function showCreateAttendee($event_id) {
|
||||
|
||||
$event = Event::scope()->find($event_id);
|
||||
|
||||
/*
|
||||
* If there are no tickets then we can't create an attendee
|
||||
* @todo This is a bit hackish
|
||||
*/
|
||||
if($event->tickets->count() === 0) {
|
||||
return '<script>showMessage("You need to create a ticket before you can add an attendee.");</script>';
|
||||
}
|
||||
|
||||
return View::make('ManageEvent.Modals.CreateAttendee', array(
|
||||
'modal_id' => \Input::get('modal_id'),
|
||||
'event' => $event,
|
||||
'tickets' => $event->tickets()->lists('title', 'id')
|
||||
));
|
||||
}
|
||||
|
||||
public function postCreateAttendee($event_id) {
|
||||
|
||||
$rules = [
|
||||
'first_name' => 'required',
|
||||
'ticket_id' => 'required|exists:tickets,id,account_id,' . \Auth::user()->account_id,
|
||||
'ticket_price' => 'numeric|required',
|
||||
'email' => 'email|required',
|
||||
];
|
||||
|
||||
$messages = [
|
||||
'ticket_id.exists' => 'The ticket you have selected does not exist',
|
||||
'ticket_id.required' => 'The ticket field is required. '
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$ticket_id = Input::get('ticket_id');
|
||||
$ticket_price = Input::get('ticket_price');
|
||||
$attendee_first_name = Input::get('first_name');
|
||||
$attendee_last_name = Input::get('last_name');
|
||||
$attendee_email = Input::get('email');
|
||||
$email_attendee = Input::get('email_ticket');
|
||||
|
||||
|
||||
/*
|
||||
* Create the order
|
||||
*/
|
||||
$order = new Order;
|
||||
$order->first_name = $attendee_first_name;
|
||||
$order->last_name = $attendee_last_name;
|
||||
$order->email = $attendee_email;
|
||||
$order->order_status_id = ORDER_COMPLETE;
|
||||
$order->amount = $ticket_price;
|
||||
$order->account_id = Auth::user()->account_id;
|
||||
$order->event_id = $event_id;
|
||||
$order->save();
|
||||
|
||||
/*
|
||||
* Update qty sold
|
||||
*/
|
||||
$ticket = Ticket::scope()->find($ticket_id);
|
||||
$ticket->increment('quantity_sold');
|
||||
$ticket->increment('sales_volume', $ticket_price);
|
||||
$ticket->event->increment('sales_volume', $ticket_price);
|
||||
|
||||
|
||||
/*
|
||||
* Insert order item
|
||||
*/
|
||||
$orderItem = new OrderItem;
|
||||
$orderItem->title = $ticket->title;
|
||||
$orderItem->quantity = 1;
|
||||
$orderItem->order_id = $order->id;
|
||||
$orderItem->unit_price = $ticket_price;
|
||||
$orderItem->save();
|
||||
|
||||
|
||||
/*
|
||||
* Update the event stats
|
||||
*/
|
||||
$event_stats = new EventStats;
|
||||
$event_stats->updateTicketsSoldCount($event_id, 1);
|
||||
$event_stats->updateTicketRevenue($ticket_id, $ticket_price);
|
||||
|
||||
|
||||
/*
|
||||
* Create the attendee
|
||||
*/
|
||||
$attendee = new Attendee;
|
||||
$attendee->first_name = $attendee_first_name;
|
||||
$attendee->last_name = $attendee_last_name;
|
||||
$attendee->email = $attendee_email;
|
||||
$attendee->event_id = $event_id;
|
||||
$attendee->order_id = $order->id;
|
||||
$attendee->ticket_id = $ticket_id;
|
||||
$attendee->account_id = Auth::user()->account_id;
|
||||
$attendee->reference = $order->order_reference . '-1';
|
||||
$attendee->save();
|
||||
|
||||
if ($email_attendee == '1') {
|
||||
$this->dispatch(new OrderTicketsCommand($order, false));
|
||||
}
|
||||
|
||||
Session::flash('message', 'Attendee Successfully Created');
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'id' => $attendee->id,
|
||||
'redirectUrl' => route('showEventAttendees', array(
|
||||
'event_id' => $event_id
|
||||
))
|
||||
));
|
||||
}
|
||||
|
||||
public function showPrintAttendees($event_id) {
|
||||
|
||||
$data['event'] = Event::scope()->find($event_id);
|
||||
$data['attendees'] = $data['event']->attendees()->withoutCancelled()->orderBy('first_name')->get();
|
||||
|
||||
return View::make('ManageEvent.PrintAttendees', $data);
|
||||
}
|
||||
|
||||
public function showMessageAttendee($attendee_id) {
|
||||
|
||||
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
||||
|
||||
$data = [
|
||||
'attendee' => $attendee,
|
||||
'event' => $attendee->event,
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Modals.MessageAttendee', $data);
|
||||
}
|
||||
|
||||
public function postMessageAttendee($attendee_id) {
|
||||
|
||||
$rules = [
|
||||
'subject' => 'required',
|
||||
'message' => 'required'
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
||||
|
||||
$data = [
|
||||
'attendee' => $attendee,
|
||||
'message_content' => Input::get('message'),
|
||||
'subject' => Input::get('subject'),
|
||||
'event' => $attendee->event,
|
||||
'email_logo' => $attendee->event->organiser->full_logo_path
|
||||
];
|
||||
|
||||
Mail::send('Emails.messageAttendees', $data, function($message) use ($attendee, $data) {
|
||||
$message->to($attendee->email, $attendee->full_name)
|
||||
->from(OUTGOING_EMAIL_NOREPLY, $attendee->event->organiser->name)
|
||||
->replyTo($attendee->event->organiser->email, $attendee->event->organiser->name)
|
||||
->subject($data['subject']);
|
||||
});
|
||||
|
||||
/* Could bcc in the above? */
|
||||
if (Input::get('send_copy') == '1') {
|
||||
Mail::send('Emails.messageAttendees', $data, function($message) use ($attendee, $data) {
|
||||
$message->to($attendee->event->organiser->email, $attendee->event->organiser->name)
|
||||
->from(OUTGOING_EMAIL_NOREPLY, $attendee->event->organiser->name)
|
||||
->replyTo($attendee->event->organiser->email, $attendee->event->organiser->name)
|
||||
->subject($data['subject'] . '[ORGANISER COPY]');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'message' => 'Message Successfully Sent'
|
||||
));
|
||||
}
|
||||
|
||||
public function showMessageAttendees($event_id) {
|
||||
|
||||
$data = [
|
||||
'event' => Event::scope()->find($event_id),
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
'tickets' => Event::scope()->find($event_id)->tickets()->lists('title', 'id')->toArray()
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Modals.MessageAttendees', $data);
|
||||
}
|
||||
|
||||
public function postMessageAttendees($event_id) {
|
||||
|
||||
$rules = [
|
||||
'subject' => 'required',
|
||||
'message' => 'required',
|
||||
'recipients' => 'required'
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$message = Message::createNew();
|
||||
$message->message = Input::get('message');
|
||||
$message->subject = Input::get('subject');
|
||||
$message->recipients = Input::get('recipients');
|
||||
$message->event_id = $event_id;
|
||||
$message->save();
|
||||
|
||||
/*
|
||||
* Add to the queue
|
||||
*/
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'message' => 'Message Successfully Sent'
|
||||
));
|
||||
}
|
||||
|
||||
public function showExportAttendees($event_id, $export_as = 'xls') {
|
||||
|
||||
Excel::create('attendees-as-of-' . date('d-m-Y-g.i.a'), function($excel) use ($event_id) {
|
||||
|
||||
$excel->setTitle('Attendees List');
|
||||
|
||||
// Chain the setters
|
||||
$excel->setCreator(APP_NAME)
|
||||
->setCompany(APP_NAME);
|
||||
|
||||
$excel->sheet('attendees_sheet_1', function($sheet) use ($event_id) {
|
||||
|
||||
DB::connection()->setFetchMode(\PDO::FETCH_ASSOC);
|
||||
$data = DB::table('attendees')
|
||||
->where('attendees.event_id', '=', $event_id)
|
||||
->where('attendees.is_cancelled', '=', 0)
|
||||
->where('attendees.account_id', '=', Auth::user()->account_id)
|
||||
->join('events', 'events.id', '=', 'attendees.event_id')
|
||||
->join('orders', 'orders.id', '=', 'attendees.order_id')
|
||||
->join('tickets', 'tickets.id', '=', 'attendees.ticket_id')
|
||||
->select(
|
||||
'attendees.first_name', 'attendees.last_name', 'attendees.email', 'attendees.reference', 'orders.order_reference', 'tickets.title', 'orders.created_at', DB::raw("(CASE WHEN attendees.has_arrived = 1 THEN 'YES' ELSE 'NO' END) AS `attendees.has_arrived`"), 'attendees.arrival_time')->get();
|
||||
//DB::raw("(CASE WHEN UNIX_TIMESTAMP(`attendees.arrival_time`) = 0 THEN '---' ELSE 'd' END) AS `attendees.arrival_time`"))
|
||||
|
||||
|
||||
|
||||
|
||||
$sheet->fromArray($data);
|
||||
|
||||
$sheet->row(1, array(
|
||||
'First Name', 'Last Name', 'Email', 'Ticket Reference', 'Order Reference', 'Ticket Type', 'Purchase Date', 'Has Arrived', 'Arrival Time'
|
||||
));
|
||||
|
||||
// Set gray background on first row
|
||||
$sheet->row(1, function($row) {
|
||||
$row->setBackground('#f5f5f5');
|
||||
});
|
||||
});
|
||||
})->export($export_as);
|
||||
}
|
||||
|
||||
public function showEditAttendee($event_id, $attendee_id) {
|
||||
|
||||
|
||||
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
||||
|
||||
$data = [
|
||||
'attendee' => $attendee,
|
||||
'event' => $attendee->event,
|
||||
'tickets' => $attendee->event->tickets->lists('title', 'id'),
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Modals.EditAttendee', $data);
|
||||
}
|
||||
|
||||
public function postEditAttendee($event_id, $attendee_id) {
|
||||
|
||||
$rules = [
|
||||
'first_name' => 'required',
|
||||
'ticket_id' => 'required|exists:tickets,id,account_id,' . Auth::user()->account_id,
|
||||
'email' => 'required|email'
|
||||
];
|
||||
|
||||
$messages = [
|
||||
'ticket_id.exists' => 'The ticket you have selected does not exist',
|
||||
'ticket_id.required' => 'The ticket field is required. '
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
||||
|
||||
$attendee->first_name = Input::get('first_name');
|
||||
$attendee->last_name = Input::get('last_name');
|
||||
$attendee->email = Input::get('email');
|
||||
$attendee->ticket_id = Input::get('ticket_id');
|
||||
$attendee->save();
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'id' => $attendee->id,
|
||||
'message' => 'Refreshing...',
|
||||
'redirectUrl' => ''
|
||||
));
|
||||
}
|
||||
|
||||
public function showCancelAttendee($event_id, $attendee_id) {
|
||||
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
||||
|
||||
$data = [
|
||||
'attendee' => $attendee,
|
||||
'event' => $attendee->event,
|
||||
'tickets' => $attendee->event->tickets->lists('title', 'id'),
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Modals.CancelAttendee', $data);
|
||||
}
|
||||
|
||||
public function postCancelAttendee($event_id, $attendee_id) {
|
||||
$attendee = Attendee::scope()->findOrFail($attendee_id);
|
||||
|
||||
$attendee->ticket->decrement('quantity_sold');
|
||||
$attendee->is_cancelled = 1;
|
||||
$attendee->save();
|
||||
|
||||
$data = [
|
||||
'attendee' => $attendee,
|
||||
'email_logo' => $attendee->organiser->full_logo_path
|
||||
];
|
||||
|
||||
if (Input::get('notify_attendee') == '1') {
|
||||
Mail::send('Emails.notifyCancelledAttendee', $data, function($message) use ($attendee) {
|
||||
$message->to($attendee->email, $attendee->full_name)
|
||||
->from(OUTGOING_EMAIL_NOREPLY, $attendee->event->organiser->name)
|
||||
->replyTo($attendee->event->organiser->email, $attendee->event->organiser->name)
|
||||
->subject('You\'re ticket has been cancelled');
|
||||
});
|
||||
}
|
||||
|
||||
\Session::flash('message', 'Successfully Cancelled Attenddee');
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'id' => $attendee->id,
|
||||
'message' => 'Refreshing...',
|
||||
'redirectUrl' => ''
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Input,
|
||||
DB,
|
||||
Response,
|
||||
View;
|
||||
use App\Models\Event;
|
||||
use App\Models\Attendee;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class EventCheckInController extends MyBaseController {
|
||||
|
||||
/**
|
||||
* @param $event_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function showCheckIn($event_id) {
|
||||
$data['event'] = Event::scope()->findOrFail($event_id);
|
||||
$data['attendees'] = $data['event']->attendees;
|
||||
return View::make('ManageEvent.CheckIn', $data);
|
||||
}
|
||||
|
||||
public function postCheckInSearch($event_id) {
|
||||
|
||||
$searchQuery = Input::get('q');
|
||||
|
||||
$attendees = Attendee::scope()->withoutCancelled()
|
||||
->join('tickets', 'tickets.id', '=', 'attendees.ticket_id')
|
||||
->where(function($query) use ($event_id) {
|
||||
$query->where('attendees.event_id', '=', $event_id);
|
||||
})->where(function($query) use ($searchQuery) {
|
||||
$query->orWhere('attendees.first_name', 'like', $searchQuery . '%')
|
||||
->orWhere(DB::raw("CONCAT_WS(' ', first_name, last_name)"), 'like', $searchQuery . '%')
|
||||
//->orWhere('attendees.email', 'like', $searchQuery . '%')
|
||||
->orWhere('attendees.reference', 'like', $searchQuery . '%')
|
||||
->orWhere('attendees.last_name', 'like', $searchQuery . '%');
|
||||
})
|
||||
->select([
|
||||
'attendees.id',
|
||||
'attendees.first_name',
|
||||
'attendees.last_name',
|
||||
'attendees.email',
|
||||
'attendees.reference',
|
||||
'attendees.arrival_time',
|
||||
'attendees.has_arrived',
|
||||
'tickets.title as ticket'
|
||||
])
|
||||
->orderBy('attendees.first_name', 'ASC')
|
||||
->get();
|
||||
|
||||
return Response::json($attendees);
|
||||
}
|
||||
|
||||
public function postCheckInAttendee() {
|
||||
|
||||
$attendee_id = Input::get('attendee_id');
|
||||
$checking = Input::get('checking');
|
||||
|
||||
$attendee = Attendee::scope()->find($attendee_id);
|
||||
|
||||
/*
|
||||
* Ugh
|
||||
*/
|
||||
if ((($checking == 'in') && ($attendee->has_arrived == 1)) || (($checking == 'out') && ($attendee->has_arrived == 0))) {
|
||||
return Response::json([
|
||||
'status' => 'error',
|
||||
'message' => 'Warning: This Attendee Has Already Been Checked ' . (($checking == 'in') ? 'In (at '.$attendee->arrival_time->format('H:i A, F j').')' : 'Out').'!',
|
||||
'checked' => $checking,
|
||||
'id' => $attendee->id
|
||||
]);
|
||||
}
|
||||
|
||||
$attendee->has_arrived = ($checking == 'in') ? 1 : 0;
|
||||
$attendee->arrival_time = Carbon::now();
|
||||
$attendee->save();
|
||||
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'checked' => $checking,
|
||||
'message' => 'Attendee Successfully Checked ' . (($checking == 'in') ? 'In' : 'Out'),
|
||||
'id' => $attendee->id
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,504 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use View,
|
||||
Input,
|
||||
Validator,
|
||||
DB,
|
||||
Response,
|
||||
Session,
|
||||
Request,
|
||||
Redirect,
|
||||
Log,
|
||||
Cookie,
|
||||
App;
|
||||
use PDF;
|
||||
use Bugsnag;
|
||||
use Stripe,
|
||||
Stripe_Charge,
|
||||
Stripe_Customer;
|
||||
use App\Commands\OrderTicketsCommand;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Event;
|
||||
use App\Models\Affiliate;
|
||||
use App\Models\Order;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\Attendee;
|
||||
use App\Models\EventStats;
|
||||
use App\Models\OrderItem;
|
||||
use App\Models\ReservedTickets;
|
||||
use App\Attendize\Utils;
|
||||
|
||||
class EventCheckoutController extends Controller
|
||||
{
|
||||
|
||||
protected $is_embedded;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
/*
|
||||
* See if the checkout is being called from an embedded iframe.
|
||||
*/
|
||||
$this->is_embedded = Input::get('is_embedded') == '1';
|
||||
}
|
||||
|
||||
public function postValidateTickets($event_id)
|
||||
{
|
||||
/*
|
||||
* Order expires after X min
|
||||
*/
|
||||
$order_expires_time = Carbon::now()->addMinutes(CHECKOUT_TIMEOUT_AFTER);
|
||||
|
||||
$event = Event::findOrFail($event_id);
|
||||
|
||||
$ticket_ids = Input::get('tickets');
|
||||
|
||||
/*
|
||||
* Remove any tickets the user has reserved
|
||||
*/
|
||||
ReservedTickets::where('session_id', '=', Session::getId())->delete();
|
||||
|
||||
/*
|
||||
* Go though the selected tickets and check if they're available
|
||||
* , tot up the price and reserve them to prevent over selling.
|
||||
*/
|
||||
|
||||
$validation_rules = [];
|
||||
$validation_messages = [];
|
||||
$tickets = [];
|
||||
$order_total = 0;
|
||||
$total_ticket_quantity = 0;
|
||||
$booking_fee = 0;
|
||||
$organiser_booking_fee = 0;
|
||||
$quantity_available_validation_rules = [];
|
||||
|
||||
foreach ($ticket_ids as $ticket_id) {
|
||||
|
||||
$current_ticket_quantity = (int)Input::get('ticket_' . $ticket_id);
|
||||
|
||||
|
||||
if ($current_ticket_quantity < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$total_ticket_quantity = $total_ticket_quantity + $current_ticket_quantity;
|
||||
|
||||
$ticket = Ticket::find($ticket_id);
|
||||
|
||||
$ticket_quantity_remaining = $ticket->quantity_remaining;
|
||||
|
||||
/*
|
||||
* @todo Check max/min per person
|
||||
*/
|
||||
$max_per_person = min($ticket_quantity_remaining, $ticket->max_per_person);
|
||||
|
||||
$quantity_available_validation_rules['ticket_' . $ticket_id] = ['numeric', 'min:' . $ticket->min_per_person, 'max:' . $max_per_person];
|
||||
|
||||
|
||||
$quantity_available_validation_messages = [
|
||||
'ticket_' . $ticket_id . '.max' => 'The maximum number of tickets you can register is ' . $ticket_quantity_remaining,
|
||||
'ticket_' . $ticket_id . '.min' => 'You must select at least ' . $ticket->min_per_person . ' tickets.'
|
||||
];
|
||||
|
||||
|
||||
$validator = Validator::make(['ticket_' . $ticket_id => (int)Input::get('ticket_' . $ticket_id)], $quantity_available_validation_rules, $quantity_available_validation_messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json([
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
]);
|
||||
}
|
||||
|
||||
$order_total = $order_total + ($current_ticket_quantity * $ticket->price);
|
||||
$booking_fee = $booking_fee + ($current_ticket_quantity * $ticket->booking_fee);
|
||||
$organiser_booking_fee = $organiser_booking_fee + ($current_ticket_quantity * $ticket->organiser_booking_fee);
|
||||
|
||||
$tickets[] = [
|
||||
'ticket' => $ticket,
|
||||
'qty' => $current_ticket_quantity,
|
||||
'price' => ($current_ticket_quantity * $ticket->price),
|
||||
'booking_fee' => ($current_ticket_quantity * $ticket->booking_fee),
|
||||
'organiser_booking_fee' => ($current_ticket_quantity * $ticket->organiser_booking_fee),
|
||||
'full_price' => $ticket->price + $ticket->total_booking_fee
|
||||
];
|
||||
|
||||
/*
|
||||
* Reserve the tickets in the DB
|
||||
*/
|
||||
$reservedTickets = new ReservedTickets;
|
||||
$reservedTickets->ticket_id = $ticket_id;
|
||||
$reservedTickets->event_id = $event_id;
|
||||
$reservedTickets->quantity_reserved = $current_ticket_quantity;
|
||||
$reservedTickets->expires = $order_expires_time;
|
||||
$reservedTickets->session_id = Session::getId();
|
||||
$reservedTickets->save();
|
||||
|
||||
if ($event->ask_for_all_attendees_info) {
|
||||
for ($i = 0; $i < $current_ticket_quantity; $i++) {
|
||||
/*
|
||||
* Create our validation rules here
|
||||
*/
|
||||
$validation_rules['ticket_holder_first_name.' . $i . '.' . $ticket_id] = ['required'];
|
||||
$validation_rules['ticket_holder_last_name.' . $i . '.' . $ticket_id] = ['required'];
|
||||
$validation_rules['ticket_holder_email.' . $i . '.' . $ticket_id] = ['required', 'email'];
|
||||
|
||||
$validation_messages['ticket_holder_first_name.' . $i . '.' . $ticket_id . '.required'] = 'Ticket holder ' . ($i + 1) . '\'s first name is required';
|
||||
$validation_messages['ticket_holder_last_name.' . $i . '.' . $ticket_id . '.required'] = 'Ticket holder ' . ($i + 1) . '\'s last name is required';
|
||||
$validation_messages['ticket_holder_email.' . $i . '.' . $ticket_id . '.required'] = 'Ticket holder ' . ($i + 1) . '\'s email is required';
|
||||
$validation_messages['ticket_holder_email.' . $i . '.' . $ticket_id . '.email'] = 'Ticket holder ' . ($i + 1) . '\'s email appears to be invalid';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($tickets)) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'message' => 'No tickets selected.'
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
* @todo - Store this in something other than a session?
|
||||
*/
|
||||
Session::set('ticket_order_' . $event->id, [
|
||||
'validation_rules' => $validation_rules,
|
||||
'validation_messages' => $validation_messages,
|
||||
'event_id' => $event->id,
|
||||
'tickets' => $tickets, /* probably shouldn't store the whole ticket obj in session */
|
||||
'total_ticket_quantity' => $total_ticket_quantity,
|
||||
'order_started' => time(),
|
||||
'expires' => $order_expires_time,
|
||||
'reserved_tickets_id' => $reservedTickets->id,
|
||||
'order_total' => $order_total,
|
||||
'booking_fee' => $booking_fee,
|
||||
'organiser_booking_fee' => $organiser_booking_fee,
|
||||
'total_booking_fee' => $booking_fee + $organiser_booking_fee,
|
||||
'order_requires_payment' => (ceil($order_total) == 0) ? FALSE : TRUE,
|
||||
'account_id' => $event->account->id,
|
||||
'affiliate_referral' => Cookie::get('affiliate_' . $event_id)
|
||||
]);
|
||||
|
||||
if (Request::ajax()) {
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'redirectUrl' => route('showEventCheckout', [
|
||||
'event_id' => $event_id,
|
||||
'is_embedded' => $this->is_embedded
|
||||
]) . '#order_form'
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: We should just show an enable JS message here instead
|
||||
*/
|
||||
return Redirect::to(route('showEventCheckout', [
|
||||
'event_id' => $event_id
|
||||
]) . '#order_form');
|
||||
}
|
||||
|
||||
public function showEventCheckout($event_id)
|
||||
{
|
||||
|
||||
$order_session = Session::get('ticket_order_' . $event_id);
|
||||
|
||||
if (!$order_session || $order_session['expires'] < Carbon::now()) {
|
||||
return Redirect::route('showEventPage', ['event_id' => $event_id]);
|
||||
}
|
||||
|
||||
$secondsToExpire = Carbon::now()->diffInSeconds($order_session['expires']);
|
||||
|
||||
//dd($secondsToExpire);
|
||||
$data = $order_session + [
|
||||
'event' => Event::findorFail($order_session['event_id']),
|
||||
'secondsToExpire' => $secondsToExpire,
|
||||
'is_embedded' => $this->is_embedded
|
||||
];
|
||||
|
||||
if ($this->is_embedded) {
|
||||
return View::make('Public.ViewEvent.Embedded.EventPageCheckout', $data);
|
||||
}
|
||||
return View::make('Public.ViewEvent.EventPageCheckout', $data);
|
||||
}
|
||||
|
||||
public function postCreateOrder($event_id)
|
||||
{
|
||||
|
||||
$mirror_buyer_info = (Input::get('mirror_buyer_info') == 'on') ? TRUE : FALSE;
|
||||
|
||||
$event = Event::findOrFail($event_id);
|
||||
|
||||
$order = new Order;
|
||||
|
||||
$ticket_order = Session::get('ticket_order_' . $event_id);
|
||||
|
||||
$attendee_increment = 1;
|
||||
|
||||
$validation_rules = $ticket_order['validation_rules'];
|
||||
$validation_messages = $ticket_order['validation_messages'];
|
||||
|
||||
|
||||
if (!$mirror_buyer_info && $event->ask_for_all_attendees_info) {
|
||||
$order->rules = $order->rules + $validation_rules;
|
||||
$order->messages = $order->messages + $validation_messages;
|
||||
}
|
||||
|
||||
if (!$order->validate(Input::all())) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $order->errors()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin payment attempt before creating the attendees etc.
|
||||
* */
|
||||
if ($ticket_order['order_requires_payment']) {
|
||||
|
||||
try {
|
||||
|
||||
$stripe_error = FALSE;
|
||||
|
||||
Stripe::setApiKey($event->account->stripe_api_key);
|
||||
|
||||
$token = Input::get('stripeToken');
|
||||
|
||||
$customer = Stripe_Customer::create(array(
|
||||
'email' => Input::get('order_email'),
|
||||
'card' => $token,
|
||||
'description' => 'Customer: ' . Input::get('order_email')
|
||||
));
|
||||
|
||||
if (Utils::isAttendize()) {
|
||||
$charge = Stripe_Charge::create(array(
|
||||
'customer' => $customer->id,
|
||||
'amount' => ($ticket_order['order_total'] + $ticket_order['organiser_booking_fee']) * 100,
|
||||
'currency' => $event->currency->code,
|
||||
'description' => Input::get('order_email'),
|
||||
'application_fee' => $ticket_order['booking_fee'] * 100,
|
||||
'description' => 'Order for customer: ' . Input::get('order_email')
|
||||
));
|
||||
} else {
|
||||
$charge = Stripe_Charge::create(array(
|
||||
'customer' => $customer->id,
|
||||
'amount' => ($ticket_order['order_total'] + $ticket_order['organiser_booking_fee']) * 100,
|
||||
'currency' => $event->currency->code,
|
||||
'description' => Input::get('order_email'),
|
||||
'description' => 'Order for customer: ' . Input::get('order_email')
|
||||
));
|
||||
}
|
||||
|
||||
$order->transaction_id = $charge->id;
|
||||
} catch (\Stripe_CardError $e) {
|
||||
// Card was declined.
|
||||
$e_json = $e->getJsonBody();
|
||||
$error = $e_json['error'];
|
||||
$stripe_error = $error['message'];
|
||||
Log::error($e);
|
||||
} catch (\Stripe_InvalidRequestError $e) {
|
||||
$stripe_error = 'Whoops, something went wrong. Please try again.';
|
||||
Log::error($e);
|
||||
} catch (\Stripe_AuthenticationError $e) {
|
||||
$stripe_error = 'There was a problem processing your payment. Please try again';
|
||||
Log::error($e);
|
||||
} catch (\Stripe_ApiConnectionError $e) {
|
||||
$stripe_error = 'There was a problem processing your payment. Please try again';
|
||||
Log::error($e);
|
||||
} catch (\Stripe_Error $e) {
|
||||
$stripe_error = 'There was a problem processing your payment. Please try again';
|
||||
Log::error($e);
|
||||
} catch (\Exception $e) {
|
||||
$stripe_error = 'There was a problem processing your payment. Please try again';
|
||||
Log::error($e);
|
||||
}
|
||||
|
||||
if ($stripe_error) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'message' => $stripe_error
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the order
|
||||
*/
|
||||
$order->first_name = Input::get('order_first_name');
|
||||
$order->last_name = Input::get('order_last_name');
|
||||
$order->email = Input::get('order_email');
|
||||
$order->order_status_id = ORDER_COMPLETE;
|
||||
$order->amount = $ticket_order['order_total'];
|
||||
$order->booking_fee = $ticket_order['booking_fee'];
|
||||
$order->organiser_booking_fee = $ticket_order['organiser_booking_fee'];
|
||||
$order->discount = 0.00;
|
||||
$order->account_id = $event->account->id;
|
||||
$order->event_id = $event_id;
|
||||
$order->save();
|
||||
|
||||
/*
|
||||
* Update the event sales volume
|
||||
*/
|
||||
$event->increment('sales_volume', $order->amount);
|
||||
$event->increment('organiser_fees_volume', $order->organiser_booking_fee);
|
||||
|
||||
/*
|
||||
* Update affiliates stats stats
|
||||
*/
|
||||
if ($ticket_order['affiliate_referral']) {
|
||||
$affiliate = Affiliate::where('name', '=', $ticket_order['affiliate_referral'])->first();
|
||||
$affiliate->increment('sales_volume', $order->amount + $order->organiser_booking_fee);
|
||||
$affiliate->increment('tickets_sold', $ticket_order['total_ticket_quantity']);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the event stats
|
||||
*/
|
||||
$event_stats = EventStats::firstOrNew([
|
||||
'event_id' => $event_id,
|
||||
'date' => DB::raw('CURDATE()')
|
||||
]);
|
||||
$event_stats->increment('tickets_sold', $ticket_order['total_ticket_quantity']);
|
||||
|
||||
if ($ticket_order['order_requires_payment']) {
|
||||
$event_stats->increment('sales_volume', $order->amount);
|
||||
$event_stats->increment('organiser_fees_volume', $order->organiser_booking_fee);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the attendees
|
||||
*/
|
||||
foreach ($ticket_order['tickets'] as $attendee_details) {
|
||||
|
||||
/*
|
||||
* Update ticket's quantity sold
|
||||
*/
|
||||
$ticket = Ticket::findOrFail($attendee_details['ticket']['id']);
|
||||
|
||||
/*
|
||||
* Update some ticket info
|
||||
*/
|
||||
$ticket->increment('quantity_sold', $attendee_details['qty']);
|
||||
$ticket->increment('sales_volume', ($attendee_details['ticket']['price'] * $attendee_details['qty']));
|
||||
$ticket->increment('organiser_fees_volume', ($attendee_details['ticket']['organiser_booking_fee'] * $attendee_details['qty']));
|
||||
|
||||
/*
|
||||
* Insert order items (for use in generating invoices)
|
||||
*/
|
||||
$orderItem = new OrderItem;
|
||||
$orderItem->title = $attendee_details['ticket']['title'];
|
||||
$orderItem->quantity = $attendee_details['qty'];
|
||||
$orderItem->order_id = $order->id;
|
||||
$orderItem->unit_price = $attendee_details['ticket']['price'];
|
||||
$orderItem->unit_booking_fee = $attendee_details['ticket']['booking_fee'] + $attendee_details['ticket']['organiser_booking_fee'];
|
||||
$orderItem->save();
|
||||
|
||||
/*
|
||||
* Create the attendees
|
||||
*/
|
||||
for ($i = 0; $i < $attendee_details['qty']; $i++) {
|
||||
$attendee = new Attendee;
|
||||
$attendee->first_name = $event->ask_for_all_attendees_info ? ($mirror_buyer_info ? $order->first_name : Input::get("ticket_holder_first_name.$i.{$attendee_details['ticket']['id']}")) : $order->first_name;
|
||||
$attendee->last_name = $event->ask_for_all_attendees_info ? ($mirror_buyer_info ? $order->last_name : Input::get("ticket_holder_last_name.$i.{$attendee_details['ticket']['id']}")) : $order->last_name;
|
||||
$attendee->email = $event->ask_for_all_attendees_info ? ($mirror_buyer_info ? $order->email : Input::get("ticket_holder_email.$i.{$attendee_details['ticket']['id']}")) : $order->email;
|
||||
$attendee->event_id = $event_id;
|
||||
$attendee->order_id = $order->id;
|
||||
$attendee->ticket_id = $attendee_details['ticket']['id'];
|
||||
$attendee->account_id = $event->account->id;
|
||||
$attendee->reference = $order->order_reference . '-' . ($attendee_increment);
|
||||
$attendee->save();
|
||||
|
||||
/*
|
||||
* Queue an email to send to each attendee
|
||||
*/
|
||||
|
||||
|
||||
/* Keep track of total number of attendees */
|
||||
$attendee_increment++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Queue up some tasks - Emails to be sents, PDFs etc.
|
||||
*/
|
||||
$this->dispatch(new OrderTicketsCommand($order));
|
||||
|
||||
/*
|
||||
* Release the reserved the tickets
|
||||
*/
|
||||
ReservedTickets::where('session_id', '=', Session::getId())->delete();
|
||||
|
||||
/*
|
||||
* Kill the session
|
||||
*/
|
||||
Session::forget('ticket_order_' . $event->id);
|
||||
|
||||
/*
|
||||
* Queue the PDF creation jobs
|
||||
*/
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'redirectUrl' => route('showOrderDetails', [
|
||||
'is_embedded' => $this->is_embedded,
|
||||
'order_reference' => $order->order_reference
|
||||
])
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the order details page
|
||||
*
|
||||
* @param string $order_reference
|
||||
* @return view
|
||||
*/
|
||||
public function showOrderDetails($order_reference)
|
||||
{
|
||||
|
||||
$order = Order::where('order_reference', '=', $order_reference)->first();
|
||||
|
||||
if (!$order) {
|
||||
App::abort(404);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'order' => $order,
|
||||
'event' => $order->event,
|
||||
'tickets' => $order->event->tickets,
|
||||
'is_embedded' => $this->is_embedded
|
||||
];
|
||||
|
||||
if ($this->is_embedded) {
|
||||
return View::make('Public.ViewEvent.Embedded.EventPageViewOrder', $data);
|
||||
}
|
||||
return View::make('Public.ViewEvent.EventPageViewOrder', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output order tickets
|
||||
*
|
||||
* @param string $order_reference
|
||||
*/
|
||||
public function showOrderTickets($order_reference)
|
||||
{
|
||||
|
||||
$order = Order::where('order_reference', '=', $order_reference)->first();
|
||||
|
||||
if (!$order) {
|
||||
App::abort(404);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'order' => $order,
|
||||
'event' => $order->event,
|
||||
'tickets' => $order->event->tickets,
|
||||
'attendees' => $order->attendees
|
||||
];
|
||||
|
||||
if (Input::get('download') == '1') {
|
||||
return PDF::html('Public.ViewEvent.Partials.PDFTicket', $data, 'Tickets');
|
||||
}
|
||||
|
||||
return View::make('Public.ViewEvent.Partials.PDFTicket', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,289 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Response, Input, Validator;
|
||||
use Auth;
|
||||
use Image;
|
||||
use Storage;
|
||||
use View;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\EventImage;
|
||||
use App\Models\Organiser;
|
||||
use App\Models\Event;
|
||||
|
||||
class EventController extends MyBaseController {
|
||||
|
||||
|
||||
public function showCreateEvent() {
|
||||
|
||||
$data = [
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
'organisers' => Organiser::scope()->lists('name', 'id'),
|
||||
'organiser_id' => Input::get('organiser_id') ? Input::get('organiser_id') : false
|
||||
];
|
||||
|
||||
return View::make('ManageOrganiser.Modals.CreateEvent', $data);
|
||||
}
|
||||
|
||||
public function postCreateEvent() {
|
||||
|
||||
$event = Event::createNew();
|
||||
|
||||
if (!$event->validate(Input::all())) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $event->errors()
|
||||
));
|
||||
}
|
||||
|
||||
$event->title = Input::get('title');
|
||||
$event->description = strip_tags(Input::get('description'));
|
||||
$event->start_date = Input::get('start_date') ? Carbon::createFromFormat('d-m-Y H:i', Input::get('start_date')) : NULL;
|
||||
|
||||
/*
|
||||
* Venue location info (Usually autofilled from google maps)
|
||||
*/
|
||||
|
||||
$is_auto_address = (trim(Input::get('place_id')) !== '');
|
||||
|
||||
if ($is_auto_address) { /* Google auto filled */
|
||||
$event->venue_name = Input::get('name');
|
||||
$event->venue_name_full = Input::get('venue_name_full');
|
||||
$event->location_lat = Input::get('lat');
|
||||
$event->location_long = Input::get('lng');
|
||||
$event->location_address = Input::get('formatted_address');
|
||||
$event->location_country = Input::get('country');
|
||||
$event->location_country_code = Input::get('country_short');
|
||||
$event->location_state = Input::get('administrative_area_level_1');
|
||||
$event->location_address_line_1 = Input::get('route');
|
||||
$event->location_address_line_2 = Input::get('locality');
|
||||
$event->location_post_code = Input::get('postal_code');
|
||||
$event->location_street_number = Input::get('street_number');
|
||||
$event->location_google_place_id = Input::get('place_id');
|
||||
$event->location_is_manual = 0;
|
||||
} else { /* Manually entered */
|
||||
$event->venue_name = Input::get('location_venue_name');
|
||||
$event->location_address_line_1 = Input::get('location_address_line_1');
|
||||
$event->location_address_line_2 = Input::get('location_address_line_2');
|
||||
$event->location_state = Input::get('location_state');
|
||||
$event->location_post_code = Input::get('location_post_code');
|
||||
$event->location_is_manual = 1;
|
||||
}
|
||||
|
||||
|
||||
$event->end_date = Input::get('end_date') ? Carbon::createFromFormat('d-m-Y H:i', Input::get('end_date')) : NULL;
|
||||
|
||||
$event->currency_id = Auth::user()->account->currency_id;
|
||||
//$event->timezone_id = Auth::user()->account->timezone_id;
|
||||
|
||||
|
||||
if (Input::get('organiser_name')) {
|
||||
|
||||
$organiser = Organiser::createNew(FALSE, FALSE, TRUE);
|
||||
|
||||
$rules = array(
|
||||
'organiser_name' => array('required'),
|
||||
'organiser_email' => array('required', 'email'),
|
||||
);
|
||||
$messages = array(
|
||||
'organiser_name.required' => 'You must give a name for the event organiser.'
|
||||
);
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$organiser->name = Input::get('organiser_name');
|
||||
$organiser->about = Input::get('organiser_about');
|
||||
$organiser->email = Input::get('organiser_email');
|
||||
$organiser->facebook = Input::get('organiser_facebook');
|
||||
$organiser->twitter = Input::get('organiser_twitter');
|
||||
$organiser->save();
|
||||
$event->organiser_id = $organiser->id;
|
||||
} elseif (Input::get('organiser_id')) {
|
||||
$event->organiser_id = Input::get('organiser_id');
|
||||
} else { /* Somethings gone horribly wrong */}
|
||||
|
||||
$event->save();
|
||||
|
||||
if (Input::hasFile('event_image')) {
|
||||
|
||||
$path = public_path() . '/' . EVENT_IMAGES_PATH;
|
||||
$filename = 'event_image-' . md5(time() . $event->id) . '.' . strtolower(Input::file('event_image')->getClientOriginalExtension());
|
||||
|
||||
$file_full_path = $path . '/' . $filename;
|
||||
|
||||
|
||||
Input::file('event_image')->move($path, $filename);
|
||||
|
||||
$img = Image::make($file_full_path);
|
||||
|
||||
$img->resize(800, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
|
||||
$img->save($file_full_path);
|
||||
|
||||
/* Upload to s3 */
|
||||
\Storage::put(EVENT_IMAGES_PATH.'/'.$filename, file_get_contents($file_full_path));
|
||||
|
||||
|
||||
$eventImage = EventImage::createNew();
|
||||
$eventImage->image_path = EVENT_IMAGES_PATH . '/' . $filename;
|
||||
$eventImage->event_id = $event->id;
|
||||
$eventImage->save();
|
||||
}
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'id' => $event->id,
|
||||
'redirectUrl' => route('showEventTickets', array(
|
||||
'event_id' => $event->id,
|
||||
'first_run' => 'yup'
|
||||
))
|
||||
));
|
||||
}
|
||||
|
||||
public function postEditEvent($event_id) {
|
||||
|
||||
$event = Event::scope()->findOrFail($event_id);
|
||||
|
||||
if (!$event->validate(Input::all())) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $event->errors()
|
||||
));
|
||||
}
|
||||
|
||||
$event->is_live = Input::get('is_live');
|
||||
$event->title = Input::get('title');
|
||||
$event->description = strip_tags(Input::get('description'));
|
||||
$event->start_date = Input::get('start_date') ? Carbon::createFromFormat('d-m-Y H:i', Input::get('start_date')) : NULL;
|
||||
|
||||
|
||||
/*
|
||||
* If the google place ID is the same as before then don't update the venue
|
||||
*/
|
||||
if ((Input::get('place_id') !== $event->location_google_place_id) || $event->location_google_place_id == '') {
|
||||
$is_auto_address = (trim(Input::get('place_id')) !== '');
|
||||
|
||||
if ($is_auto_address) { /* Google auto filled */
|
||||
$event->venue_name = Input::get('name');
|
||||
$event->venue_name_full = Input::get('venue_name_full');
|
||||
$event->location_lat = Input::get('lat');
|
||||
$event->location_long = Input::get('lng');
|
||||
$event->location_address = Input::get('formatted_address');
|
||||
$event->location_country = Input::get('country');
|
||||
$event->location_country_code = Input::get('country_short');
|
||||
$event->location_state = Input::get('administrative_area_level_1');
|
||||
$event->location_address_line_1 = Input::get('route');
|
||||
$event->location_address_line_2 = Input::get('locality');
|
||||
$event->location_post_code = Input::get('postal_code');
|
||||
$event->location_street_number = Input::get('street_number');
|
||||
$event->location_google_place_id = Input::get('place_id');
|
||||
$event->location_is_manual = 0;
|
||||
} else { /* Manually entered */
|
||||
$event->venue_name = Input::get('location_venue_name');
|
||||
$event->location_address_line_1 = Input::get('location_address_line_1');
|
||||
$event->location_address_line_2 = Input::get('location_address_line_2');
|
||||
$event->location_state = Input::get('location_state');
|
||||
$event->location_post_code = Input::get('location_post_code');
|
||||
$event->location_is_manual = 1;
|
||||
$event->location_google_place_id = '';
|
||||
$event->venue_name_full = '';
|
||||
$event->location_lat = '';
|
||||
$event->location_long = '';
|
||||
$event->location_address = '';
|
||||
$event->location_country = '';
|
||||
$event->location_country_code = '';
|
||||
$event->location_street_number = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$event->end_date = Input::get('end_date') ? Carbon::createFromFormat('d-m-Y H:i', Input::get('end_date')) : NULL;
|
||||
|
||||
|
||||
if (Input::get('remove_current_image') == '1') {
|
||||
EventImage::where('event_id', '=', $event->id)->delete();
|
||||
}
|
||||
|
||||
$event->save();
|
||||
|
||||
if (Input::hasFile('event_image')) {
|
||||
|
||||
$path = public_path() . '/' . EVENT_IMAGES_PATH;
|
||||
$filename = 'event_image-' . md5(time() . $event->id) . '.' . strtolower(Input::file('event_image')->getClientOriginalExtension());
|
||||
|
||||
$file_full_path = $path . '/' . $filename;
|
||||
|
||||
|
||||
Input::file('event_image')->move($path, $filename);
|
||||
|
||||
$img = Image::make($file_full_path);
|
||||
|
||||
$img->resize(800, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
|
||||
$img->save($file_full_path);
|
||||
|
||||
\Storage::put(EVENT_IMAGES_PATH.'/'.$filename, file_get_contents($file_full_path));
|
||||
|
||||
EventImage::where('event_id', '=', $event->id)->delete();
|
||||
|
||||
$eventImage = EventImage::createNew();
|
||||
$eventImage->image_path = EVENT_IMAGES_PATH . '/' . $filename;
|
||||
$eventImage->event_id = $event->id;
|
||||
$eventImage->save();
|
||||
}
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'id' => $event->id,
|
||||
'message' => 'Event Successfully Updated',
|
||||
'redirectUrl' => ''
|
||||
));
|
||||
}
|
||||
|
||||
public function postUploadEventImage() {
|
||||
|
||||
if (Input::hasFile('event_image')) {
|
||||
|
||||
$the_file = \File::get(Input::file('event_image')->getRealPath());
|
||||
$file_name = 'event_details_image-' . md5(microtime()) . '.' . strtolower(Input::file('event_image')->getClientOriginalExtension());
|
||||
|
||||
$relative_path_to_file = EVENT_IMAGES_PATH . '/' . $file_name;
|
||||
$full_path_to_file = public_path().'/'.$relative_path_to_file;
|
||||
|
||||
$img = Image::make($the_file);
|
||||
|
||||
$img->resize(1000, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
|
||||
$img->save($full_path_to_file);
|
||||
if(\Storage::put($file_name, $the_file)) {
|
||||
return Response::json([
|
||||
'link' => '/'.$relative_path_to_file
|
||||
]);
|
||||
}
|
||||
|
||||
return Response::json([
|
||||
'error' => 'There was a problem uploading your image.'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Event;
|
||||
use Response, Input, File, Image, Validator, View;
|
||||
|
||||
class EventCustomizeController extends MyBaseController {
|
||||
|
||||
public function showCustomize($event_id = '', $tab = '') {
|
||||
$data = $this->getEventViewData($event_id, [
|
||||
'available_bg_images' => $this->getAvailableBackgroundImages(),
|
||||
'available_bg_images_thumbs' => $this->getAvailableBackgroundImagesThumbs(),
|
||||
'tab' => $tab
|
||||
]);
|
||||
return View::make('ManageEvent.Customize', $data);
|
||||
}
|
||||
|
||||
public function getAvailableBackgroundImages() {
|
||||
|
||||
$images = [];
|
||||
|
||||
$files = File::files(public_path() . '/' . EVENT_BG_IMAGES);
|
||||
|
||||
foreach ($files as $image) {
|
||||
$images[] = str_replace(public_path(), '', $image);
|
||||
}
|
||||
|
||||
return $images;
|
||||
}
|
||||
|
||||
public function getAvailableBackgroundImagesThumbs() {
|
||||
|
||||
$images = [];
|
||||
|
||||
$files = File::files(public_path() . '/' . EVENT_BG_IMAGES.'/thumbs');
|
||||
|
||||
foreach ($files as $image) {
|
||||
$images[] = str_replace(public_path(), '', $image);
|
||||
}
|
||||
|
||||
return $images;
|
||||
}
|
||||
|
||||
public function postEditEventSocial($event_id) {
|
||||
$event = Event::scope()->findOrFail($event_id);
|
||||
|
||||
$rules = [
|
||||
'social_share_text' => ['max:3000'],
|
||||
'social_show_facebook' => ['boolean'],
|
||||
'social_show_twitter' => ['boolean'],
|
||||
'social_show_linkedin' => ['boolean'],
|
||||
'social_show_email' => ['boolean'],
|
||||
'social_show_googleplus' => ['boolean']
|
||||
];
|
||||
$messages = [
|
||||
'social_share_text.max' => 'Please keep the shate text under 3000 characters.',
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$event->social_share_text = Input::get('social_share_text');
|
||||
$event->social_show_facebook = Input::get('social_show_facebook');
|
||||
$event->social_show_linkedin = Input::get('social_show_linkedin');
|
||||
$event->social_show_twitter = Input::get('social_show_twitter');
|
||||
$event->social_show_email = Input::get('social_show_email');
|
||||
$event->social_show_googleplus = Input::get('social_show_googleplus');
|
||||
$event->save();
|
||||
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => 'Social Settings Succesfully Upated',
|
||||
]);
|
||||
}
|
||||
|
||||
public function postEditEventFees($event_id) {
|
||||
$event = Event::scope()->findOrFail($event_id);
|
||||
|
||||
$rules = [
|
||||
'organiser_fee_percentage' => ['numeric', 'between:0,100'],
|
||||
'organiser_fee_fixed' => ['numeric', 'between:0,100']
|
||||
];
|
||||
$messages = [
|
||||
'organiser_fee_percentage.numeric' => 'Please enter a value between 0 and 100',
|
||||
'organiser_fee_fixed.numeric' => 'Please check the format. It shoud be in the format 0.00.',
|
||||
'organiser_fee_fixed.between' => 'Please enter a value between 0 and 100.'
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$event->organiser_fee_percentage = Input::get('organiser_fee_percentage');
|
||||
$event->organiser_fee_fixed = Input::get('organiser_fee_fixed');
|
||||
$event->save();
|
||||
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => 'Order Page Succesfully Upated',
|
||||
]);
|
||||
}
|
||||
|
||||
public function postEditEventOrderPage($event_id) {
|
||||
$event = Event::scope()->findOrFail($event_id);
|
||||
|
||||
// Just plain text so no validation needed (hopefully)
|
||||
$rules = [];
|
||||
$messages = [];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$event->pre_order_display_message = trim(Input::get('pre_order_display_message'));
|
||||
$event->post_order_display_message = trim(Input::get('post_order_display_message'));
|
||||
$event->ask_for_all_attendees_info = (Input::get('ask_for_all_attendees_info') == 'on');
|
||||
$event->save();
|
||||
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => 'Order Page Succesfully Upated',
|
||||
]);
|
||||
}
|
||||
|
||||
public function postEditEventDesign($event_id) {
|
||||
|
||||
$event = Event::scope()->findOrFail($event_id);
|
||||
|
||||
$rules = [
|
||||
'bg_image_path' => ['mimes:jpeg,jpg,png', 'max:4000']
|
||||
];
|
||||
$messages = [
|
||||
'bg_image_path.mimes' => 'Please ensure you are uploading an image (JPG, PNG, JPEG)',
|
||||
'bg_image_path.max' => 'Pleae ensure the image is not larger than 2.5MB'
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
if (Input::get('bg_image_path_custom') && Input::get('bg_type') == 'image') {
|
||||
$event->bg_image_path = Input::get('bg_image_path_custom');
|
||||
$event->bg_type = 'image';
|
||||
}
|
||||
|
||||
if (Input::get('bg_color') && Input::get('bg_type') == 'color') {
|
||||
$event->bg_color = Input::get('bg_color');
|
||||
$event->bg_type = 'color';
|
||||
}
|
||||
|
||||
/*
|
||||
* Not in use for now.
|
||||
*/
|
||||
if (Input::hasFile('bg_image_path') && Input::get('bg_type') == 'custom_image') {
|
||||
|
||||
$path = public_path() . '/' . EVENT_IMAGES_PATH;
|
||||
$filename = 'event_bg-'. md5($event->id) . '.' . strtolower(Input::file('bg_image_path')->getClientOriginalExtension());
|
||||
|
||||
$file_full_path = $path . '/' . $filename;
|
||||
|
||||
|
||||
Input::file('bg_image_path')->move($path, $filename);
|
||||
|
||||
$img = Image::make($file_full_path);
|
||||
|
||||
$img->resize(1400, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
|
||||
$img->save($file_full_path, 75);
|
||||
|
||||
|
||||
$event->bg_image_path = EVENT_IMAGES_PATH . '/' . $filename;
|
||||
$event->bg_type = 'custom_image';
|
||||
|
||||
\Storage::put(EVENT_IMAGES_PATH.'/'.$filename, file_get_contents($file_full_path));
|
||||
}
|
||||
|
||||
$event->save();
|
||||
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => 'Event Page Succesfully Upated',
|
||||
'runThis' => 'document.getElementById(\'previewIframe\').contentWindow.location.reload(true);'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use View;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventStats;
|
||||
use DateTime, DatePeriod, DateInterval;
|
||||
|
||||
class EventDashboardController extends MyBaseController {
|
||||
|
||||
|
||||
function showDashboard($event_id = FALSE) {
|
||||
$event = Event::scope()->findOrFail($event_id);
|
||||
|
||||
$num_days= 20;
|
||||
|
||||
/**
|
||||
* This is a fairly hackish way to get the data for the dashboard charts. I'm sure someone
|
||||
* with better SQL skill could do it in one simple query.
|
||||
*
|
||||
* Filling in the missing days here seems to be fast(ish) (with 20 days history), but the work
|
||||
* should be done in the DB
|
||||
*/
|
||||
$chartData = EventStats::where('event_id', '=', $event->id)
|
||||
->where('date', '>', Carbon::now()->subDays($num_days)->format('Y-m-d'))
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
$startDate = new DateTime("-$num_days days");
|
||||
$dateItter = new DatePeriod(
|
||||
$startDate, new DateInterval('P1D'), $num_days
|
||||
);
|
||||
|
||||
$original = $chartData;
|
||||
|
||||
/*
|
||||
* I have no idea what I was doing here, but it seems to work;
|
||||
*/
|
||||
$result = array();
|
||||
$i = 0;
|
||||
foreach ($dateItter as $date) {
|
||||
$views = 0;
|
||||
$sales_volume = 0;
|
||||
$unique_views = 0;
|
||||
$tickets_sold = 0;
|
||||
$organiser_fees_volume = 0;
|
||||
|
||||
foreach ($original as $item) {
|
||||
if ($item['date'] == $date->format('Y-m-d')) {
|
||||
$views = $item['views'];
|
||||
$sales_volume = $item['sales_volume'];
|
||||
$organiser_fees_volume = $item['organiser_fees_volume'];
|
||||
$unique_views = $item['unique_views'];
|
||||
$tickets_sold = $item['tickets_sold'];
|
||||
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$result[] = array(
|
||||
"date" => $date->format('Y-m-d'),
|
||||
"views" => $views,
|
||||
'unique_views' => $unique_views,
|
||||
'sales_volume' => $sales_volume + $organiser_fees_volume,
|
||||
'tickets_sold' => $tickets_sold
|
||||
);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'event' => $event,
|
||||
'chartData' => json_encode($result)
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Dashboard', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $chartData
|
||||
* @param bool|FALSE $from_date
|
||||
* @param bool|FALSE $toDate
|
||||
* @return string
|
||||
*/
|
||||
public function generateChartJson($chartData, $from_date = FALSE, $toDate = FALSE) {
|
||||
|
||||
$data = [];
|
||||
|
||||
$startdate = '2014-10-1';
|
||||
$enddate = '2014-11-7';
|
||||
$timestamp = strtotime($startdate);
|
||||
while ($startdate <= $enddate) {
|
||||
|
||||
$startdate = date('Y-m-d', $timestamp);
|
||||
|
||||
$data[] = [
|
||||
'date' => $startdate,
|
||||
'tickets_sold' => rand(0, 7),
|
||||
'views' => rand(0, 5),
|
||||
'unique_views' => rand(0, 5)
|
||||
];
|
||||
|
||||
|
||||
$timestamp = strtotime('+1 days', strtotime($startdate));
|
||||
}
|
||||
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,345 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use DB,
|
||||
Response,
|
||||
Input,
|
||||
View,
|
||||
Exception,
|
||||
Validator,
|
||||
Log,
|
||||
Mail;
|
||||
use Excel;
|
||||
use Bugsnag;
|
||||
use Stripe,
|
||||
Stripe_Charge;
|
||||
use App\Models\Event;
|
||||
use App\Models\Order;
|
||||
use App\Models\Attendee;
|
||||
|
||||
class EventOrdersController extends MyBaseController
|
||||
{
|
||||
|
||||
public function showOrders($event_id = '')
|
||||
{
|
||||
|
||||
$allowed_sorts = ['first_name', 'email', 'order_reference', 'order_status_id', 'created_at'];
|
||||
|
||||
$searchQuery = Input::get('q');
|
||||
$sort_by = (in_array(Input::get('sort_by'), $allowed_sorts) ? Input::get('sort_by') : 'created_at');
|
||||
$sort_order = Input::get('sort_order') == 'asc' ? 'asc' : 'desc';
|
||||
|
||||
$event = Event::scope()->find($event_id);
|
||||
|
||||
if ($searchQuery) {
|
||||
|
||||
/*
|
||||
* Strip the hash from the start of the search term in case people search for
|
||||
* order references like '#EDGC67'
|
||||
*/
|
||||
if ($searchQuery[0] === '#') {
|
||||
$searchQuery = str_replace('#', '', $searchQuery);
|
||||
}
|
||||
|
||||
$orders = $event->orders()
|
||||
->where(function ($query) use ($searchQuery) {
|
||||
$query->where('order_reference', 'like', $searchQuery . '%')
|
||||
->orWhere('first_name', 'like', $searchQuery . '%')
|
||||
->orWhere('email', 'like', $searchQuery . '%')
|
||||
->orWhere('last_name', 'like', $searchQuery . '%');
|
||||
})
|
||||
->orderBy($sort_by, $sort_order)
|
||||
->paginate();
|
||||
} else {
|
||||
$orders = $event->orders()->orderBy($sort_by, $sort_order)->paginate();
|
||||
}
|
||||
|
||||
$data = [
|
||||
'orders' => $orders,
|
||||
'event' => $event,
|
||||
'sort_by' => $sort_by,
|
||||
'sort_order' => $sort_order,
|
||||
'q' => $searchQuery ? $searchQuery : ''
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Orders', $data);
|
||||
}
|
||||
|
||||
public function manageOrder($order_id)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'order' => Order::scope()->find($order_id),
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Modals.ManageOrder', $data);
|
||||
}
|
||||
|
||||
public function showCancelOrder($order_id)
|
||||
{
|
||||
$order = Order::scope()->find($order_id);
|
||||
|
||||
$data = [
|
||||
'order' => $order,
|
||||
'event' => $order->event(),
|
||||
'attendees' => $order->attendees()->withoutCancelled()->get(),
|
||||
'modal_id' => Input::get('modal_id')
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Modals.CancelOrder', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function postCancelOrder($order_id)
|
||||
{
|
||||
|
||||
$rules = [
|
||||
'refund_amount' => ['numeric']
|
||||
];
|
||||
$messages = [
|
||||
'refund_amount.integer' => 'Refund amount must only contain numbers.',
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$order = Order::scope()->findOrFail($order_id);
|
||||
$refund_order = (Input::get('refund_order') === 'on') ? TRUE : FALSE;
|
||||
$refund_type = Input::get('refund_type');
|
||||
$refund_amount = Input::get('refund_amount');
|
||||
$attendees = Input::get('attendees');
|
||||
$error_message = FALSE;
|
||||
|
||||
|
||||
if ($refund_order) {
|
||||
|
||||
if (!$order->transaction_id) {
|
||||
$error_message = 'Sorry, this order cannot be refunded.';
|
||||
}
|
||||
|
||||
if ($order->is_refunded) {
|
||||
$error_message = 'This order has already been refunded';
|
||||
} elseif ($order->amount == 0) {
|
||||
$error_message = 'Nothing to refund';
|
||||
} elseif ($refund_amount > ($order->amount - $order->amount_refunded)) {
|
||||
$error_message = 'The maximum amount you can refund is ' . (money($order->amount - $order->amount_refunded, $order->event->currency->code));
|
||||
}
|
||||
if (!$error_message) {
|
||||
try {
|
||||
|
||||
Stripe::setApiKey($order->account->stripe_api_key);
|
||||
$charge = Stripe_Charge::retrieve($order->transaction_id);
|
||||
|
||||
|
||||
if ($refund_type === 'full') { /* Full refund */
|
||||
|
||||
$refund_amount = $order->amount - $order->amount_refunded;
|
||||
$refund = $charge->refund([
|
||||
'refund_application_fee' => floatval($order->booking_fee) > 0 ? true : false
|
||||
]);
|
||||
|
||||
/* Update the event sales volume*/
|
||||
$order->event->decrement('sales_volume', $refund_amount);
|
||||
|
||||
$order->is_refunded = 1;
|
||||
$order->amount_refunded = $order->amount;
|
||||
$order->order_status_id = ORDER_REFUNDED;
|
||||
|
||||
|
||||
|
||||
} else { /* Partial refund */
|
||||
|
||||
$refund = $charge->refund([
|
||||
'amount' => $refund_amount * 100,
|
||||
'refund_application_fee' => floatval($order->booking_fee) > 0 ? true : false
|
||||
]);
|
||||
|
||||
/* Update the event sales volume*/
|
||||
$order->event->decrement('sales_volume', $refund_amount);
|
||||
|
||||
$order->order_status_id = ORDER_PARTIALLY_REFUNDED;
|
||||
|
||||
if (($order->organiser_amount - $order->amount_refunded) == 0) {
|
||||
$order->is_refunded = 1;
|
||||
$order->order_status_id = ORDER_REFUNDED;
|
||||
}
|
||||
|
||||
$order->is_partially_refunded = 1;
|
||||
}
|
||||
$order->amount_refunded = round($refund->amount_refunded / 100, 2);
|
||||
$order->save();
|
||||
|
||||
|
||||
} catch (\Stripe_InvalidRequestError $e) {
|
||||
Log::error($e);
|
||||
$error_message = 'There has been a problem processing your refund. Please check your information and try again.';
|
||||
} catch (\Stripe_AuthenticationError $e) {
|
||||
Log::error($e);
|
||||
$error_message = 'There has been a problem processing your refund. Please try again.';
|
||||
} catch (\Stripe_ApiConnectionError $e) {
|
||||
Log::error($e);
|
||||
$error_message = 'There has been a problem processing your refund. Please try again.';
|
||||
} catch (\Stripe_Error $e) {
|
||||
Log::error($e);
|
||||
$error_message = 'There has been a problem processing your refund. Please try again.';
|
||||
} catch (Exception $e) {
|
||||
Log::error($e);
|
||||
$error_message = 'There has been a problem processing your refund. Please try again.';
|
||||
}
|
||||
}
|
||||
|
||||
if ($error_message) {
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => $error_message
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Cancel the attendees
|
||||
*/
|
||||
if ($attendees) {
|
||||
foreach ($attendees as $attendee_id) {
|
||||
$attendee = Attendee::scope()->where('id', '=', $attendee_id)->first();
|
||||
$attendee->is_cancelled = 1;
|
||||
$attendee->save();
|
||||
}
|
||||
}
|
||||
|
||||
\Session::flash('message',
|
||||
(!$refund_amount && !$attendees) ? 'Nothing To Do' : "Successfully " . ($refund_order ? " Refunded Order" : " ") . ($attendees && $refund_order ? ' & ' : '') . ($attendees ? "Cancelled Attendee(s)" : ""));
|
||||
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'redirectUrl' => ''
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $event_id
|
||||
* @param string $export_as Accepted: xls, xlsx, csv, pdf, html
|
||||
*/
|
||||
public function showExportOrders($event_id, $export_as = 'xls')
|
||||
{
|
||||
|
||||
$event = Event::scope()->findOrFail($event_id);
|
||||
|
||||
Excel::create('orders-as-of-' . date('d-m-Y-g.i.a'), function ($excel) use ($event) {
|
||||
|
||||
$excel->setTitle('Orders For Event: ' . $event->title);
|
||||
|
||||
// Chain the setters
|
||||
$excel->setCreator(APP_NAME)
|
||||
->setCompany(APP_NAME);
|
||||
|
||||
$excel->sheet('orders_sheet_1', function ($sheet) use ($event) {
|
||||
|
||||
\DB::connection()->setFetchMode(\PDO::FETCH_ASSOC);
|
||||
$data = DB::table('orders')
|
||||
->where('orders.event_id', '=', $event->id)
|
||||
->where('orders.event_id', '=', $event->id)
|
||||
->select([
|
||||
'orders.first_name',
|
||||
'orders.last_name',
|
||||
'orders.email',
|
||||
'orders.order_reference',
|
||||
'orders.amount',
|
||||
\DB::raw("(CASE WHEN orders.is_refunded = 1 THEN 'YES' ELSE 'NO' END) AS `orders.is_refunded`"),
|
||||
\DB::raw("(CASE WHEN orders.is_partially_refunded = 1 THEN 'YES' ELSE 'NO' END) AS `orders.is_partially_refunded`"),
|
||||
'orders.amount_refunded',
|
||||
'orders.created_at'
|
||||
])->get();
|
||||
//DB::raw("(CASE WHEN UNIX_TIMESTAMP(`attendees.arrival_time`) = 0 THEN '---' ELSE 'd' END) AS `attendees.arrival_time`"))
|
||||
|
||||
$sheet->fromArray($data);
|
||||
|
||||
$sheet->row(1, array(
|
||||
'First Name', 'Last Name', 'Email', 'Order Reference', 'Amount', 'Fully Refunded', 'Partially Refunded', 'Amount Refunded', 'Order Date'
|
||||
));
|
||||
|
||||
// Set gray background on first row
|
||||
$sheet->row(1, function ($row) {
|
||||
$row->setBackground('#f5f5f5');
|
||||
});
|
||||
});
|
||||
})->export($export_as);
|
||||
}
|
||||
|
||||
public function showMessageOrder($order_id)
|
||||
{
|
||||
|
||||
$order = Order::scope()->findOrFail($order_id);
|
||||
|
||||
$data = [
|
||||
'order' => $order,
|
||||
'event' => $order->event,
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Modals.MessageOrder', $data);
|
||||
}
|
||||
|
||||
public function postMessageOrder($order_id)
|
||||
{
|
||||
|
||||
$rules = [
|
||||
'subject' => 'required|max:250',
|
||||
'message' => 'required|max:5000'
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$order = Attendee::scope()->findOrFail($order_id);
|
||||
|
||||
$data = [
|
||||
'order' => $order,
|
||||
'message_content' => Input::get('message'),
|
||||
'subject' => Input::get('subject'),
|
||||
'event' => $order->event,
|
||||
'email_logo' => $order->event->organiser->full_logo_path
|
||||
];
|
||||
|
||||
Mail::send('Emails.messageOrder', $data, function ($message) use ($order, $data) {
|
||||
$message->to($order->email, $order->full_name)
|
||||
->from(OUTGOING_EMAIL_NOREPLY, $order->event->organiser->name)
|
||||
->replyTo($order->event->organiser->email, $order->event->organiser->name)
|
||||
->subject($data['subject']);
|
||||
});
|
||||
|
||||
/* Could bcc in the above? */
|
||||
if (Input::get('send_copy') == '1') {
|
||||
Mail::send('Emails.messageOrder', $data, function ($message) use ($order, $data) {
|
||||
$message->to($order->event->organiser->email)
|
||||
->from(OUTGOING_EMAIL_NOREPLY, $order->event->organiser->name)
|
||||
->replyTo($order->event->organiser->email, $order->event->organiser->name)
|
||||
->subject($data['subject'] . ' [Organiser copy]');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'message' => 'Message Successfully Sent'
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
class EventPromoteController extends MyBaseController {
|
||||
|
||||
public function showPromote($event_id) {
|
||||
|
||||
$data = [
|
||||
'event' => Event::scope()->find($event_id)
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Promote', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
class EventTicketQuestionsController extends MyBaseController {
|
||||
|
||||
|
||||
public function showQuestions($event_id) {
|
||||
|
||||
$data = [
|
||||
'event' => Event::scope()->findOrFail($event_id),
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
'question_types' => QuestionType::all()
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Modals.ViewQuestions', $data);
|
||||
}
|
||||
|
||||
|
||||
public function postCreateQuestion($event_id) {
|
||||
|
||||
$event = Event::findOrFail($event_id);
|
||||
|
||||
$question = Question::createNew(FALSE, FALSE, TRUE);
|
||||
$question->title = Input::get('title');
|
||||
$question->instructions = Input::get('instructions');
|
||||
$question->options = Input::get('options');
|
||||
$question->is_required = Input::get('title');
|
||||
$question->question_type_id = Input::get('question_type_id');
|
||||
$question->save();
|
||||
|
||||
|
||||
|
||||
$ticket_ids = Input::get('tickets');
|
||||
|
||||
foreach($ticket_ids as $ticket_id) {
|
||||
Ticket::scope()->find($ticket_id)->questions()->attach($question->id);
|
||||
}
|
||||
|
||||
$event->questions()->attach($question->id);
|
||||
|
||||
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => 'Successfully Created Question'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Input, View, Response, Log;
|
||||
use App\Models\Event;
|
||||
use App\Models\Ticket;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
class EventTicketsController extends MyBaseController {
|
||||
|
||||
public function showTickets($event_id) {
|
||||
|
||||
$allowed_sorts = ['created_at', 'quantity_sold', 'sales_volume', 'title'];
|
||||
|
||||
$searchQuery = Input::get('q');
|
||||
$sort_by = (in_array(Input::get('sort_by'), $allowed_sorts) ? Input::get('sort_by') : 'created_at');
|
||||
|
||||
|
||||
$event = Event::scope()->findOrFail($event_id);
|
||||
|
||||
$tickets = $searchQuery
|
||||
? $event->tickets()->where('title', 'like', '%' . $searchQuery . '%')->orderBy($sort_by, 'desc')->paginate(10)
|
||||
: $event->tickets()->orderBy($sort_by, 'desc')->paginate(10);
|
||||
|
||||
|
||||
$data = [
|
||||
'event' => $event,
|
||||
'tickets' => $tickets,
|
||||
'sort_by' => $sort_by,
|
||||
'q' => $searchQuery ? $searchQuery : ''
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Tickets', $data);
|
||||
}
|
||||
|
||||
public function showEditTicket($event_id, $ticket_id) {
|
||||
|
||||
$data = [
|
||||
'event' => Event::scope()->find($event_id),
|
||||
'ticket' => Ticket::scope()->find($ticket_id),
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
];
|
||||
|
||||
return View::make('ManageEvent.Modals.EditTicket', $data);
|
||||
}
|
||||
|
||||
public function showCreateTicket($event_id) {
|
||||
return View::make('ManageEvent.Modals.CreateTicket', array(
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
'event' => Event::find($event_id)
|
||||
));
|
||||
}
|
||||
|
||||
public function postCreateTicket($event_id) {
|
||||
|
||||
$ticket = Ticket::createNew();
|
||||
|
||||
if (!$ticket->validate(Input::all())) {
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $ticket->errors()
|
||||
));
|
||||
}
|
||||
|
||||
$ticket->event_id = $event_id;
|
||||
$ticket->title = Input::get('title');
|
||||
$ticket->quantity_available = !Input::get('quantity_available') ? NULL : Input::get('quantity_available');
|
||||
$ticket->start_sale_date = Input::get('start_sale_date') ? Carbon::createFromFormat('d-m-Y H:i', Input::get('start_sale_date')) : NULL;
|
||||
$ticket->end_sale_date = Input::get('end_sale_date') ? Carbon::createFromFormat('d-m-Y H:i', Input::get('end_sale_date')) : NULL;
|
||||
$ticket->price = Input::get('price');
|
||||
$ticket->min_per_person = Input::get('min_per_person');
|
||||
$ticket->max_per_person = Input::get('max_per_person');
|
||||
$ticket->description = Input::get('description');
|
||||
$ticket->save();
|
||||
|
||||
\Session::flash('message', 'Successfully Created Ticket');
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'id' => $ticket->id,
|
||||
'message' => 'Refreshing...',
|
||||
'redirectUrl' => route('showEventTickets', array(
|
||||
'event_id' => $event_id
|
||||
))
|
||||
));
|
||||
}
|
||||
|
||||
public function postPauseTicket() {
|
||||
$ticket_id = Input::get('ticket_id');
|
||||
|
||||
$ticket = Ticket::scope()->find($ticket_id);
|
||||
|
||||
$ticket->is_paused = ($ticket->is_paused == 1) ? 0 : 1;
|
||||
|
||||
if ($ticket->save()) {
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => 'Ticket Successfully Updated',
|
||||
'id' => $ticket->id
|
||||
]);
|
||||
}
|
||||
|
||||
Log::error('Ticket Failed to pause/resume', [
|
||||
'ticket' => $ticket
|
||||
]);
|
||||
|
||||
return Response::json([
|
||||
'status' => 'error',
|
||||
'id' => $ticket->id,
|
||||
'message' => 'Whoops!, looks like something went wrong. Please try again.'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function postDeleteTicket() {
|
||||
|
||||
$ticket_id = Input::get('ticket_id');
|
||||
|
||||
$ticket = Ticket::scope()->find($ticket_id);
|
||||
|
||||
if ($ticket->quantity_sold > 0) {
|
||||
return Response::json([
|
||||
'status' => 'error',
|
||||
'message' => 'Sorry, you can\'t delete this ticket as some have already been sold',
|
||||
'id' => $ticket->id
|
||||
]);
|
||||
}
|
||||
|
||||
if ($ticket->delete()) {
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => 'Ticket Successfully Deleted',
|
||||
'id' => $ticket->id
|
||||
]);
|
||||
}
|
||||
|
||||
Log::error('Ticket Failed to delete', [
|
||||
'ticket' => $ticket
|
||||
]);
|
||||
|
||||
return Response::json([
|
||||
'status' => 'error',
|
||||
'id' => $ticket->id,
|
||||
'message' => 'Whoops!, looks like something went wrong. Please try again.'
|
||||
]);
|
||||
}
|
||||
|
||||
public function postEditTicket($event_id, $ticket_id) {
|
||||
|
||||
$ticket = Ticket::findOrFail($ticket_id);
|
||||
|
||||
/*
|
||||
* Override some vaidation rules
|
||||
*/
|
||||
$validation_rules['quantity_available'] = ['integer','min:'.($ticket->quantity_sold + $ticket->quantity_reserved)];
|
||||
$validation_messages['quantity_available.min'] = 'Quantity available can\'t be less the amount sold or reserved.';
|
||||
|
||||
$ticket->rules = $validation_rules + $ticket->rules;
|
||||
$ticket->messages = $validation_messages + $ticket->messages;
|
||||
|
||||
|
||||
if (!$ticket->validate(Input::all())) {
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $ticket->errors()
|
||||
));
|
||||
}
|
||||
|
||||
$ticket->title = Input::get('title');
|
||||
$ticket->quantity_available = !Input::get('quantity_available') ? NULL : Input::get('quantity_available');
|
||||
$ticket->price = Input::get('price');
|
||||
$ticket->start_sale_date = Input::get('start_sale_date') ? Carbon::createFromFormat('d-m-Y H:i', Input::get('start_sale_date')) : NULL;
|
||||
$ticket->end_sale_date = Input::get('end_sale_date') ? Carbon::createFromFormat('d-m-Y H:i', Input::get('end_sale_date')) : NULL;
|
||||
$ticket->description = Input::get('description');
|
||||
$ticket->min_per_person = Input::get('min_per_person');
|
||||
$ticket->max_per_person = Input::get('max_per_person');
|
||||
|
||||
|
||||
$ticket->save();
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'id' => $ticket->id,
|
||||
'message' => 'Refreshing...',
|
||||
'redirectUrl' => route('showEventTickets', array(
|
||||
'event_id' => $event_id
|
||||
))
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Input, View, Cookie, Mail, Validator, Response, Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Event;
|
||||
use App\Models\Affiliate;
|
||||
use App\Models\EventStats;
|
||||
|
||||
|
||||
class EventViewController extends Controller
|
||||
{
|
||||
|
||||
public function showEventHome($event_id, $slug = '', $preview = FALSE)
|
||||
{
|
||||
|
||||
$event = Event::findOrFail($event_id);
|
||||
|
||||
if(!Auth::check() && !$event->is_live) {
|
||||
return View::make('Public.ViewEvent.EventNotLivePage');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'event' => $event,
|
||||
'tickets' => $event->tickets()->orderBy('created_at', 'desc')->get(),
|
||||
'is_embedded' => 0
|
||||
];
|
||||
/*
|
||||
* Don't record stats if we're previewing the event page from the backend or if we own the event.
|
||||
*/
|
||||
if (!$preview || !Auth::check()) {
|
||||
|
||||
$event_stats = new EventStats;
|
||||
$event_stats->updateViewCount($event_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* See if there is an affiliate referral in the URL
|
||||
*/
|
||||
if ($affiliate_ref = \Input::get('ref')) {
|
||||
|
||||
$affiliate_ref = preg_replace("/\W|_/", '', $affiliate_ref);
|
||||
|
||||
if ($affiliate_ref) {
|
||||
$affiliate = Affiliate::firstOrNew([
|
||||
'name' => Input::get('ref'),
|
||||
'event_id' => $event_id,
|
||||
'account_id' => $event->account_id,
|
||||
]);
|
||||
|
||||
++$affiliate->visits;
|
||||
|
||||
$affiliate->save();
|
||||
|
||||
Cookie::queue('affiliate_' . $event_id, $affiliate_ref, 60 * 24 * 60);
|
||||
}
|
||||
}
|
||||
|
||||
return View::make('Public.ViewEvent.EventPage', $data);
|
||||
}
|
||||
|
||||
public function showEventHomePreview($event_id)
|
||||
{
|
||||
return showEventHome($event_id, TRUE);
|
||||
}
|
||||
|
||||
|
||||
public function postContactOrganiser($event_id)
|
||||
{
|
||||
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
'email' => ['required', 'email'],
|
||||
'message' => ['required']
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $validator->messages()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
$event = Event::findOrFail($event_id);
|
||||
|
||||
$data = [
|
||||
'sender_name' => Input::get('name'),
|
||||
'sender_email' => Input::get('email'),
|
||||
'message_content' => strip_tags(Input::get('message')),
|
||||
'event' => $event
|
||||
];
|
||||
|
||||
Mail::send('Emails.messageOrganiser', $data, function ($message) use ($event, $data) {
|
||||
$message->to($event->organiser->email, $event->organiser->name)
|
||||
->from(OUTGOING_EMAIL_NOREPLY, $data['sender_name'])
|
||||
->replyTo($data['sender_email'], $data['sender_name'])
|
||||
->subject('Message Regarding: ' . $event->title);
|
||||
});
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'message' => 'Message Successfully Sent'
|
||||
));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use View;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Event;
|
||||
|
||||
|
||||
class EventViewEmbeddedController extends Controller {
|
||||
|
||||
public function showEmbeddedEvent($event_id) {
|
||||
|
||||
$event = Event::findOrFail($event_id);
|
||||
|
||||
$data = [
|
||||
'event' => $event,
|
||||
'tickets' => $event->tickets()->orderBy('created_at', 'desc')->get(),
|
||||
'is_embedded' => '1'
|
||||
];
|
||||
|
||||
return View::make('Public.ViewEvent.Embedded.EventPage', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ImageController extends Controller {
|
||||
|
||||
public function generateThumbnail($image_src, $width = FALSE, $height = false, $quality = 90) {
|
||||
$img = Image::make('public/foo.jpg');
|
||||
|
||||
$img->resize(320, 240);
|
||||
|
||||
$img->insert('public/watermark.png');
|
||||
|
||||
$img->save('public/bar.jpg');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\Timezone;
|
||||
use View;
|
||||
use Response;
|
||||
use Config;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Artisan;
|
||||
use DB;
|
||||
use File;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
|
||||
class InstallerController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
set_time_limit(300);
|
||||
}
|
||||
|
||||
public function showInstaller()
|
||||
{
|
||||
$data['paths'] = [
|
||||
storage_path('app'),
|
||||
storage_path('framework'),
|
||||
storage_path('logs'),
|
||||
public_path('user_content'),
|
||||
base_path('.env')
|
||||
];
|
||||
$data['requirements'] = [
|
||||
'openssl',
|
||||
'pdo',
|
||||
'mbstring',
|
||||
'fileinfo',
|
||||
'tokenizer',
|
||||
];
|
||||
|
||||
return View::make('Installer.Installer', $data);
|
||||
}
|
||||
|
||||
public function postInstaller()
|
||||
{
|
||||
|
||||
$database['type'] = 'mysql';
|
||||
$database['host'] = Input::get('database_host');
|
||||
$database['name'] = Input::get('database_name');
|
||||
$database['username'] = Input::get('database_username');
|
||||
$database['password'] = Input::get('database_password');
|
||||
|
||||
$mail['driver'] = Input::get('mail_driver');
|
||||
$mail['port'] = Input::get('mail_port');
|
||||
$mail['username'] = Input::get('mail_username');
|
||||
$mail['password'] = Input::get('mail_password');
|
||||
$mail['encryption'] = Input::get('mail_encryption');
|
||||
$mail['from_address'] = Input::get('mail_from_address');
|
||||
$mail['from_name'] = Input::get('mail_from_name');
|
||||
$mail['host'] = Input::get('mail_host');
|
||||
|
||||
$app_url = Input::get('app_url');
|
||||
$app_key = str_random(16);
|
||||
|
||||
|
||||
if (Input::get('test') === 'db') {
|
||||
|
||||
$is_db_valid = self::testDatabase($database);
|
||||
|
||||
if ($is_db_valid === 'yes') {
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => 'Success, Your connection works!',
|
||||
'test' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
return Response::json([
|
||||
'status' => 'error',
|
||||
'message' => 'Unable to connect! Please check your settings',
|
||||
'test' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$config = "APP_ENV=production\n" .
|
||||
"APP_DEBUG=false\n" .
|
||||
"APP_URL={$app_url}\n" .
|
||||
"APP_KEY={$app_key}\n\n" .
|
||||
"DB_TYPE=mysql\n" .
|
||||
"DB_HOST={$database['host']}\n" .
|
||||
"DB_DATABASE={$database['name']}\n" .
|
||||
"DB_USERNAME={$database['username']}\n" .
|
||||
"DB_PASSWORD={$database['password']}\n\n" .
|
||||
"MAIL_DRIVER={$mail['driver']}\n" .
|
||||
"MAIL_PORT={$mail['port']}\n" .
|
||||
"MAIL_ENCRYPTION={$mail['encryption']}\n" .
|
||||
"MAIL_HOST={$mail['host']}\n" .
|
||||
"MAIL_USERNAME={$mail['username']}\n" .
|
||||
"MAIL_FROM_NAME={$mail['from_name']}\n" .
|
||||
"MAIL_FROM_ADDRESS={$mail['from_address']}\n" .
|
||||
"MAIL_PASSWORD={$mail['password']}\n\n";
|
||||
|
||||
$fp = fopen(base_path()."/.env", 'w');
|
||||
fwrite($fp, $config);
|
||||
fclose($fp);
|
||||
|
||||
Artisan::call('migrate', array('--force' => true));
|
||||
if (Timezone::count() == 0) {
|
||||
Artisan::call('db:seed', array('--force' => true));
|
||||
}
|
||||
Artisan::call('optimize', array('--force' => true));
|
||||
|
||||
return Redirect::route('signup',['first_run' => 'yup']);
|
||||
}
|
||||
|
||||
|
||||
private function testDatabase($database)
|
||||
{
|
||||
Config::set('database.default', $database['type']);
|
||||
Config::set("database.connections.mysql.host", $database['host']);
|
||||
Config::set("database.connections.mysql.database", $database['name']);
|
||||
Config::set("database.connections.mysql.username", $database['username']);
|
||||
Config::set("database.connections.mysql.password", $database['password']);
|
||||
|
||||
try {
|
||||
DB::reconnect();
|
||||
$success = DB::connection()->getDatabaseName() ? 'yes' : 'no';
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Input,
|
||||
Response,
|
||||
View,
|
||||
Auth;
|
||||
use HttpClient;
|
||||
use App\Models\Account;
|
||||
use App\Models\Timezone;
|
||||
use App\Models\Currency;
|
||||
use App\Models\User;
|
||||
|
||||
|
||||
class ManageAccountController extends MyBaseController {
|
||||
|
||||
public function showEditAccount() {
|
||||
|
||||
$data = [
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
'account' => Account::find(Auth::user()->account_id),
|
||||
'timezones' => Timezone::lists('location', 'id'),
|
||||
'currencies' => Currency::lists('title', 'id')
|
||||
];
|
||||
|
||||
return View::make('ManageAccount.Modals.EditAccount', $data);
|
||||
}
|
||||
|
||||
public function showStripeReturn() {
|
||||
|
||||
$error_message = "There was an error connecting your Stripe account. Please try again.";
|
||||
|
||||
if (Input::get('error') || !Input::get('code')) {
|
||||
//BugSnag::notifyError('Error Connecting to Stripe', Input::get('error'));
|
||||
\Session::flash('message', $error_message);
|
||||
|
||||
return redirect()->route('showEventsDashboard');
|
||||
}
|
||||
|
||||
$request = [
|
||||
'url' => 'https://connect.stripe.com/oauth/token',
|
||||
'params' => [
|
||||
|
||||
'client_secret' => STRIPE_SECRET_KEY, //sk_test_iXk2Ky0DlhIcTcKMvsDa8iKI',
|
||||
'code' => Input::get('code'),
|
||||
'grant_type' => 'authorization_code'
|
||||
]
|
||||
];
|
||||
|
||||
$response = HttpClient::post($request);
|
||||
|
||||
$content = $response->json();
|
||||
|
||||
if(isset($content->error) || !isset($content->access_token)) {
|
||||
//BugSnag::notifyError('Error Connecting to Stripe', Input::get('error'));
|
||||
\Session::flash('message', $error_message);
|
||||
|
||||
return redirect()->route('showEventsDashboard');
|
||||
}
|
||||
|
||||
$account = Account::find(\Auth::user()->account_id);
|
||||
$account->stripe_access_token = $content->access_token;
|
||||
$account->stripe_refresh_token = $content->refresh_token;
|
||||
$account->stripe_publishable_key = $content->stripe_publishable_key;
|
||||
$account->stripe_data_raw = json_encode($content);
|
||||
$account->save();
|
||||
|
||||
\Session::flash('message', "You have successfully connected your Stripe account.");
|
||||
return redirect()->route('showEventsDashboard');
|
||||
}
|
||||
|
||||
public function postEditAccount() {
|
||||
$account = Account::find(Auth::user()->account_id);
|
||||
|
||||
if (!$account->validate(Input::all())) {
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $account->errors()
|
||||
));
|
||||
}
|
||||
|
||||
$account->first_name = Input::get('first_name');
|
||||
$account->last_name = Input::get('last_name');
|
||||
$account->email = Input::get('email');
|
||||
$account->timezone_id = Input::get('timezone_id');
|
||||
$account->currency_id = Input::get('currency_id');
|
||||
$account->save();
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'id' => $account->id,
|
||||
'message' => 'Account Successfully Updated'
|
||||
));
|
||||
}
|
||||
|
||||
public function postEditAccountPayment() {
|
||||
$account = Account::find(Auth::user()->account_id);
|
||||
|
||||
$account->stripe_publishable_key = Input::get('stripe_publishable_key');
|
||||
$account->stripe_secret_key = Input::get('stripe_secret_key');
|
||||
|
||||
$account->save();
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'id' => $account->id,
|
||||
'message' => 'Payment Information Successfully Updated'
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function postInviteUser() {
|
||||
$rules = array(
|
||||
'email' => array('required', 'email', 'unique:users,email,NULL,id,account_id,'.Auth::user()->account_id),
|
||||
);
|
||||
|
||||
$messages = array(
|
||||
'email.email' => 'Please enter a valid E-mail address.',
|
||||
'email.required' => 'E-mail address is required.',
|
||||
'email.unique' => 'E-mail already in use for this account.',
|
||||
);
|
||||
|
||||
$validation = \Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validation->fails()) {
|
||||
return \Response::json([
|
||||
'status' => 'error',
|
||||
'messages'=> $validation->messages()->toArray()
|
||||
]);
|
||||
}
|
||||
|
||||
$temp_password = str_random(8);
|
||||
|
||||
$user = new User;
|
||||
$user->email = Input::get('email');
|
||||
$user->password = \Hash::make($temp_password);
|
||||
$user->account_id = Auth::user()->account_id;
|
||||
$user->save();
|
||||
|
||||
$data = [
|
||||
'user' => $user,
|
||||
'temp_password' => $temp_password,
|
||||
'inviter' => Auth::user()
|
||||
];
|
||||
|
||||
\Mail::send('Emails.inviteUser', $data, function($message) use ($data) {
|
||||
$message->to($data['user']->email)
|
||||
->subject($data['inviter']->first_name.' '.$data['inviter']->last_name.' added you to an Attendize Ticketing account.');
|
||||
});
|
||||
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message'=> 'Success! <b>'.$user->email.'</b> has been sent further instructions.'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Attendize\Utils;
|
||||
use App\Models\Organiser;
|
||||
use View;
|
||||
|
||||
class MyBaseController extends Controller {
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
View::share('organisers', Organiser::scope()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the layout used by the controller.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setupLayout() {
|
||||
if (!is_null($this->layout)) {
|
||||
$this->layout = View::make($this->layout);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data which is required in each view, optionally combined with additional data.
|
||||
*
|
||||
* @param int $event_id
|
||||
* @param array $additional_data
|
||||
* @return arrau
|
||||
*/
|
||||
public function getEventViewData($event_id, $additional_data = array()) {
|
||||
return array_merge(array(
|
||||
'event' => Event::scope()->findOrFail($event_id)
|
||||
)
|
||||
, $additional_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Response,
|
||||
Input,
|
||||
Image,
|
||||
View;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\Organiser;
|
||||
|
||||
class OrganiserController extends MyBaseController {
|
||||
|
||||
public function showSelectOragniser() {
|
||||
return View::make('ManageOrganiser.SelectOrganiser');
|
||||
}
|
||||
|
||||
public function showOrganiserDashboard($organiser_id = FALSE) {
|
||||
|
||||
$allowed_sorts = ['created_at', 'start_date', 'end_date', 'title'];
|
||||
|
||||
$searchQuery = Input::get('q');
|
||||
//$sort_order = Input::get('sort_order') == 'asc' ? 'asc' : 'desc';
|
||||
$sort_by = (in_array(Input::get('sort_by'), $allowed_sorts) ? Input::get('sort_by') : 'start_date');
|
||||
|
||||
$events = $searchQuery
|
||||
? Event::scope()->where('title', 'like', '%' . $searchQuery . '%')->orderBy($sort_by, 'desc')->where('organiser_id', '=', $organiser_id)->paginate(12)
|
||||
: Event::scope()->where('organiser_id', '=', $organiser_id)->orderBy($sort_by, 'desc')->paginate(12);
|
||||
|
||||
|
||||
$data = [
|
||||
'events' => $events,
|
||||
'organisers' => Organiser::scope()->orderBy('name')->get(),
|
||||
'current_organiser' => Organiser::scope()->find($organiser_id),
|
||||
'q' => $searchQuery ? $searchQuery : '', //Redundant
|
||||
'search' => [
|
||||
'q' => $searchQuery ? $searchQuery : '',
|
||||
'sort_by' => $sort_by,
|
||||
'showPast' => Input::get('past')
|
||||
]
|
||||
];
|
||||
|
||||
return View::make('ManageEvents.OrganiserDashboard', $data);
|
||||
}
|
||||
|
||||
|
||||
public function showEditOrganiser($organiser_id) {
|
||||
|
||||
$organiser = Organiser::scope()->findOrfail($organiser_id);
|
||||
|
||||
return View::make('ManageEvents.Modals.EditOrganiser', [
|
||||
'modal_id' => Input::get('modal_id'),
|
||||
'organiser' => $organiser
|
||||
]);
|
||||
}
|
||||
|
||||
public function showCreateOrganiser() {
|
||||
|
||||
return View::make('ManageOrganiser.CreateOrganiser', [
|
||||
'modal_id' => 'createOrganiser'
|
||||
]);
|
||||
|
||||
return View::make('ManageEvents.Modals.CreateOrganiser', [
|
||||
'modal_id' => Input::get('modal_id')
|
||||
]);
|
||||
}
|
||||
|
||||
public function postCreateOrganiser() {
|
||||
$organiser = Organiser::createNew(FALSE, FALSE, TRUE);
|
||||
|
||||
if (!$organiser->validate(Input::all())) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $organiser->errors()
|
||||
));
|
||||
}
|
||||
|
||||
$organiser->name = Input::get('name');
|
||||
$organiser->about = Input::get('about');
|
||||
$organiser->email = Input::get('email');
|
||||
$organiser->facebook = Input::get('facebook');
|
||||
$organiser->twitter = Input::get('twitter');
|
||||
$organiser->confirmation_key = md5(time().rand(0,999999));
|
||||
|
||||
if (Input::hasFile('organiser_logo')) {
|
||||
|
||||
$path = public_path() . '/' . ORGANISER_IMAGES_PATH;
|
||||
$filename = 'organiser_logo-' . $organiser->id . '.' . strtolower(Input::file('organiser_logo')->getClientOriginalExtension());
|
||||
|
||||
$file_full_path = $path . '/' . $filename;
|
||||
|
||||
Input::file('organiser_logo')->move($path, $filename);
|
||||
|
||||
$img = Image::make($file_full_path);
|
||||
|
||||
$img->resize(250, 250, function ($constraint) {
|
||||
//$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
|
||||
$img->save($file_full_path);
|
||||
|
||||
if(file_exists($file_full_path)) {
|
||||
$organiser->logo_path = ORGANISER_IMAGES_PATH . '/' . $filename;
|
||||
}
|
||||
|
||||
}
|
||||
$organiser->save();
|
||||
|
||||
\Session::flash('message', 'Successfully Created Organiser');
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'message' => 'Refreshing..',
|
||||
'redirectUrl' => route('showOrganiserDashboard', [
|
||||
'organiser_id' => $organiser->id
|
||||
])
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Input;
|
||||
use View;
|
||||
use Session;
|
||||
use Response;
|
||||
use File;
|
||||
use Storage;
|
||||
use Image;
|
||||
use App\Models\Organiser;
|
||||
use App\Models\Event;
|
||||
|
||||
class OrganiserCustomizeController extends MyBaseController
|
||||
{
|
||||
|
||||
public function showCustomize($organiser_id) {
|
||||
|
||||
$data = [
|
||||
'organiser' => Organiser::scope()->findOrFail($organiser_id)
|
||||
];
|
||||
|
||||
return View::make('ManageOrganiser.Customize', $data);
|
||||
}
|
||||
|
||||
public function postEditOrganiser($organiser_id) {
|
||||
$organiser = Organiser::scope()->find($organiser_id);
|
||||
|
||||
if (!$organiser->validate(Input::all())) {
|
||||
return Response::json(array(
|
||||
'status' => 'error',
|
||||
'messages' => $organiser->errors()
|
||||
));
|
||||
}
|
||||
|
||||
$organiser->name = Input::get('name');
|
||||
$organiser->about = Input::get('about');
|
||||
$organiser->email = Input::get('email');
|
||||
$organiser->facebook = Input::get('facebook');
|
||||
$organiser->twitter = Input::get('twitter');
|
||||
|
||||
/*
|
||||
* If the email has been changed the user must confirm the email.
|
||||
*/
|
||||
if($organiser->email !== Input::get('email')) {
|
||||
$organiser->is_email_confirmed = 0;
|
||||
}
|
||||
|
||||
if (Input::get('remove_current_image') == '1') {
|
||||
$organiser->logo_path = '';
|
||||
}
|
||||
|
||||
if (Input::hasFile('organiser_logo') ) {
|
||||
|
||||
$the_file = \File::get(Input::file('organiser_logo')->getRealPath());
|
||||
$file_name = '123-test-organiser_logo-' . $organiser->id . '.' . strtolower(Input::file('organiser_logo')->getClientOriginalExtension());
|
||||
|
||||
$relative_path_to_file = ORGANISER_IMAGES_PATH . '/' . $file_name;
|
||||
$full_path_to_file = public_path().'/'.$relative_path_to_file;
|
||||
|
||||
$img = Image::make($the_file);
|
||||
|
||||
$img->resize(200, 200, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
|
||||
$img->save($full_path_to_file);
|
||||
|
||||
if(\Storage::put($file_name, $the_file)) {
|
||||
$organiser->logo_path = $relative_path_to_file;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$organiser->save();
|
||||
|
||||
Session::flash('message', 'Successfully Updated Organiser');
|
||||
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'redirectUrl' => route('showOrganiserCustomize', [
|
||||
'organiser_id' => $organiser->id
|
||||
])
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Organiser;
|
||||
use App\Models\Event;
|
||||
use App\Models\Attendee;
|
||||
use View;
|
||||
use Carbon\Carbon;
|
||||
use Input;
|
||||
|
||||
|
||||
class OrganiserDashboardController extends MyBaseController
|
||||
{
|
||||
|
||||
|
||||
public function showDashboard($organiser_id)
|
||||
{
|
||||
|
||||
$organiser = Organiser::scope()->findOrFail($organiser_id);
|
||||
$upcoming_events = $organiser->events()->where('end_date', '>=', Carbon::now())->get();
|
||||
|
||||
$data = [
|
||||
'organiser' => $organiser,
|
||||
'upcoming_events' => $upcoming_events,
|
||||
'search' => [
|
||||
'sort_by' => 's',
|
||||
'q' => ''
|
||||
],
|
||||
'q'=> 'dd'
|
||||
];
|
||||
|
||||
return View::make('ManageOrganiser.Dashboard', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Input;
|
||||
use View;
|
||||
use App\Models\Organiser;
|
||||
use App\Models\Event;
|
||||
|
||||
class OrganiserEventsController extends MyBaseController
|
||||
{
|
||||
|
||||
public function showEvents($organiser_id) {
|
||||
|
||||
$organiser = Organiser::scope()->findOrfail($organiser_id);
|
||||
|
||||
$allowed_sorts = ['created_at', 'start_date', 'end_date', 'title'];
|
||||
|
||||
$searchQuery = Input::get('q');
|
||||
$sort_by = (in_array(Input::get('sort_by'), $allowed_sorts) ? Input::get('sort_by') : 'start_date');
|
||||
|
||||
$events = $searchQuery
|
||||
? Event::scope()->where('title', 'like', '%' . $searchQuery . '%')->orderBy($sort_by, 'desc')->where('organiser_id', '=', $organiser_id)->paginate(12)
|
||||
: Event::scope()->where('organiser_id', '=', $organiser_id)->orderBy($sort_by, 'desc')->paginate(12);
|
||||
|
||||
|
||||
$data = [
|
||||
'events' => $events,
|
||||
'organiser' => $organiser,
|
||||
'search' => [
|
||||
'q' => $searchQuery ? $searchQuery : '',
|
||||
'sort_by' => Input::get('sort_by') ? Input::get('sort_by') : '',
|
||||
'showPast' => Input::get('past')
|
||||
]
|
||||
];
|
||||
|
||||
return View::make('ManageOrganiser.Events', $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use View;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Organiser;
|
||||
|
||||
|
||||
class OrganiserViewController extends Controller {
|
||||
|
||||
public function showOrganiserHome($organiser_id, $slug='', $preview = FALSE) {
|
||||
|
||||
$organiser = Organiser::findOrFail($organiser_id);
|
||||
|
||||
$data = [
|
||||
'organiser' => $organiser,
|
||||
'tickets' => $organiser->events()->orderBy('created_at', 'desc')->get(),
|
||||
'is_embedded' => 0
|
||||
];
|
||||
|
||||
return View::make('Public.ViewOrganiser.OrganiserPage', $data);
|
||||
}
|
||||
|
||||
public function showEventHomePreview($event_id) {
|
||||
return showEventHome($event_id, TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class RemindersController extends Controller {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* The password broker implementation.
|
||||
*
|
||||
* @var PasswordBroker
|
||||
*/
|
||||
protected $passwords;
|
||||
|
||||
public function __construct(Guard $auth, PasswordBroker $passwords) {
|
||||
$this->auth = $auth;
|
||||
$this->passwords = $passwords;
|
||||
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the e-mail subject line to be used for the reset link email.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getEmailSubject()
|
||||
{
|
||||
return isset($this->subject) ? $this->subject : 'Your Password Reset Link';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the password reminder view.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getRemind() {
|
||||
return \View::make('Public.LoginAndRegister.ForgotPassword');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a POST request to remind a user of their password.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function postRemind(Request $request) {
|
||||
|
||||
$this->validate($request, ['email' => 'required']);
|
||||
|
||||
$response = $this->passwords->sendResetLink($request->only('email'), function($m) {
|
||||
$m->subject($this->getEmailSubject());
|
||||
});
|
||||
|
||||
switch ($response) {
|
||||
case PasswordBroker::RESET_LINK_SENT:
|
||||
return redirect()->back()->with('status', trans($response));
|
||||
|
||||
case PasswordBroker::INVALID_USER:
|
||||
return redirect()->back()->withErrors(['email' => trans($response)]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the password reset view for the given token.
|
||||
*
|
||||
* @param string $token
|
||||
* @return Response
|
||||
*/
|
||||
public function getReset($token = null) {
|
||||
if (is_null($token))
|
||||
\App::abort(404);
|
||||
|
||||
return \View::make('Public.LoginAndRegister.ResetPassword')->with('token', $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a POST request to reset a user's password.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function postReset(Request $request) {
|
||||
$this->validate($request, [
|
||||
'token' => 'required',
|
||||
'email' => 'required',
|
||||
'password' => 'required|confirmed',
|
||||
]);
|
||||
|
||||
$credentials = $request->only(
|
||||
'email', 'password', 'password_confirmation', 'token'
|
||||
);
|
||||
|
||||
$response = $this->passwords->reset($credentials, function($user, $password) {
|
||||
$user->password = bcrypt($password);
|
||||
|
||||
$user->save();
|
||||
|
||||
$this->auth->login($user);
|
||||
});
|
||||
|
||||
switch ($response) {
|
||||
case PasswordBroker::PASSWORD_RESET:
|
||||
\Session::flash('message', 'Password Successfully Reset');
|
||||
return redirect(route('login'));
|
||||
|
||||
default:
|
||||
return redirect()->back()
|
||||
->withInput($request->only('email'))
|
||||
->withErrors(['email' => trans($response)]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Input,
|
||||
Response,
|
||||
Auth,
|
||||
Validator;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
|
||||
class UserController extends Controller {
|
||||
|
||||
public function showEditUser() {
|
||||
|
||||
$data = [
|
||||
'user' => \Auth::user(),
|
||||
'modal_id' => \Input::get('modal_id')
|
||||
];
|
||||
|
||||
return \View::make('ManageUser.Modals.EditUser', $data);
|
||||
}
|
||||
|
||||
public function postEditUser() {
|
||||
|
||||
$rules = array(
|
||||
'email' => ['required', 'email', 'exists:users,email,account_id,' . Auth::user()->account_id],
|
||||
'new_password' => ['min:5', 'confirmed', 'required_with:password'],
|
||||
'password' => 'passcheck',
|
||||
'first_name' => ['required'],
|
||||
'last_name' => ['required']
|
||||
);
|
||||
|
||||
$messages = [
|
||||
'email.email' => 'Please enter a valid E-mail address.',
|
||||
'email.required' => 'E-mail address is required.',
|
||||
'password.passcheck' => 'This password is incorrect.',
|
||||
'email.exists' => 'This E-mail has is already in use.',
|
||||
'first_name.required' => 'Please enter your first name.'
|
||||
];
|
||||
|
||||
$validation = \Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validation->fails()) {
|
||||
return Response::json([
|
||||
'status' => 'error',
|
||||
'messages' => $validation->messages()->toArray()
|
||||
]);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
if (Input::get('password')) {
|
||||
$user->password = \Hash::make(Input::get('new_password'));
|
||||
}
|
||||
|
||||
$user->first_name = Input::get('first_name');
|
||||
$user->last_name = Input::get('last_name');
|
||||
|
||||
|
||||
|
||||
//$user->email = Input::get('email');
|
||||
$user->save();
|
||||
|
||||
return Response::json([
|
||||
'status' => 'success',
|
||||
'message' => 'Successfully Edited User'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Request,
|
||||
View,
|
||||
Auth,
|
||||
Input,
|
||||
Redirect;
|
||||
use \Illuminate\Contracts\Auth\Guard;
|
||||
|
||||
class UserLoginController extends Controller {
|
||||
|
||||
protected $auth;
|
||||
|
||||
public function __construct(Guard $auth) {
|
||||
$this->auth = $auth;
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
public function showLogin() {
|
||||
|
||||
/*
|
||||
* If there's an ajax request to the login page assume the person has been
|
||||
* logged out and redirect them to the login page
|
||||
*/
|
||||
if (Request::ajax()) {
|
||||
return Response::json(array(
|
||||
'status' => 'success',
|
||||
'redirectUrl' => route('login')
|
||||
));
|
||||
}
|
||||
|
||||
return View::make('Public.LoginAndRegister.Login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the login
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postLogin() {
|
||||
|
||||
$email = Input::get('email');
|
||||
$password = Input::get('password');
|
||||
|
||||
if ($this->auth->attempt(array('email' => $email, 'password' => $password), true)) {
|
||||
return Redirect::to(route('showSelectOrganiser'));
|
||||
}
|
||||
return Redirect::to('login?failed=yup')->with('message', 'Your username/password combination was incorrect')
|
||||
->withInput();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
|
||||
class UserLogoutController extends Controller {
|
||||
|
||||
protected $auth;
|
||||
|
||||
public function __construct(Guard $auth) {
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
|
||||
public function doLogout() {
|
||||
$this->auth->logout();
|
||||
return \Redirect::to('/?logged_out=yup');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Attendize\Utils;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use View, Validator, Redirect, Hash, Auth, Input;
|
||||
use App\Models\Account;
|
||||
use App\Models\User;
|
||||
|
||||
class UserSignupController extends Controller {
|
||||
|
||||
protected $auth;
|
||||
|
||||
public function __construct(Guard $auth) {
|
||||
$this->auth = $auth;
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
public function showSignup() {
|
||||
|
||||
if(Account::count() > 0 && Utils::isAttendize()) {
|
||||
return Redirect::route('login');
|
||||
}
|
||||
|
||||
return View::make('Public.LoginAndRegister.Signup');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Validate an email
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates an account
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postSignup() {
|
||||
$rules = array(
|
||||
'email' => array('required', 'email', 'unique:users'),
|
||||
'password' => array('required', 'min:5', 'confirmed'),
|
||||
'first_name' => array('required'),
|
||||
'terms_agreed' => array('required')
|
||||
);
|
||||
|
||||
$messages = array(
|
||||
'email.email' => 'Please enter a valid E-mail address.',
|
||||
'email.required' => 'E-mail address is required.',
|
||||
'password.required' => 'Password is required.',
|
||||
'password.min' => 'Your password is too short! Min 5 symbols.',
|
||||
'email.unique' => 'This E-mail has already been taken.',
|
||||
'first_name.required' => 'Please enter your first name.',
|
||||
'terms_agreed.required' => 'Please agree to our Terms of Service.'
|
||||
);
|
||||
|
||||
$validation = Validator::make(Input::all(), $rules, $messages);
|
||||
|
||||
if ($validation->fails()) {
|
||||
return Redirect::to('signup')->withInput()->withErrors($validation);
|
||||
}
|
||||
|
||||
$account = new Account;
|
||||
$account->email = Input::get('email');
|
||||
$account->first_name = Input::get('first_name');
|
||||
$account->last_name = Input::get('last_name');
|
||||
$account->currency_id = DEFAULT_CURRENCY;
|
||||
$account->timezone_id = DEFAULT_TIMEZONE;
|
||||
$account->save();
|
||||
|
||||
$user = new User;
|
||||
$user->email = Input::get('email');
|
||||
$user->first_name = Input::get('first_name');
|
||||
$user->last_name = Input::get('last_name');
|
||||
$user->password = Hash::make(Input::get('password'));
|
||||
$user->account_id = $account->id;
|
||||
$user->is_parent = 1;
|
||||
$user->is_registered = 1;
|
||||
$user->save();
|
||||
|
||||
|
||||
/*
|
||||
* Send a confirmation email.
|
||||
* NOTE: $user->confirmation_code is generated by the model in the background
|
||||
*/
|
||||
\Mail::send('Emails.ConfirmEmail', ['first_name' => $user->first_name, 'confirmation_code' => $user->confirmation_code], function($message) {
|
||||
$message->to(Input::get('email'), Input::get('first_name'))
|
||||
->subject('Thank you for registering for Attendize');
|
||||
});
|
||||
|
||||
\Session::flash('message', "Success! You can now login.");
|
||||
|
||||
return Redirect::to('login');
|
||||
}
|
||||
|
||||
function confirmEmail($confirmation_code) {
|
||||
|
||||
$user = User::whereConfirmationCode($confirmation_code)->first();
|
||||
|
||||
if ( ! $user)
|
||||
{
|
||||
return \View::make('Public.Errors.Generic', [
|
||||
'message' => 'The confirmation code is missing or malformed.'
|
||||
]);
|
||||
}
|
||||
|
||||
$user->is_confirmed = 1;
|
||||
$user->confirmation_code = null;
|
||||
$user->save();
|
||||
|
||||
\Session::flash('message', "Success! Your email is now verified. You can now login.");
|
||||
|
||||
//$this->auth->login($user);
|
||||
|
||||
return Redirect::route('login');
|
||||
}
|
||||
|
||||
private function validateEmail($data)
|
||||
{
|
||||
$rules = [
|
||||
'email' => 'required|email|unique:users'
|
||||
];
|
||||
|
||||
return Validator::make($data, $rules);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel {
|
||||
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
|
||||
'Illuminate\Cookie\Middleware\EncryptCookies',
|
||||
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
|
||||
'Illuminate\Session\Middleware\StartSession',
|
||||
'Illuminate\View\Middleware\ShareErrorsFromSession',
|
||||
'App\Http\Middleware\VerifyCsrfToken',
|
||||
'App\Http\Middleware\GeneralChecks'
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => 'App\Http\Middleware\Authenticate',
|
||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
|
||||
'first.run' => 'App\Http\Middleware\FirstRunMiddleware'
|
||||
];
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
|
||||
class Authenticate {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest())
|
||||
{
|
||||
if ($request->ajax())
|
||||
{
|
||||
return response('Unauthorized.', 401);
|
||||
}
|
||||
else
|
||||
{
|
||||
return redirect()->guest('login');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php namespace app\Http\Middleware;
|
||||
|
||||
use Request;
|
||||
use Closure;
|
||||
use Utils;
|
||||
use App;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Cache;
|
||||
use Session;
|
||||
use App\Models\Organiser;
|
||||
|
||||
class FirstRunMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
/*
|
||||
* If there are no organisers then redirect the user to create one
|
||||
* else - if there's only one organiser bring the user straight there.
|
||||
*/
|
||||
if (Organiser::scope()->count() === 0 && !($request->route()->getName() == 'showCreateOrganiser') && !($request->route()->getName() == 'postCreateOrganiser')) {
|
||||
return redirect(route('showCreateOrganiser', [
|
||||
'first_run' => '1'
|
||||
]));
|
||||
} elseif (Organiser::scope()->count() === 1 && ($request->route()->getName() == 'showSelectOrganiser')) {
|
||||
return redirect(route('showOrganiserDashboard', [
|
||||
'organiser_id' => Organiser::scope()->first()->id
|
||||
]));
|
||||
}
|
||||
|
||||
$response = $next($request);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php namespace app\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use App;
|
||||
|
||||
class GeneralChecks
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
// Show message to IE 8 and before users
|
||||
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(?i)msie [2-8]/', $_SERVER['HTTP_USER_AGENT'])) {
|
||||
Session::flash('message', "Please update your browser. This application requires a modern browser.");
|
||||
}
|
||||
|
||||
$response = $next($request);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class RedirectIfAuthenticated {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->check())
|
||||
{
|
||||
return new RedirectResponse(route('showSelectOrganiser'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
||||
|
||||
class VerifyCsrfToken extends BaseVerifier {
|
||||
|
||||
|
||||
protected $except = [
|
||||
'install/*',
|
||||
];
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
return parent::handle($request, $next);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
abstract class Request extends FormRequest {
|
||||
|
||||
//
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,625 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register all of the routes for an application.
|
||||
| It's a breeze. Simply tell Laravel the URIs it should respond to
|
||||
| and give it the Closure to execute when that URI is requested.
|
||||
|
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Installer
|
||||
*/
|
||||
Route::get('install', [
|
||||
'as' => 'showInstaller',
|
||||
'uses' => 'InstallerController@showInstaller'
|
||||
]);
|
||||
Route::post('install', [
|
||||
'as' => 'postInstaller',
|
||||
'uses' => 'InstallerController@postInstaller'
|
||||
]);
|
||||
|
||||
/*
|
||||
* Stripe connect return
|
||||
*/
|
||||
Route::any('payment/return/stripe', [
|
||||
'as' => 'showStripeReturn',
|
||||
'uses' => 'ManageAccountController@showStripeReturn'
|
||||
]);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Login
|
||||
*/
|
||||
Route::get('/login', [
|
||||
'as' => 'login',
|
||||
'uses' => 'UserLoginController@showLogin'
|
||||
]);
|
||||
Route::post('/login', 'UserLoginController@postLogin');
|
||||
|
||||
/*
|
||||
* Forgot password
|
||||
*/
|
||||
Route::get('login/forgot-password', [
|
||||
'as' => 'forgotPassword',
|
||||
'uses' => 'RemindersController@getRemind'
|
||||
]);
|
||||
|
||||
Route::post('login/forgot-password', [
|
||||
'as' => 'postForgotPassword',
|
||||
'uses' => 'RemindersController@postRemind'
|
||||
]);
|
||||
|
||||
/*
|
||||
* Reset Password
|
||||
*/
|
||||
Route::get('login/reset-password/{token}', [
|
||||
'as' => 'showResetPassword',
|
||||
'uses' => 'RemindersController@getReset'
|
||||
]);
|
||||
|
||||
Route::post('login/reset-password', [
|
||||
'as' => 'postResetPassword',
|
||||
'uses' => 'RemindersController@postReset'
|
||||
]);
|
||||
|
||||
|
||||
/*
|
||||
* Logout
|
||||
*/
|
||||
Route::any('/logout', 'UserLogoutController@doLogout');
|
||||
|
||||
|
||||
/*
|
||||
* Registration / Account creation
|
||||
*/
|
||||
Route::get('/signup', 'UserSignupController@showSignup');
|
||||
Route::post('/signup', 'UserSignupController@postSignup');
|
||||
|
||||
/*
|
||||
* Confirm Email
|
||||
*/
|
||||
Route::get('signup/confirm_email/{confirmation_code}', [
|
||||
'as' => 'confirmEmail',
|
||||
'uses' => 'UserSignupController@confirmEmail'
|
||||
]);
|
||||
|
||||
/*
|
||||
* Public organiser page routes
|
||||
*/
|
||||
Route::group(['prefix' => 'o'], function() {
|
||||
|
||||
Route::get('/{organiser_id}/{organier_slug?}', [
|
||||
'as' => 'showOrganiserHome',
|
||||
'uses' => 'OrganiserViewController@showOrganiserHome'
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* Public event page routes
|
||||
*/
|
||||
Route::group(array('prefix' => 'e'), function() {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Embedded events
|
||||
*/
|
||||
Route::get('/{event_id}/embed', [
|
||||
'as' => 'showEmbeddedEventPage',
|
||||
'uses' => 'EventViewEmbeddedController@showEmbeddedEvent'
|
||||
]);
|
||||
|
||||
Route::get('/{event_id}/{event_slug?}', [
|
||||
'as' => 'showEventPage',
|
||||
'uses' => 'EventViewController@showEventHome'
|
||||
]);
|
||||
|
||||
Route::post('/{event_id}/contact_organiser', [
|
||||
'as' => 'postContactOrganiser',
|
||||
'uses' => 'EventViewController@postContactOrganiser'
|
||||
]);
|
||||
|
||||
/*
|
||||
* Used for previewing designs in the backend. Doesn't log page views etc.
|
||||
*/
|
||||
Route::get('/{event_id}/preview', [
|
||||
'as' => 'showEventPagePreview',
|
||||
'uses' => 'EventViewController@showEventHomePreview'
|
||||
]);
|
||||
|
||||
Route::post('{event_id}/checkout/', [
|
||||
'as' => 'postValidateTickets',
|
||||
'uses' => 'EventCheckoutController@postValidateTickets'
|
||||
]);
|
||||
|
||||
Route::get('{event_id}/checkout/create', [
|
||||
'as' => 'showEventCheckout',
|
||||
'uses' => 'EventCheckoutController@showEventCheckout'
|
||||
]);
|
||||
|
||||
Route::post('{event_id}/checkout/create', [
|
||||
'as' => 'postCreateOrder',
|
||||
'uses' => 'EventCheckoutController@postCreateOrder'
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View order
|
||||
*/
|
||||
Route::get('order/{order_reference}', [
|
||||
'as' => 'showOrderDetails',
|
||||
'uses' => 'EventCheckoutController@showOrderDetails'
|
||||
]);
|
||||
|
||||
Route::get('order/{order_reference}/tickets', [
|
||||
'as' => 'showOrderTickets',
|
||||
'uses' => 'EventCheckoutController@showOrderTickets'
|
||||
]);
|
||||
|
||||
|
||||
/*
|
||||
* Begin logged in stuff
|
||||
*/
|
||||
Route::group(array('middleware' => ['auth', 'first.run']), function() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Edit User
|
||||
*/
|
||||
Route::group(['prefix' => 'user'], function() {
|
||||
|
||||
Route::get('/', [
|
||||
'as' => 'showEditUser',
|
||||
'uses' => 'UserController@showEditUser'
|
||||
]);
|
||||
Route::post('/', [
|
||||
'as' => 'postEditUser',
|
||||
'uses' => 'UserController@postEditUser'
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
* Manage account
|
||||
*/
|
||||
Route::group(array('prefix' => 'account'), function() {
|
||||
|
||||
Route::get('/', [
|
||||
'as' => 'showEditAccount',
|
||||
'uses' => 'ManageAccountController@showEditAccount'
|
||||
]);
|
||||
|
||||
Route::post('/', [
|
||||
'as' => 'postEditAccount',
|
||||
'uses' => 'ManageAccountController@postEditAccount'
|
||||
]);
|
||||
Route::post('/edit_payment', [
|
||||
'as' => 'postEditAccountPayment',
|
||||
'uses' => 'ManageAccountController@postEditAccountPayment'
|
||||
]);
|
||||
|
||||
Route::post('invite_user', [
|
||||
'as' => 'postInviteUser',
|
||||
'uses' => 'ManageAccountController@postInviteUser'
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
Route::get('select_organiser', [
|
||||
'as' => 'showSelectOrganiser',
|
||||
'uses' => 'OrganiserController@showSelectOragniser'
|
||||
]);
|
||||
|
||||
/*
|
||||
* New organiser dashboard
|
||||
*/
|
||||
Route::group(array('prefix' => 'organiser'), function() {
|
||||
/*
|
||||
* -----------
|
||||
* Organiser Dashboard
|
||||
* -----------
|
||||
*/
|
||||
Route::get('{organiser_id}/dashboard', [
|
||||
'as' => 'showOrganiserDashboard',
|
||||
'uses' => 'OrganiserDashboardController@showDashboard'
|
||||
]);
|
||||
|
||||
/*
|
||||
* -----------
|
||||
* Organiser events
|
||||
* -----------
|
||||
*/
|
||||
Route::get('{organiser_id}/events', [
|
||||
'as' => 'showOrganiserEvents',
|
||||
'uses' => 'OrganiserEventsController@showEvents'
|
||||
]);
|
||||
/*
|
||||
* -----------
|
||||
* Organiser events
|
||||
* -----------
|
||||
*/
|
||||
Route::get('{organiser_id}/customize', [
|
||||
'as' => 'showOrganiserCustomize',
|
||||
'uses' => 'OrganiserCustomizeController@showCustomize'
|
||||
]);
|
||||
});
|
||||
|
||||
/*
|
||||
* Events dashboard
|
||||
*/
|
||||
Route::group(array('prefix' => 'events'), function() {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* -----------
|
||||
* Events Dashboard - Organisers
|
||||
* -----------
|
||||
*/
|
||||
Route::get('/organiser/create', [
|
||||
'as' => 'showCreateOrganiser',
|
||||
'uses' => 'OrganiserController@showCreateOrganiser'
|
||||
]);
|
||||
Route::post('/organiser/create', [
|
||||
'as' => 'postCreateOrganiser',
|
||||
'uses' => 'OrganiserController@postCreateOrganiser'
|
||||
]);
|
||||
Route::get('/organiser/{organiser_id}', [
|
||||
'as' => 'showOrganiserEventsDashboard',
|
||||
'uses' => 'OrganiserController@showOrganiserDashboard'
|
||||
]);
|
||||
Route::get('/organiser/{organiser_id?}', [
|
||||
'as' => 'showSearchEventsDashboard',
|
||||
'uses' => 'OrganiserController@showOrganiserDashboard'
|
||||
]);
|
||||
Route::get('/organiser/{organiser_id}/edit', [
|
||||
'as' => 'showEditOrganiser',
|
||||
'uses' => 'OrganiserController@showEditOrganiser'
|
||||
]);
|
||||
Route::post('/organiser/{organiser_id}/edit', [
|
||||
'as' => 'postEditOrganiser',
|
||||
'uses' => 'OrganiserCustomizeController@postEditOrganiser'
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ----------
|
||||
* Create Event
|
||||
* ----------
|
||||
*/
|
||||
Route::get('/create', [
|
||||
'as' => 'showCreateEvent',
|
||||
'uses' => 'EventController@showCreateEvent'
|
||||
]);
|
||||
|
||||
Route::post('/create', [
|
||||
'as' => 'postCreateEvent',
|
||||
'uses' => 'EventController@postCreateEvent'
|
||||
]);
|
||||
});
|
||||
|
||||
/*
|
||||
* Upoad event images
|
||||
*/
|
||||
Route::post('/upload_image', [
|
||||
'as' => 'postUploadEventImage',
|
||||
'uses' => 'EventController@postUploadEventImage'
|
||||
]);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Event Management Stuff
|
||||
*/
|
||||
Route::group(array('prefix' => 'event'), function() {
|
||||
|
||||
/*
|
||||
* -------
|
||||
* Dashboard
|
||||
* -------
|
||||
*/
|
||||
Route::get('{event_id}/dashboard/', array(
|
||||
'as' => 'showEventDashboard',
|
||||
'uses' => 'EventDashboardController@showDashboard')
|
||||
);
|
||||
|
||||
Route::get('{event_id}', function($event_id) {
|
||||
return Redirect::route('showEventDashboard', [
|
||||
'event_id' => $event_id
|
||||
]);
|
||||
});
|
||||
|
||||
/**
|
||||
* @todo Move to a controller
|
||||
*/
|
||||
Route::get('{event_id}/go_live', ['as' => 'MakeEventLive', function($event_id) {
|
||||
$event = \App\Models\Event::scope()->findOrFail($event_id);
|
||||
$event->is_live = 1;
|
||||
$event->save();
|
||||
\Session::flash('message', 'Event Successfully Made Live! You can undo this action in event settings page.');
|
||||
return Redirect::route('showEventDashboard', [
|
||||
'event_id' => $event_id
|
||||
]);
|
||||
}]);
|
||||
|
||||
/*
|
||||
* -------
|
||||
* Tickets
|
||||
* -------
|
||||
*/
|
||||
Route::get('{event_id}/tickets/', array(
|
||||
'as' => 'showEventTickets',
|
||||
'uses' => 'EventTicketsController@showTickets'
|
||||
));
|
||||
Route::get('{event_id}/tickets/edit/{ticket_id}', array(
|
||||
'as' => 'showEditTicket',
|
||||
'uses' => 'EventTicketsController@showEditTicket'
|
||||
));
|
||||
Route::post('{event_id}/tickets/edit/{ticket_id}', array(
|
||||
'as' => 'postEditTicket',
|
||||
'uses' => 'EventTicketsController@postEditTicket'
|
||||
));
|
||||
Route::get('{event_id}/tickets/create', array(
|
||||
'as' => 'showCreateTicket',
|
||||
'uses' => 'EventTicketsController@showCreateTicket'
|
||||
));
|
||||
Route::post('{event_id}/tickets/create', array(
|
||||
'as' => 'postCreateTicket',
|
||||
'uses' => 'EventTicketsController@postCreateTicket'
|
||||
));
|
||||
Route::post('{event_id}/tickets/delete', array(
|
||||
'as' => 'postDeleteTicket',
|
||||
'uses' => 'EventTicketsController@postDeleteTicket'
|
||||
));
|
||||
Route::post('{event_id}/tickets/pause', array(
|
||||
'as' => 'postPauseTicket',
|
||||
'uses' => 'EventTicketsController@postPauseTicket'
|
||||
));
|
||||
|
||||
/*
|
||||
* Ticket questions
|
||||
*/
|
||||
Route::get('{event_id}/tickets/questions', [
|
||||
'as' => 'showTicketQuestions',
|
||||
'uses' => 'EventTicketQuestionsController@showQuestions'
|
||||
]);
|
||||
Route::post('{event_id}/tickets/questions/create', [
|
||||
'as' => 'postCreateQuestion',
|
||||
'uses' => 'EventTicketQuestionsController@postCreateQuestion'
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* -------
|
||||
* Attendees
|
||||
* -------
|
||||
*/
|
||||
Route::get('{event_id}/attendees/', array(
|
||||
'as' => 'showEventAttendees',
|
||||
'uses' => 'EventAttendeesController@showAttendees'
|
||||
));
|
||||
|
||||
Route::get('{event_id}/attendees/message', [
|
||||
'as' => 'showMessageAttendees',
|
||||
'uses' => 'EventAttendeesController@showMessageAttendees'
|
||||
]);
|
||||
|
||||
Route::post('{event_id}/attendees/message', [
|
||||
'as' => 'postMessageAttendees',
|
||||
'uses' => 'EventAttendeesController@postMessageAttendees'
|
||||
]);
|
||||
|
||||
Route::get('{event_id}/attendees/single_message', [
|
||||
'as' => 'showMessageAttendee',
|
||||
'uses' => 'EventAttendeesController@showMessageAttendee'
|
||||
]);
|
||||
|
||||
Route::post('{event_id}/attendees/single_message', [
|
||||
'as' => 'postMessageAttendee',
|
||||
'uses' => 'EventAttendeesController@postMessageAttendee'
|
||||
]);
|
||||
|
||||
|
||||
Route::get('{event_id}/attendees/create', [
|
||||
'as' => 'showCreateAttendee',
|
||||
'uses' => 'EventAttendeesController@showCreateAttendee'
|
||||
]);
|
||||
|
||||
Route::post('{event_id}/attendees/create', [
|
||||
'as' => 'postCreateAttendee',
|
||||
'uses' => 'EventAttendeesController@postCreateAttendee'
|
||||
]);
|
||||
|
||||
Route::get('{event_id}/attendees/print', [
|
||||
'as' => 'showPrintAttendees',
|
||||
'uses' => 'EventAttendeesController@showPrintAttendees'
|
||||
]);
|
||||
|
||||
Route::get('{event_id}/attendees/export/{export_as?}', [
|
||||
'as' => 'showExportAttendees',
|
||||
'uses' => 'EventAttendeesController@showExportAttendees'
|
||||
]);
|
||||
|
||||
Route::get('{event_id}/attendees/{attendee_id}/edit', [
|
||||
'as' => 'showEditAttendee',
|
||||
'uses' => 'EventAttendeesController@showEditAttendee'
|
||||
]);
|
||||
Route::post('{event_id}/attendees/{attendee_id}/edit', [
|
||||
'as' => 'postEditAttendee',
|
||||
'uses' => 'EventAttendeesController@postEditAttendee'
|
||||
]);
|
||||
|
||||
Route::get('{event_id}/attendees/{attendee_id}/cancel', [
|
||||
'as' => 'showCancelAttendee',
|
||||
'uses' => 'EventAttendeesController@showCancelAttendee'
|
||||
]);
|
||||
Route::post('{event_id}/attendees/{attendee_id}/cancel', [
|
||||
'as' => 'postCancelAttendee',
|
||||
'uses' => 'EventAttendeesController@postCancelAttendee'
|
||||
]);
|
||||
|
||||
|
||||
/*
|
||||
* -------
|
||||
* Orders
|
||||
* -------
|
||||
*/
|
||||
Route::get('{event_id}/orders/', array(
|
||||
'as' => 'showEventOrders',
|
||||
'uses' => 'EventOrdersController@showOrders'
|
||||
));
|
||||
|
||||
Route::get('order/{order_id}', array(
|
||||
'as' => 'showManageOrder',
|
||||
'uses' => 'EventOrdersController@manageOrder'
|
||||
));
|
||||
|
||||
Route::get('order/{order_id}/cancel', array(
|
||||
'as' => 'showCancelOrder',
|
||||
'uses' => 'EventOrdersController@showCancelOrder'
|
||||
));
|
||||
|
||||
Route::post('order/{order_id}/cancel', array(
|
||||
'as' => 'postCancelOrder',
|
||||
'uses' => 'EventOrdersController@postCancelOrder'
|
||||
));
|
||||
|
||||
Route::get('{event_id}/orders/export/{export_as?}', [
|
||||
'as' => 'showExportOrders',
|
||||
'uses' => 'EventOrdersController@showExportOrders'
|
||||
]);
|
||||
Route::get('{event_id}/orders/message', [
|
||||
'as' => 'showMessageOrder',
|
||||
'uses' => 'EventOrdersController@showMessageOrder'
|
||||
]);
|
||||
|
||||
Route::post('{event_id}/orders/message', [
|
||||
'as' => 'postMessageOrder',
|
||||
'uses' => 'EventOrdersController@postMessageOrder'
|
||||
]);
|
||||
|
||||
/*
|
||||
* -------
|
||||
* Edit Event
|
||||
* -------
|
||||
*/
|
||||
Route::post('{event_id}/customize', array(
|
||||
'as' => 'postEditEvent',
|
||||
'uses' => 'EventController@postEditEvent'
|
||||
));
|
||||
|
||||
/*
|
||||
* -------
|
||||
* Customize Design etc.
|
||||
* -------
|
||||
*/
|
||||
Route::get('{event_id}/customize', array(
|
||||
'as' => 'showEventCustomize',
|
||||
'uses' => 'EventCustomizeController@showCustomize'
|
||||
));
|
||||
|
||||
Route::get('{event_id}/customize/{tab?}', array(
|
||||
'as' => 'showEventCustomizeTab',
|
||||
'uses' => 'EventCustomizeController@showCustomize'
|
||||
));
|
||||
|
||||
|
||||
|
||||
Route::post('{event_id}/customize/order_page', array(
|
||||
'as' => 'postEditEventOrderPage',
|
||||
'uses' => 'EventCustomizeController@postEditEventOrderPage'
|
||||
));
|
||||
Route::post('{event_id}/customize/design', array(
|
||||
'as' => 'postEditEventDesign',
|
||||
'uses' => 'EventCustomizeController@postEditEventDesign'
|
||||
));
|
||||
Route::post('{event_id}/customize/social', array(
|
||||
'as' => 'postEditEventSocial',
|
||||
'uses' => 'EventCustomizeController@postEditEventSocial'
|
||||
));
|
||||
|
||||
Route::post('{event_id}/customize/fees', array(
|
||||
'as' => 'postEditEventFees',
|
||||
'uses' => 'EventCustomizeController@postEditEventFees'
|
||||
));
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* -------
|
||||
* Check In App
|
||||
* -------
|
||||
*/
|
||||
Route::get('{event_id}/check_in', array(
|
||||
'as' => 'showChechIn',
|
||||
'uses' => 'EventCheckInController@showCheckIn'
|
||||
));
|
||||
Route::post('{event_id}/check_in/search', array(
|
||||
'as' => 'postCheckInSearch',
|
||||
'uses' => 'EventCheckInController@postCheckInSearch'
|
||||
));
|
||||
Route::post('{event_id}/check_in/', array(
|
||||
'as' => 'postCheckInAttendee',
|
||||
'uses' => 'EventCheckInController@postCheckInAttendee'
|
||||
));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* -------
|
||||
* Promote
|
||||
* -------
|
||||
*/
|
||||
Route::get('{event_id}/promote', array(
|
||||
'as' => 'showEventPromote',
|
||||
'uses' => 'EventPromoteController@showPromote'
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Route::post('queue/push', function() {
|
||||
|
||||
// set_time_limit(300);
|
||||
|
||||
return Queue::marshal();
|
||||
});
|
||||
|
||||
|
||||
Route::get('/', function() {
|
||||
|
||||
return Redirect::route('showSelectOrganiser');
|
||||
});
|
||||
|
||||
|
||||
Route::get('/terms_and_conditions', ['as' => 'termsAndConditions', function() {
|
||||
|
||||
return 'TODO: add terms and cond';
|
||||
//return View::make('Public.Website.Terms_and_Cond');
|
||||
}]);
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use \App\Attendize\Utils;
|
||||
|
||||
class Account extends MyBaseModel {
|
||||
use SoftDeletes;
|
||||
|
||||
protected $rules = [
|
||||
'first_name' => ['required'],
|
||||
'last_name' => ['required'],
|
||||
'email' => ['required', 'email']
|
||||
];
|
||||
|
||||
protected $messages = [];
|
||||
|
||||
public function users() {
|
||||
return $this->hasMany('\App\Models\User');
|
||||
}
|
||||
|
||||
public function orders() {
|
||||
return $this->hasMany('\App\Models\Order');
|
||||
}
|
||||
|
||||
public function currency() {
|
||||
return $this->hasOne('\App\Models\Currency');
|
||||
}
|
||||
|
||||
public function getStripeApiKeyAttribute() {
|
||||
if(Utils::isAttendize()) {
|
||||
return $this->stripe_access_token;
|
||||
}
|
||||
|
||||
return $this->stripe_secret_key;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of Activity
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class Activity extends \Illuminate\Database\Eloquent\Model {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
class Affiliate extends \Illuminate\Database\Eloquent\Model {
|
||||
protected $fillable = array('name', 'visits', 'tickets_sold', 'event_id', 'account_id', 'sales_volume');
|
||||
|
||||
public function getDates() {
|
||||
return array('created_at', 'updated_at');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of Attendees
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class Attendee extends MyBaseModel {
|
||||
use SoftDeletes;
|
||||
|
||||
public function order(){
|
||||
return$this->belongsTo('\App\Models\Order');
|
||||
}
|
||||
|
||||
public function ticket() {
|
||||
return $this->belongsTo('\App\Models\Ticket');
|
||||
}
|
||||
|
||||
public function event() {
|
||||
return $this->belongsTo('\App\Models\Event');
|
||||
}
|
||||
|
||||
|
||||
public function scopeWithoutCancelled($query) {
|
||||
return $query->where('attendees.is_cancelled', '=', 0);
|
||||
}
|
||||
|
||||
public function getFullNameAttribute() {
|
||||
return $this->first_name.' '.$this->last_name;
|
||||
}
|
||||
|
||||
//
|
||||
// public function getReferenceAttribute() {
|
||||
// return $this->order->order_reference
|
||||
// }
|
||||
|
||||
public function getDates() {
|
||||
return array('created_at', 'updated_at', 'arrival_time');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a private referennce number for the attendee. Use for checking in the attendee.
|
||||
*/
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
static::creating(function($order) {
|
||||
$order->private_reference_number = str_pad(rand(0, pow(10, 9)-1), 9, '0', STR_PAD_LEFT);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of Currency
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class Currency extends \Illuminate\Database\Eloquent\Model {
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
|
||||
protected $table = 'currencies';
|
||||
|
||||
|
||||
public function event() {
|
||||
return $this->belongsTo('\App\Models\Event');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of DateFormat
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class DateFormat extends \Illuminate\Database\Eloquent\Model {
|
||||
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of DateTimeFormat
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class DateTimeFormat extends \Illuminate\Database\Eloquent\Model {
|
||||
|
||||
protected $table = 'datetime_formats';
|
||||
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of DiscountCode
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class DiscountCode extends \Illuminate\Database\Eloquent\Model {
|
||||
//put your code here
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Str, URL;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Event extends MyBaseModel {
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $rules = array(
|
||||
'title' => array('required'),
|
||||
'description' => array('required'),
|
||||
'location_venue_name' => array('required_without:venue_name_full'),
|
||||
'venue_name_full' => array('required_without:location_venue_name'),
|
||||
'start_date' => array('required'),
|
||||
'end_date' => array('required'),
|
||||
'organiser_name' => array('required_without:organiser_id'),
|
||||
'event_image' => ['mimes:jpeg,jpg,png', 'max:3000']
|
||||
);
|
||||
protected $messages = array(
|
||||
'title.required' => 'You must at least give a title for your event.',
|
||||
'organiser_name.required_without' => 'Please create an organiser or select an existing organiser.',
|
||||
'event_image.mimes' => 'Please ensure you are uploading an image (JPG, PNG, JPEG)',
|
||||
'event_image.max' => 'Pleae ensure the image is not larger then 3MB',
|
||||
'location_venue_name.required_without' => 'Please enter a venue for your event',
|
||||
'venue_name_full.required_without' => 'Please enter a venue for your event'
|
||||
);
|
||||
|
||||
public function questions() {
|
||||
return $this->belongsToMany('\App\Models\Question', 'event_question');
|
||||
}
|
||||
|
||||
public function attendees() {
|
||||
return $this->hasMany('\App\Models\Attendee');
|
||||
}
|
||||
|
||||
public function images() {
|
||||
return $this->hasMany('\App\Models\EventImage');
|
||||
}
|
||||
public function messages() {
|
||||
return $this->hasMany('\App\Models\Message')->orderBy('created_at', 'DESC');
|
||||
}
|
||||
|
||||
public function tickets() {
|
||||
return $this->hasMany('\App\Models\Ticket');
|
||||
}
|
||||
|
||||
public function stats() {
|
||||
return $this->hasMany('\App\Models\EventStats');
|
||||
}
|
||||
|
||||
public function affiliates() {
|
||||
return $this->hasMany('\App\Models\Affiliate');
|
||||
}
|
||||
|
||||
public function orders() {
|
||||
return $this->hasMany('\App\Models\Order');
|
||||
}
|
||||
|
||||
public function account() {
|
||||
return $this->belongsTo('\App\Models\Account');
|
||||
}
|
||||
|
||||
public function currency() {
|
||||
return $this->belongsTo('\App\Models\Currency');
|
||||
}
|
||||
|
||||
public function organiser() {
|
||||
return $this->belongsTo('\App\Models\Organiser');
|
||||
}
|
||||
|
||||
/*
|
||||
* Getters & Setters
|
||||
*/
|
||||
|
||||
public function getEmbedUrlAttribute() {
|
||||
return str_replace(['http:', 'https:'], '', route('showEmbeddedEventPage', ['event' => $this->id]));
|
||||
}
|
||||
|
||||
public function getFixedFeeAttribute() {
|
||||
return TICKET_BOOKING_FEE_FIXED + $this->organiser_fee_fixed;
|
||||
}
|
||||
public function getPercentageFeeAttribute() {
|
||||
return TICKET_BOOKING_FEE_PERCENTAGE + $this->organiser_fee_percentage;
|
||||
}
|
||||
|
||||
public function getHappeningNowAttribute() {
|
||||
return Carbon::now()->between($this->start_date, $this->end_date);
|
||||
}
|
||||
|
||||
public function getCurrencySymbolAttribute() {
|
||||
return $this->currency->symbol_left;
|
||||
}
|
||||
public function getCurrencyCodeAttribute() {
|
||||
return $this->currency->code;
|
||||
}
|
||||
|
||||
public function getEmbedHtmlCodeAttribute () {
|
||||
return "<!--Attendize.com Ticketing Embed Code-->
|
||||
<iframe style='overflow:hidden; min-height: 350px;' frameBorder='0' seamless='seamless' width='100%' height='100%' src='".$this->embed_url."' vspace='0' hspace='0' scrolling='auto' allowtransparency='true'></iframe>
|
||||
<!--/Attendize.com Ticketing Embed Code-->";
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a usable address for embedding Google Maps
|
||||
*/
|
||||
public function getMapAddressAttribute() {
|
||||
|
||||
$string = $this->venue.','
|
||||
.$this->location_street_number.','
|
||||
.$this->location_address_line_1.','
|
||||
.$this->location_address_line_2.','
|
||||
.$this->location_state.','
|
||||
.$this->location_post_code.','
|
||||
.$this->location_country;
|
||||
|
||||
return urlencode($string);
|
||||
|
||||
}
|
||||
|
||||
public function getBgImageUrlAttribute() {
|
||||
return URL::to('/').'/'.$this->bg_image_path;
|
||||
}
|
||||
|
||||
public function getEventUrlAttribute() {
|
||||
return URL::to('/').'/e/'.$this->id.'/'.Str::slug($this->title);
|
||||
}
|
||||
|
||||
|
||||
public function getSalesAndFeesVoulmeAttribute() {
|
||||
return $this->sales_volume + $this->organiser_fees_volume;
|
||||
}
|
||||
|
||||
public function getDates() {
|
||||
return array('created_at', 'updated_at', 'start_date', 'end_date');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of EventImage
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class EventImage extends MyBaseModel {
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
use DB, Cookie;
|
||||
use App\Models\Ticket;
|
||||
|
||||
class EventStats extends \Illuminate\Database\Eloquent\Model {
|
||||
|
||||
public $timestamps = false;
|
||||
public static $unguarded = true;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @todo This shouldn't be in a view.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Update the amount of revenue a ticket has earned
|
||||
*
|
||||
* @param int $ticket_id
|
||||
* @param float $amount
|
||||
* @param bool $deduct
|
||||
* @return bool
|
||||
*/
|
||||
public function updateTicketRevenue($ticket_id, $amount, $deduct = FALSE) {
|
||||
$ticket = Ticket::find($ticket_id);
|
||||
|
||||
if($deduct) {
|
||||
$amount = $amount * -1;
|
||||
}
|
||||
|
||||
$ticket->ticket_revenue = $ticket->ticket_revenue + $amount;
|
||||
|
||||
return $ticket->save();
|
||||
}
|
||||
|
||||
public function updateViewCount($event_id) {
|
||||
|
||||
$stats = $this->firstOrNew([
|
||||
'event_id' => $event_id,
|
||||
'date' => DB::raw('CURDATE()')
|
||||
]);
|
||||
|
||||
$cookie_name = 'visitTrack_'.$event_id.'_'.date('dmy');
|
||||
|
||||
if(!Cookie::get($cookie_name)) {
|
||||
Cookie::queue($cookie_name, true, 60 * 24 * 14);
|
||||
++$stats->unique_views;
|
||||
}
|
||||
|
||||
++$stats->views;
|
||||
|
||||
return $stats->save();
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Missing amount?
|
||||
*/
|
||||
public function updateSalesVolume($event_id) {
|
||||
$stats = $this->firstOrNew([
|
||||
'event_id' => $event_id,
|
||||
'date' => DB::raw('CURDATE()')
|
||||
]);
|
||||
|
||||
$stats->sales_volume = $stats->sales_volume + $amount;
|
||||
|
||||
return $stats->save();
|
||||
}
|
||||
|
||||
|
||||
public function updateTicketsSoldCount($event_id, $count) {
|
||||
|
||||
$stats = $this->firstOrNew([
|
||||
'event_id' => $event_id,
|
||||
'date' => DB::raw('CURDATE()')
|
||||
]);
|
||||
|
||||
$stats->increment('tickets_sold', $count);
|
||||
|
||||
return $stats->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of Message
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class Message extends MyBaseModel {
|
||||
|
||||
public function event() {
|
||||
return $this->belongsTo('\App\Models\Event');
|
||||
}
|
||||
|
||||
public function getRecipientsLabelAttribute() {
|
||||
if($this->recipients == 0) {
|
||||
return 'All Attendees';
|
||||
}
|
||||
|
||||
$ticket = Ticket::scope()->find($this->recipients);
|
||||
return 'Ticket: '.$ticket->title;
|
||||
}
|
||||
|
||||
public function getDates() {
|
||||
return array('created_at', 'updated_at', 'sent_at');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Auth,
|
||||
Validator;
|
||||
|
||||
/*
|
||||
* Adapted from: https://github.com/hillelcoren/invoice-ninja/blob/master/app/models/EntityModel.php
|
||||
*/
|
||||
|
||||
class MyBaseModel extends \Illuminate\Database\Eloquent\Model {
|
||||
|
||||
protected $softDelete = true;
|
||||
public $timestamps = true;
|
||||
protected $rules = array();
|
||||
protected $messages = array();
|
||||
protected $errors;
|
||||
|
||||
public function validate($data) {
|
||||
$v = Validator::make($data, $this->rules, $this->messages);
|
||||
|
||||
if ($v->fails()) {
|
||||
$this->errors = $v->messages();
|
||||
return false;
|
||||
}
|
||||
|
||||
// validation pass
|
||||
return true;
|
||||
}
|
||||
|
||||
public function errors($returnArray = TRUE) {
|
||||
return $returnArray ? $this->errors->toArray() : $this->errors;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $account_id
|
||||
* @param int $user_id
|
||||
* @param bool $ignore_user_id
|
||||
* @return \className
|
||||
*/
|
||||
public static function createNew($account_id = FALSE, $user_id = FALSE, $ignore_user_id = FALSE) {
|
||||
$className = get_called_class();
|
||||
$entity = new $className();
|
||||
|
||||
if (Auth::check()) {
|
||||
|
||||
if (!$ignore_user_id) {
|
||||
$entity->user_id = Auth::user()->id;
|
||||
}
|
||||
|
||||
$entity->account_id = Auth::user()->account_id;
|
||||
} else if ($account_id || $user_id) {
|
||||
|
||||
if ($user_id && !$ignore_user_id) {
|
||||
$entity->user_id = $user_id;
|
||||
}
|
||||
|
||||
$entity->account_id = $account_id;
|
||||
} else {
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
public function getFormatedDate($field, $format = 'd-m-Y H:i') {
|
||||
return $this->$field === NULL ? NULL : date($format, strtotime($this->$field));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $accountId
|
||||
*/
|
||||
public function scopeScope($query, $accountId = false) {
|
||||
|
||||
/*
|
||||
* GOD MODE - DON'T UNCOMMENT!
|
||||
* returning $query before adding the account_id condition will let you
|
||||
* browse all events etc. in the system.
|
||||
* //return $query;
|
||||
*/
|
||||
|
||||
|
||||
if (!$accountId) {
|
||||
$accountId = Auth::user()->account_id;
|
||||
}
|
||||
|
||||
$table = $this->getTable();
|
||||
|
||||
$query->where(function($query) use ($accountId, $table) {
|
||||
$query->whereRaw(\DB::raw('(' . $table . '.account_id = ' . $accountId . ')'));
|
||||
});
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use PDF;
|
||||
use File;
|
||||
|
||||
class Order extends MyBaseModel {
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
public $rules = [
|
||||
'order_first_name' => ['required'],
|
||||
'order_last_name' => ['required'],
|
||||
'order_email' => ['required', 'email'],
|
||||
];
|
||||
public $messages = [
|
||||
'order_first_name.required' => 'Please enter a valid first name',
|
||||
'order_last_name.required' => 'Please enter a valid last name',
|
||||
'order_email.email' => 'Please enter a valid email',
|
||||
];
|
||||
|
||||
public function orderItems() {
|
||||
return $this->hasMany('\App\Models\OrderItem');
|
||||
}
|
||||
|
||||
public function attendees() {
|
||||
return $this->hasMany('\App\Models\Attendee');
|
||||
}
|
||||
|
||||
public function account() {
|
||||
return $this->belongsTo('\App\Models\Account');
|
||||
}
|
||||
|
||||
public function event() {
|
||||
return $this->belongsTo('\App\Models\Event');
|
||||
}
|
||||
|
||||
public function tickets() {
|
||||
return $this->hasMany('\App\Models\Ticket');
|
||||
}
|
||||
|
||||
public function orderStatus() {
|
||||
return $this->belongsTo('\App\Models\OrderStatus');
|
||||
}
|
||||
|
||||
public function getOrganiserAmountAttribute() {
|
||||
return $this->amount + $this->organiser_booking_fee;
|
||||
}
|
||||
|
||||
public function getTotalAmountAttribute() {
|
||||
return $this->amount + $this->organiser_booking_fee + $this->booking_fee;
|
||||
}
|
||||
|
||||
public function getFullNameAttribute() {
|
||||
return $this->first_name . ' ' . $this->last_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and save the PDF tickets
|
||||
*
|
||||
* @todo Move this from the order model
|
||||
* @return boolean
|
||||
*/
|
||||
public function generatePdfTickets() {
|
||||
|
||||
$data = [
|
||||
'order' => $this,
|
||||
'event' => $this->event,
|
||||
'tickets' => $this->event->tickets,
|
||||
'attendees' => $this->attendees
|
||||
];
|
||||
|
||||
$pdf_file_path = public_path(EVENT_PDF_TICKETS_PATH) . '/' . $this->order_reference;
|
||||
$pdf_file = $pdf_file_path.'.pdf';
|
||||
|
||||
if (file_exists($pdf_file)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!is_dir($pdf_file_path)) {
|
||||
File::makeDirectory($pdf_file_path, 0777, true, true);
|
||||
}
|
||||
|
||||
PDF::setOutputMode('F'); // force to file
|
||||
PDF::html('Public.ViewEvent.Partials.PDFTicket', $data, $pdf_file_path);
|
||||
|
||||
$this->ticket_pdf_path = EVENT_PDF_TICKETS_PATH.'/'.$this->order_reference.'.pdf';
|
||||
$this->save();
|
||||
|
||||
return file_exists($pdf_file);
|
||||
}
|
||||
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
static::creating(function($order) {
|
||||
$order->order_reference = strtoupper(str_random(5)) . date('jn');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of OrderItems
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class OrderItem extends MyBaseModel {
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of OrderStatus
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class OrderStatus extends \Illuminate\Database\Eloquent\Model {
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
use Str;
|
||||
|
||||
class Organiser extends MyBaseModel {
|
||||
|
||||
protected $rules = array(
|
||||
'name' => array('required'),
|
||||
'email' => array('required', 'email'),
|
||||
'organiser_logo' => ['mimes:jpeg,jpg,png', 'max:10000']
|
||||
);
|
||||
protected $messages = array(
|
||||
'name.required' => 'You must at least give a name for the event organiser.',
|
||||
'organiser_logo.max' => 'Please upload an image smaller than 10Mb',
|
||||
'organiser_logo.size' => 'Please upload an image smaller than 10Mb',
|
||||
'organiser_logo.mimes' => 'Please select a valid image type (jpeg, jpg, png)'
|
||||
);
|
||||
|
||||
public function events() {
|
||||
return $this->hasMany('\App\Models\Event');
|
||||
}
|
||||
|
||||
public function attendees() {
|
||||
return $this->hasManyThrough('\App\Models\Attendee', '\App\Models\Event');
|
||||
}
|
||||
|
||||
public function getFullLogoPathAttribute() {
|
||||
if($this->logo_path && (file_exists(CDN_URL_USER_ASSETS.'/'.$this->logo_path) || file_exists(public_path($this->logo_path)))) {
|
||||
return CDN_URL_USER_ASSETS.'/'.$this->logo_path;
|
||||
}
|
||||
|
||||
return FALLBACK_ORGANISER_LOGO_URL;
|
||||
}
|
||||
|
||||
public function getOrganiserUrlAttribute() {
|
||||
return route('showOrganiserHome', [
|
||||
'organiser_id' => $this->id,
|
||||
'organiser_slug' => Str::slug($this->oraganiser_name)
|
||||
]);
|
||||
}
|
||||
|
||||
public function getOrganiserSalesVolumeAttribute() {
|
||||
return $this->events->sum('sales_volume');
|
||||
}
|
||||
|
||||
|
||||
public function getDailyStats() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of PaymentGateway
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class PaymentGateway extends \Illuminate\Database\Eloquent\Model {
|
||||
//put your code here
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Description of Questions
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class Question extends MyBaseModel {
|
||||
use SoftDeletes;
|
||||
|
||||
public function events() {
|
||||
return $this->belongsToMany('\App\Models\Event');
|
||||
}
|
||||
|
||||
|
||||
public function question_types() {
|
||||
return $this->hasOne('\App\Models\QuestionType');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
class QuestionType extends \Illuminate\Database\Eloquent\Model {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of ReservedTickets
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class ReservedTickets extends \Illuminate\Database\Eloquent\Model {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
class Ticket extends MyBaseModel {
|
||||
use SoftDeletes;
|
||||
|
||||
public $rules = [
|
||||
'title' => array('required'),
|
||||
'price' => array('required', 'numeric', 'min:0'),
|
||||
'start_sale_date' => array('date'),
|
||||
'end_sale_date' => array('date', 'after:start_sale_date'),
|
||||
'quantity_available' => ['integer', 'min:0']
|
||||
];
|
||||
public $messages = [
|
||||
'price.numeric' => 'The price must be a valid number (e.g 12.50)',
|
||||
'title.required' => 'You must at least give a title for your ticket. (e.g Early Bird)',
|
||||
'quantity_available.integer' => 'Please ensure the quantity available is a number.'
|
||||
];
|
||||
|
||||
public function event() {
|
||||
return $this->belongsTo('\App\Models\Event');
|
||||
}
|
||||
|
||||
public function order() {
|
||||
return $this->belongsToMany('\App\Models\Order');
|
||||
}
|
||||
|
||||
public function questions() {
|
||||
return $this->belongsToMany('\App\Models\Question', 'ticket_question');
|
||||
}
|
||||
|
||||
public function reserved() {
|
||||
|
||||
}
|
||||
|
||||
public function scopeSoldOut($query) {
|
||||
$query->where('remaining_tickets', '=', 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Getters & Setters
|
||||
*/
|
||||
|
||||
public function getDates() {
|
||||
return array('created_at', 'updated_at', 'start_sale_date', 'end_sale_date');
|
||||
}
|
||||
|
||||
public function getQuantityRemainingAttribute() {
|
||||
|
||||
if(is_null($this->quantity_available)) {
|
||||
return 9999; //Better way to do this?
|
||||
}
|
||||
|
||||
return $this->quantity_available - ($this->quantity_sold + $this->quantity_reserved);
|
||||
}
|
||||
|
||||
public function getQuantityReservedAttribute() {
|
||||
|
||||
$reserved_total = \DB::table('reserved_tickets')
|
||||
->where('ticket_id', $this->id)
|
||||
->where('expires', '>', \Carbon::now())
|
||||
->sum('quantity_reserved');
|
||||
|
||||
|
||||
return $reserved_total;
|
||||
}
|
||||
|
||||
|
||||
public function getBookingFeeAttribute () {
|
||||
return (int)ceil($this->price) === 0 ? 0 : round(($this->price * (TICKET_BOOKING_FEE_PERCENTAGE / 100)) + (TICKET_BOOKING_FEE_FIXED), 2);
|
||||
}
|
||||
|
||||
public function getOrganiserBookingFeeAttribute() {
|
||||
return (int)ceil($this->price) === 0 ? 0 : round(($this->price * ($this->event->organiser_fee_percentage / 100)) + ($this->event->organiser_fee_fixed), 2);
|
||||
}
|
||||
|
||||
public function getTotalBookingFeeAttribute() {
|
||||
return $this->getBookingFeeAttribute() + $this->getOrganiserBookingFeeAttribute();
|
||||
}
|
||||
|
||||
public function getTotalPriceAttribute() {
|
||||
return $this->getTotalBookingFeeAttribute() + $this->price;
|
||||
}
|
||||
|
||||
public function getTicketMaxMinRangAttribute() {
|
||||
$range = [];
|
||||
|
||||
for($i=$this->min_per_person; $i<=$this->max_per_person; $i++) {
|
||||
$range[] = [$i => $i];
|
||||
}
|
||||
|
||||
return $range;
|
||||
}
|
||||
|
||||
|
||||
public function isFree() {
|
||||
return (int)ceil($this->price) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the maximum figure to go to on dropdowns
|
||||
*
|
||||
* @return int
|
||||
|
||||
public function getMaxPerPersonMaxValueAttribute() {
|
||||
return $this->max_per_person === -1 ? MAX_TICKETS_PER_PERSON : $this->max_per_person;
|
||||
}
|
||||
*/
|
||||
public function getSaleStatusAttribute() {
|
||||
|
||||
if ($this->start_sale_date !== NULL) {
|
||||
if ($this->start_sale_date->isFuture()) {
|
||||
return TICKET_STATUS_BEFORE_SALE_DATE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($this->end_sale_date !== NULL) {
|
||||
if ($this->end_sale_date->isPast()) {
|
||||
return TICKET_STATUS_AFTER_SALE_DATE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((int)$this->quantity_available > 0) {
|
||||
if ((int)$this->quantity_remaining <= 0) {
|
||||
return TICKET_STATUS_SOLD_OUT;
|
||||
}
|
||||
}
|
||||
|
||||
if($this->event->start_date->lte(\Carbon::now())) {
|
||||
return TICKET_STATUS_OFF_SALE;
|
||||
}
|
||||
|
||||
return TICKET_STATUS_ON_SALE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// public function setQuantityAvailableAttribute($value) {
|
||||
// $this->attributes['quantity_available'] = trim($value) == '' ? -1 : $value;
|
||||
// }
|
||||
//
|
||||
// public function setMaxPerPersonAttribute($value) {
|
||||
// $this->attributes['max_per_person'] = trim($value) == '' ? -1 : $value;
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of TicketStatuses
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class TicketStatus extends \Illuminate\Database\Eloquent\Model {
|
||||
//put your code here
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
|
||||
/*
|
||||
Attendize.com - Event Management & Ticketing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of Timezone
|
||||
*
|
||||
* @author Dave
|
||||
*/
|
||||
class Timezone extends \Illuminate\Database\Eloquent\Model {
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Auth\Passwords\CanResetPassword;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
|
||||
|
||||
use Authenticatable, CanResetPassword, SoftDeletes;
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'users';
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = array('password');
|
||||
|
||||
public function account() {
|
||||
return $this->belongsTo('\App\Models\Account');
|
||||
}
|
||||
|
||||
public function activity() {
|
||||
return $this->hasMany('\App\Models\Activity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unique identifier for the user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthIdentifier() {
|
||||
return $this->getKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthPassword() {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the e-mail address where password reminders are sent.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getReminderEmail() {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getRememberToken() {
|
||||
return $this->remember_token;
|
||||
}
|
||||
|
||||
public function setRememberToken($value) {
|
||||
$this->remember_token = $value;
|
||||
}
|
||||
|
||||
public function getRememberTokenName() {
|
||||
return 'remember_token';
|
||||
}
|
||||
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
static::creating(function($user) {
|
||||
$user->confirmation_code = str_random();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Request;
|
||||
use App\Models\Organiser;
|
||||
use Auth;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot() {
|
||||
|
||||
require app_path('Attendize/constants.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* This service provider is a great spot to register your various container
|
||||
* bindings with the application. As you can see, we are registering our
|
||||
* "Registrar" implementation here. You can add your own bindings too!
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register() {
|
||||
|
||||
|
||||
|
||||
$this->app->bind(
|
||||
'Illuminate\Contracts\Auth\Registrar', 'App\Services\Registrar'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Bus\Dispatcher;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BusServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @param \Illuminate\Bus\Dispatcher $dispatcher
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Dispatcher $dispatcher)
|
||||
{
|
||||
$dispatcher->mapUsing(function($command)
|
||||
{
|
||||
return Dispatcher::simpleMapping(
|
||||
$command, 'App\Commands', 'App\Handlers\Commands'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ConfigServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Overwrite any vendor / package configuration.
|
||||
*
|
||||
* This service provider is intended to provide a convenient location for you
|
||||
* to overwrite any "vendor" or package configuration that you may want to
|
||||
* modify before the application handles the incoming request / command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
config([
|
||||
//
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* The event handler mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'event.name' => [
|
||||
'EventListener',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any other events for your application.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @return void
|
||||
*/
|
||||
public function boot(DispatcherContract $events)
|
||||
{
|
||||
parent::boot($events);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class HelpersServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Bootstrap the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
require app_path('Helpers/helpers.php');
|
||||
require app_path('Helpers/macros.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* This namespace is applied to the controller routes in your routes file.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
{
|
||||
parent::boot($router);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
* @return void
|
||||
*/
|
||||
public function map(Router $router)
|
||||
{
|
||||
$router->group(['namespace' => $this->namespace], function($router)
|
||||
{
|
||||
require app_path('Http/routes.php');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php namespace App\Services;
|
||||
|
||||
use App\User;
|
||||
use Validator;
|
||||
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
|
||||
|
||||
class Registrar implements RegistrarContract {
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
public function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|confirmed|min:6',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return User
|
||||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Auth\Passwords\CanResetPassword;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
|
||||
|
||||
use Authenticatable, CanResetPassword;
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'users';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name', 'email', 'password'];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader
|
||||
| for our application. We just need to utilize it! We'll require it
|
||||
| into the script here so that we do not have to worry about the
|
||||
| loading of any our classes "manually". Feels great to relax.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/bootstrap/autoload.php';
|
||||
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Run The Artisan Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When we run the console application, the current CLI command will be
|
||||
| executed in this console and the response sent back to a terminal
|
||||
| or another output device for the developers. Here goes nothing!
|
||||
|
|
||||
*/
|
||||
|
||||
$kernel = $app->make('Illuminate\Contracts\Console\Kernel');
|
||||
|
||||
$status = $kernel->handle(
|
||||
$input = new Symfony\Component\Console\Input\ArgvInput,
|
||||
new Symfony\Component\Console\Output\ConsoleOutput
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Shutdown The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Once Artisan has finished running. We will fire off the shutdown events
|
||||
| so that any final work may be done by the application before we shut
|
||||
| down the process. This is the last thing to happen to the request.
|
||||
|
|
||||
*/
|
||||
|
||||
$kernel->terminate($input, $status);
|
||||
|
||||
exit($status);
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The first thing we will do is create a new Laravel application instance
|
||||
| which serves as the "glue" for all the components of Laravel, and is
|
||||
| the IoC container for the system binding all of the various parts.
|
||||
|
|
||||
*/
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
realpath(__DIR__.'/../')
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bind Important Interfaces
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, we need to bind some important interfaces into the container so
|
||||
| we will be able to resolve them when needed. The kernels serve the
|
||||
| incoming requests to this application from both the web and CLI.
|
||||
|
|
||||
*/
|
||||
|
||||
$app->singleton(
|
||||
'Illuminate\Contracts\Http\Kernel',
|
||||
'App\Http\Kernel'
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
'Illuminate\Contracts\Console\Kernel',
|
||||
'App\Console\Kernel'
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
'Illuminate\Contracts\Debug\ExceptionHandler',
|
||||
'App\Exceptions\Handler'
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This script returns the application instance. The instance is given to
|
||||
| the calling script so we can separate the building of the instances
|
||||
| from the actual running of the application and sending responses.
|
||||
|
|
||||
*/
|
||||
|
||||
return $app;
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Composer Auto Loader
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader
|
||||
| for our application. We just need to utilize it! We'll require it
|
||||
| into the script here so that we do not have to worry about the
|
||||
| loading of any our classes "manually". Feels great to relax.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Include The Compiled Class File
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| To dramatically increase your application's performance, you may use a
|
||||
| compiled class file which contains all of the classes commonly used
|
||||
| by a request. The Artisan "optimize" is used to create this file.
|
||||
|
|
||||
*/
|
||||
|
||||
$compiledPath = __DIR__.'/cache/compiled.php';
|
||||
|
||||
if (file_exists($compiledPath))
|
||||
{
|
||||
require $compiledPath;
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "Attendize",
|
||||
"version": "1.0.0",
|
||||
"authors": [
|
||||
"david4ie <dave@earley.email>"
|
||||
],
|
||||
"description": "Ticketing Platform",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"dependencies": {
|
||||
"bootstrap": "~3.2.0",
|
||||
"curioussolutions-datetimepicker": "~0.1.1",
|
||||
"humane-js": "~3.2.0",
|
||||
"chartjs": "~0.2.0",
|
||||
"geocomplete": "~1.6.4",
|
||||
"wysiwyg-editor": "~1.2.3",
|
||||
"modernizr": "~2.8.3",
|
||||
"jquery-form": "malsup/form#~3.46.0",
|
||||
"RRSSB": "~1.6.0",
|
||||
"jquery-backstretch": "~2.0.4",
|
||||
"flot": "~0.8.3",
|
||||
"morrisjs": "~0.5.1",
|
||||
"jquery.countdown": "~2.0.4",
|
||||
"fontawesome": "~4.2.0",
|
||||
"jquery-fastLiveFilter": "awbush/jquery-fastLiveFilter#~1.0.3",
|
||||
"hint.css": "~1.3.3",
|
||||
"wysihtml": "~0.4.17",
|
||||
"bootstrap-touchspin": "~3.0.1",
|
||||
"simplemde": "~1.8.1"
|
||||
},
|
||||
"resolutions": {
|
||||
"jquery": ">=1.5"
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue