|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Event; |
|
6
|
|
|
use App\Country; |
|
|
|
|
|
|
7
|
|
|
use App\Teacher; |
|
8
|
|
|
use App\Continent; |
|
|
|
|
|
|
9
|
|
|
use App\EventVenue; |
|
10
|
|
|
use App\EventCategory; |
|
11
|
|
|
use App\BackgroundImage; |
|
|
|
|
|
|
12
|
|
|
use Illuminate\Http\Request; |
|
13
|
|
|
use Illuminate\Support\Facades\Cache; |
|
14
|
|
|
use App\Http\Resources\Continent as ContinentResource; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
class EventSearchController extends Controller |
|
17
|
|
|
{ |
|
18
|
|
|
// ********************************************************************** |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Display the event search results in Global Calendar Homepage. |
|
22
|
|
|
* @param \Illuminate\Http\Request $request |
|
23
|
|
|
* @return \Illuminate\Http\Response |
|
24
|
|
|
*/ |
|
25
|
|
|
public function index(Request $request) |
|
26
|
|
|
{ |
|
27
|
|
|
$cacheExpireTime = 900; // expressed in seconds (15 min) |
|
28
|
|
|
|
|
29
|
|
|
$backgroundImages = BackgroundImage::all(); |
|
30
|
|
|
|
|
31
|
|
|
$eventCategories = Cache::remember('categories', $cacheExpireTime, function () { |
|
32
|
|
|
return EventCategory::orderBy('name')->pluck('name', 'id'); |
|
33
|
|
|
}); |
|
34
|
|
|
|
|
35
|
|
|
// Get the countries with active events |
|
36
|
|
|
$activeEvents = Event::getActiveEvents(); |
|
37
|
|
|
$countries = $activeEvents->unique('country_name')->sortBy('country_name')->pluck('country_name', 'country_id'); |
|
38
|
|
|
//$cities = $activeEvents->unique('city')->toArray(); |
|
39
|
|
|
$activeContinentsCountries = ContinentResource::collection(Continent::all()); |
|
40
|
|
|
|
|
41
|
|
|
$continents = Cache::rememberForever('continents', function () { |
|
42
|
|
|
return Continent::orderBy('name')->pluck('name', 'id'); |
|
43
|
|
|
}); |
|
44
|
|
|
|
|
45
|
|
|
$venues = Cache::remember('venues', $cacheExpireTime, function () { |
|
46
|
|
|
return EventVenue::pluck('name', 'id'); |
|
47
|
|
|
}); |
|
48
|
|
|
|
|
49
|
|
|
$teachers = Cache::remember('teachers', $cacheExpireTime, function () { |
|
50
|
|
|
return Teacher::orderBy('name')->pluck('name', 'id'); |
|
51
|
|
|
}); |
|
52
|
|
|
|
|
53
|
|
|
$filters = []; |
|
54
|
|
|
$filters['keywords'] = $request->input('keywords'); |
|
55
|
|
|
$filters['category'] = $request->input('category_id'); |
|
56
|
|
|
$filters['country'] = $request->input('country_id'); |
|
57
|
|
|
$filters['city'] = $request->input('city_name'); |
|
58
|
|
|
$filters['continent'] = $request->input('continent_id'); |
|
59
|
|
|
$filters['teacher'] = $request->input('teacher_id'); |
|
60
|
|
|
$filters['venue'] = $request->input('venue_name'); |
|
61
|
|
|
$filters['startDate'] = Event::prepareStartDate($request->input('startDate')); |
|
62
|
|
|
$filters['endDate'] = Event::prepareEndDate($request->input('endDate')); |
|
63
|
|
|
|
|
64
|
|
|
$events = Event::getEvents($filters, 20); |
|
65
|
|
|
|
|
66
|
|
|
return view('eventSearch.index', compact('events')) |
|
67
|
|
|
->with('i', (request()->input('page', 1) - 1) * 20) |
|
68
|
|
|
->with('eventCategories', $eventCategories) |
|
69
|
|
|
->with('continents', $continents) |
|
70
|
|
|
->with('countries', $countries) |
|
71
|
|
|
->with('venues', $venues) |
|
72
|
|
|
->with('teachers', $teachers) |
|
73
|
|
|
->with('searchKeywords', $filters['keywords']) |
|
74
|
|
|
->with('searchCategory', $filters['category']) |
|
75
|
|
|
->with('searchCountry', $filters['country']) |
|
76
|
|
|
->with('searchContinent', $filters['continent']) |
|
77
|
|
|
->with('searchCity', $filters['city']) |
|
78
|
|
|
->with('searchTeacher', $filters['teacher']) |
|
79
|
|
|
->with('searchVenue', $filters['venue']) |
|
80
|
|
|
->with('searchStartDate', $request->input('startDate')) |
|
81
|
|
|
->with('searchEndDate', $request->input('endDate')) |
|
82
|
|
|
->with('backgroundImages', $backgroundImages) |
|
83
|
|
|
->with('activeContinentsCountries', $activeContinentsCountries); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Display the specified resource. |
|
88
|
|
|
* |
|
89
|
|
|
* @param \App\Event $event |
|
90
|
|
|
* @param int $id |
|
91
|
|
|
* @return \Illuminate\Http\Response |
|
92
|
|
|
*/ |
|
93
|
|
|
public function show(Event $event, $id) |
|
|
|
|
|
|
94
|
|
|
{ |
|
95
|
|
|
$event = Event::where('id', $id)->first(); |
|
96
|
|
|
|
|
97
|
|
|
return view('eventSearch.show', compact('event')); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/***************************************************************************/ |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Return and HTML with all the events of a specific country by country CODE. (eg. http://websitename.com/eventSearch/country/SI) |
|
104
|
|
|
* this should be included in the IFRAME for the regional websites. |
|
105
|
|
|
* |
|
106
|
|
|
* @param string $code |
|
107
|
|
|
* @return \Illuminate\Http\Response |
|
108
|
|
|
*/ |
|
109
|
|
|
public function EventsListByCountry($code) |
|
110
|
|
|
{ |
|
111
|
|
|
$country = Country::where('code', $code)->first(); |
|
112
|
|
|
|
|
113
|
|
|
$filters = []; |
|
114
|
|
|
$filters['keywords'] = $filters['category'] = $filters['city'] = $filters['continent'] = $filters['teacher'] = $filters['venue'] = $filters['startDate'] = $filters['endDate'] = null; |
|
115
|
|
|
$filters['country'] = $country->id; |
|
116
|
|
|
$events = Event::getEvents($filters, null); |
|
117
|
|
|
|
|
118
|
|
|
$cacheExpireTime = 900; // Set the duration time of the cache (15 min - 900sec) |
|
119
|
|
|
$eventCategories = Cache::remember('categories', $cacheExpireTime, function () { |
|
120
|
|
|
return EventCategory::orderBy('name')->pluck('name', 'id'); |
|
121
|
|
|
}); |
|
122
|
|
|
|
|
123
|
|
|
return view('eventSearch.index-iframe', compact('events')) |
|
124
|
|
|
->with('country', $country) |
|
125
|
|
|
->with('eventCategories', $eventCategories); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/***************************************************************************/ |
|
129
|
|
|
} |
|
130
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths