Attendize/app/Http/Controllers/MyBaseController.php

70 lines
1.7 KiB
PHP
Raw Normal View History

2016-03-05 00:18:10 +00:00
<?php
namespace App\Http\Controllers;
2016-02-29 15:59:36 +00:00
use App\Models\Event;
2016-03-05 00:18:10 +00:00
2016-02-29 15:59:36 +00:00
use App\Models\Organiser;
use Auth;
use JavaScript;
2016-02-29 15:59:36 +00:00
use View;
2016-03-05 00:18:10 +00:00
class MyBaseController extends Controller
{
2016-02-29 15:59:36 +00:00
public function __construct()
{
/*
* Set up JS across all views
*/
JavaScript::put([
'User' => [
'full_name' => Auth::user()->full_name,
'email' => Auth::user()->email,
'is_confirmed' => Auth::user()->is_confirmed,
],
/*
2016-06-15 02:31:24 +00:00
* @todo These should be user selectable
*/
2016-06-15 02:31:24 +00:00
'DateFormat' => 'dd-MM-yyyy',
'DateTimeFormat' => 'dd-MM-yyyy hh:mm',
2016-06-15 02:31:24 +00:00
'GenericErrorMessage' => 'Whoops! An unknown error has occurred. Please try again or contact support if the problem persists.'
]);
/*
* Share the organizers across all views
*/
2016-02-29 15:59:36 +00:00
View::share('organisers', Organiser::scope()->get());
}
/**
* Returns data which is required in each view, optionally combined with additional data.
2016-03-05 00:18:10 +00:00
*
* @param int $event_id
2016-02-29 15:59:36 +00:00
* @param array $additional_data
2016-03-05 00:18:10 +00:00
*
2016-02-29 15:59:36 +00:00
* @return arrau
*/
2016-03-05 00:18:10 +00:00
public function getEventViewData($event_id, $additional_data = [])
{
$event = Event::scope()->findOrFail($event_id);
2016-03-05 00:18:10 +00:00
return array_merge([
'event' => $event,
'questions' => $event->questions()->get(),
], $additional_data);
2016-02-29 15:59:36 +00:00
}
/**
* Setup the layout used by the controller.
*
* @return void
*/
protected function setupLayout()
{
if (!is_null($this->layout)) {
$this->layout = View::make($this->layout);
}
}
2016-02-29 15:59:36 +00:00
}