web.php 109 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238
  1. <?php
  2. use Illuminate\Support\Facades\Route;
  3. use App\News;
  4. use App\BreakingNews;
  5. use App\Section;
  6. use App\Home;
  7. use App\Page;
  8. use App\PageAdv;
  9. use App\SectionAdv;
  10. use App\Event;
  11. use App\Season;
  12. use App\Video;
  13. use App\Calendar;
  14. use App\Category;
  15. use App\Group;
  16. use App\CalendarGame;
  17. use App\Notifications\FacebookPost;
  18. use App\Notifications\TwitterPost;
  19. /*
  20. |--------------------------------------------------------------------------
  21. | Web Routes
  22. |--------------------------------------------------------------------------
  23. |
  24. | Here is where you can register web routes for your application. These
  25. | routes are loaded by the RouteServiceProvider within a group which
  26. | contains the "web" middleware group. Now create something great!
  27. |
  28. */
  29. ini_set("auto_detect_line_endings", true);
  30. date_default_timezone_set('Europe/Rome');
  31. Route::get('/test_fb', function(){
  32. print env('FACEBOOK_ACCESS_TOKEN', '');
  33. $n = News::findOrFail(41436);
  34. $n->notify(new FacebookPost());
  35. });
  36. Route::get('/update/sections', function () {
  37. $aPositions = array('big', 'small1', 'small2', 'small3', 'small4', 'small5', 'small6');
  38. $sections = Section::all();
  39. foreach($sections as $section)
  40. {
  41. print $section->name . "<br>";
  42. $section_id = $section->id;
  43. // Carico il layout
  44. $layout = $section->layout;
  45. /*$aExist = array();
  46. foreach($aPositions as $p)
  47. {
  48. if ($section[$p] != null)
  49. $aExist[] = $section[$p];
  50. }*/
  51. // Controllo se ci sono news che devono essere pubblicate appartenenti a questa sezione
  52. $checks = News::where('date', '<=', date('Y-m-d H:i:s'))->where('online', '=', true)->where(function ($q) use ($section_id) {
  53. $q->where('region_1_id', '=', $section_id)->orWhere('region_2_id', '=', $section_id)->orWhere('section_id', '=', $section_id);
  54. })->where(function ($q) {
  55. $q->where('region_1_position', '<>', '')->orWhere('region_2_position', '<>', '')->orWhere('section_position', '<>', '');
  56. })->get();
  57. foreach($checks as $n)
  58. {
  59. // Controllo se questa news era già in qualche altra posizione
  60. $old_position = Section::where('big', '=', $n->id)
  61. ->orWhere('small1', '=', $n->id)
  62. ->orWhere('small2', '=', $n->id)
  63. ->orWhere('small3', '=', $n->id)
  64. ->orWhere('small4', '=', $n->id)
  65. ->orWhere('small5', '=', $n->id)
  66. ->orWhere('small6', '=', $n->id)->get();
  67. if ($old_position->count() > 0)
  68. {
  69. foreach($old_position as $old_p)
  70. {
  71. foreach($aPositions as $p)
  72. {
  73. if ($old_p[$p] == $n->id)
  74. {
  75. $old_p[$p] = '';
  76. $old_p->save();
  77. }
  78. }
  79. }
  80. }
  81. // Metto la news nella posizione dove deve essere messa
  82. foreach($aPositions as $p)
  83. {
  84. if ($n->section_id == $section_id && $n->section_position == $p)
  85. {
  86. print "Metto la news " . $n->title . " nella posizione " . $p . " della sezione/regione " . $section->name . "<br>";
  87. $section[$p] = $n->id;
  88. $section->save();
  89. $n->section_position = '';
  90. if (!$n->published)
  91. {
  92. //$n->notify(new FacebookPost());
  93. //$n->notify(new TwitterPost());
  94. $n->published = true;
  95. }
  96. $n->save();
  97. }
  98. if ($n->region_1_id == $section_id && $n->region_1_position == $p)
  99. {
  100. print "Metto la news " . $n->title . " nella posizione " . $p . " della sezione/regione " . $section->name . "<br>";
  101. $section[$p] = $n->id;
  102. $section->save();
  103. $n->region_1_position = '';
  104. if (!$n->published)
  105. {
  106. // $n->notify(new FacebookPost());
  107. $n->notify(new TwitterPost());
  108. $n->published = true;
  109. }
  110. $n->save();
  111. }
  112. if ($n->region_2_id == $section_id && $n->region_2_position == $p)
  113. {
  114. print "Metto la news " . $n->title . " nella posizione " . $p . " della sezione/regione " . $section->name . "<br>";
  115. $section[$p] = $n->id;
  116. $section->save();
  117. $n->region_2_position = '';
  118. if (!$n->published)
  119. {
  120. // $n->notify(new FacebookPost());
  121. $n->notify(new TwitterPost());
  122. $n->published = true;
  123. }
  124. $n->save();
  125. }
  126. }
  127. }
  128. }
  129. $sections = Section::all();
  130. foreach($sections as $section)
  131. {
  132. $aExist = array();
  133. foreach($aPositions as $p)
  134. {
  135. if ($section[$p] != null)
  136. $aExist[] = $section[$p];
  137. }
  138. // Riempio i vuoti
  139. $news = News::whereNotIn('id', $aExist)->where(function ($q) use ($section_id) {
  140. $q->where('section_id', '=', $section_id)->orWhere('region_1_id', '=', $section_id)->orWhere('region_2_id', '=', $section_id);
  141. })->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
  142. $idx = 0;
  143. if ($section->big == '')
  144. {
  145. $section->big = @$news[$idx]->id;
  146. $idx++;
  147. }
  148. if ($section->small1 == '')
  149. {
  150. $section->small1 = @$news[$idx]->id;
  151. $idx++;
  152. }
  153. if ($section->small2 == '')
  154. {
  155. $section->small2 = @$news[$idx]->id;
  156. $idx++;
  157. }
  158. if ($section->small3 == '')
  159. {
  160. $section->small3 = @$news[$idx]->id;
  161. $idx++;
  162. }
  163. if ($layout == 'layout_3' || $layout == 'layout_4' || $layout == 'layout_5')
  164. {
  165. if ($section->small4 == '')
  166. {
  167. $section->small4 = @$news[$idx]->id;
  168. $idx++;
  169. }
  170. if ($layout == 'layout_4')
  171. {
  172. if ($section->small5 == '')
  173. {
  174. $section->small5 = @$news[$idx]->id;
  175. $idx++;
  176. }
  177. if ($section->small6 == '')
  178. {
  179. $section->small6 = @$news[$idx]->id;
  180. $idx++;
  181. }
  182. }
  183. else
  184. {
  185. $section->small5 = '';
  186. $section->small6 = '';
  187. }
  188. }
  189. else
  190. {
  191. $section->small4 = '';
  192. $section->small5 = '';
  193. $section->small6 = '';
  194. }
  195. $section->save();
  196. }
  197. });
  198. Route::get('sitemap.xml', function() {
  199. // create new sitemap object
  200. $sitemap = App::make('sitemap');
  201. // set cache key (string), duration in minutes (Carbon|Datetime|int), turn on/off (boolean)
  202. // by default cache is disabled
  203. $sitemap->setCache('laravel.sitemap', 60);
  204. // check if there is cached sitemap and build new only if is not
  205. if (!$sitemap->isCached())
  206. {
  207. // add item to the sitemap (url, date, priority, freq)
  208. $sitemap->add(URL::to('/'), date("Y-m-d H:i:s"), '1.0', 'daily');
  209. $sections = Section::orderBy('position')->get();
  210. foreach($sections as $section)
  211. $sitemap->add(URL::to('/' . $section->slug), date("Y-m-d H:i:s", strtotime($section->updated_at)), '0.9', 'daily');
  212. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  213. foreach($pages as $page)
  214. $sitemap->add(URL::to('/' . $page->slug), date("Y-m-d H:i:s", strtotime($page->updated_at)), '0.9', 'daily');
  215. $events = Event::where('online', '=', true)->orderBy('title')->get();
  216. foreach($events as $event)
  217. $sitemap->add(URL::to('/' . $event->slug), date("Y-m-d H:i:s", strtotime($event->updated_at)), '0.9', 'daily');
  218. $season_id = @Season::where('default', '=', true)->first()->id;
  219. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  220. $calendars = array();
  221. foreach($cals as $c)
  222. {
  223. if ($c->category->grp != '')
  224. {
  225. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  226. if ($c->group_id > 0)
  227. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  228. else
  229. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  230. }
  231. }
  232. foreach($calendars as $type => $categories)
  233. {
  234. foreach($categories as $category => $groups)
  235. {
  236. if(is_array($groups))
  237. {
  238. foreach($groups as $group => $cal)
  239. {
  240. $sitemap->add(URL::to('/calendario/' . Str::slug($category) . "-" . Str::slug($group) . "/" . $cal), date("Y-m-d H:i:s"), '0.9', 'daily');
  241. }
  242. }
  243. else
  244. $sitemap->add(URL::to('/calendario/' . Str::slug($category) . "-" . Str::slug($groups)), date("Y-m-d H:i:s"), '0.9', 'daily');
  245. }
  246. }
  247. //$news = News::where('online', '=', true)->where('breaking_news', '=', false)->orderBy('date', 'DESC')->get();
  248. //foreach($news as $n)
  249. // $sitemap->add(URL::to('/' . $n->slug), date("Y-m-d H:i:s", strtotime($n->updated_at)), '0.9', 'hourly');
  250. //$cals = Calendar::orderBy('position')->get();
  251. //foreach($cals as $c)
  252. // $sitemap->add(URL::to('/' . $c->slug), date("Y-m-d H:i:s", strtotime($c->updated_at)), '0.9', 'daily');
  253. /*
  254. //$sitemap->add(URL::to('page'), '2012-08-26T12:30:00+02:00', '0.9', 'monthly');
  255. /*
  256. // add item with translations (url, date, priority, freq, images, title, translations)
  257. $translations = [
  258. ['language' => 'fr', 'url' => URL::to('pageFr')],
  259. ['language' => 'de', 'url' => URL::to('pageDe')],
  260. ['language' => 'bg', 'url' => URL::to('pageBg')],
  261. ];
  262. $sitemap->add(URL::to('pageEn'), '2015-06-24T14:30:00+02:00', '0.9', 'monthly', [], null, $translations);
  263. // add item with images
  264. $images = [
  265. ['url' => URL::to('images/pic1.jpg'), 'title' => 'Image title', 'caption' => 'Image caption', 'geo_location' => 'Plovdiv, Bulgaria'],
  266. ['url' => URL::to('images/pic2.jpg'), 'title' => 'Image title2', 'caption' => 'Image caption2'],
  267. ['url' => URL::to('images/pic3.jpg'), 'title' => 'Image title3'],
  268. ];
  269. $sitemap->add(URL::to('post-with-images'), '2015-06-24T14:30:00+02:00', '0.9', 'monthly', $images);
  270. // get all posts from db
  271. $posts = DB::table('posts')->orderBy('created_at', 'desc')->get();
  272. // add every post to the sitemap
  273. foreach ($posts as $post) {
  274. $sitemap->add($post->slug, $post->modified, $post->priority, $post->freq);
  275. }*/
  276. }
  277. // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
  278. return $sitemap->render('xml');
  279. });
  280. Route::get('/', function () {
  281. $home = Home::first();
  282. if ($home != null)
  283. $home->loadData();
  284. $aHome = array();
  285. if ($home->image != '')
  286. {
  287. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  288. }
  289. if ($home->image_2 != '')
  290. {
  291. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  292. }
  293. if ($home->image_3 != '')
  294. {
  295. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  296. }
  297. if ($home->image_4 != '')
  298. {
  299. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  300. }
  301. if ($home->image_5 != '')
  302. {
  303. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  304. }
  305. if (sizeof($aHome) > 0)
  306. {
  307. $rnd = 0;//rand (0, sizeof($aHome) - 1);
  308. $home->image = $aHome[$rnd]["image"];
  309. $home->url = $aHome[$rnd]["url"];
  310. }
  311. $show_top = true;
  312. if ($home->banner_right_big != '' || $home->banner_right_big_2 != '' || $home->banner_right_big_3 != '' || $home->banner_right_big_google != '')
  313. $show_top = false;
  314. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  315. $events = Event::where('online', '=', true)->orderBy('title')->get();
  316. // $sections = Section::where('type', '=', 'section')->orderBy('position')->get();
  317. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  318. $sections = Section::where('layout', '!=', '')->orderBy('position')->get();
  319. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  320. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  321. //if($breaking_news->count() == 0)
  322. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  323. $videos = Video::where('online', '=', true)->limit(10)->orderBy('position')->get();
  324. foreach($videos as $i => $v)
  325. {
  326. $x = $v->url;
  327. $x = str_replace("https", "", $x);
  328. $x = str_replace("http", "", $x);
  329. $v->url = $x;
  330. }
  331. $season_id = @Season::where('default', '=', true)->first()->id;
  332. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  333. $calendars = array();
  334. foreach($cals as $c)
  335. {
  336. if ($c->category->grp != '')
  337. {
  338. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  339. if ($c->group_id > 0)
  340. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  341. else
  342. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  343. }
  344. }
  345. // $sections_after = Section::where('type', '=', 'section')->where('after', '=', true)->where('layout', '!=', '')->orderBy('position')->get();
  346. return view('index', compact('home', 'sections', 'sections_menu', 'regions', 'pages', 'breaking_news', 'videos', 'events', 'calendars', 'aHome', 'show_top'));
  347. });
  348. Route::get('/videos', function(){
  349. $videos = Video::where('online', '=', true)->orderBy('date', 'DESC')->get();
  350. $home = Home::first();
  351. if ($home != null)
  352. $home->loadData();
  353. $aHome = array();
  354. if ($home->image != '')
  355. {
  356. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  357. }
  358. if ($home->image_2 != '')
  359. {
  360. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  361. }
  362. if ($home->image_3 != '')
  363. {
  364. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  365. }
  366. if ($home->image_4 != '')
  367. {
  368. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  369. }
  370. if ($home->image_5 != '')
  371. {
  372. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  373. }
  374. if (sizeof($aHome) > 0)
  375. {
  376. $rnd = rand (0, sizeof($aHome) - 1);
  377. $home->image = $aHome[$rnd]["image"];
  378. $home->url = $aHome[$rnd]["url"];
  379. }
  380. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  381. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  382. $events = Event::where('online', '=', true)->orderBy('title')->get();
  383. $sections = Section::orderBy('position')->get();
  384. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  385. //if($breaking_news->count() == 0)
  386. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  387. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  388. $season_id = @Season::where('default', '=', true)->first()->id;
  389. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  390. /*$calendars = array();
  391. foreach($cals as $c)
  392. {
  393. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  394. if ($c->group_id > 0)
  395. $calendars[$type][$c->category->name][$c->group->name] = $c->id;
  396. else
  397. $calendars[$type][$c->category->name] = $c->id;
  398. }*/
  399. $calendars = array();
  400. foreach($cals as $c)
  401. {
  402. if ($c->category->grp != '')
  403. {
  404. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  405. if ($c->group_id > 0)
  406. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  407. else
  408. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  409. }
  410. }
  411. return view('video', compact('videos', 'home', 'sections', 'sections_menu', 'regions', 'pages', 'breaking_news', 'videos', 'events', 'calendars', 'aHome'));
  412. });
  413. Route::get('/ricerca', function(){
  414. $news = News::where('id', -1)->get();
  415. $home = Home::first();
  416. if ($home != null)
  417. $home->loadData();
  418. $aHome = array();
  419. if ($home->image != '')
  420. {
  421. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  422. }
  423. if ($home->image_2 != '')
  424. {
  425. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  426. }
  427. if ($home->image_3 != '')
  428. {
  429. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  430. }
  431. if ($home->image_4 != '')
  432. {
  433. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  434. }
  435. if ($home->image_5 != '')
  436. {
  437. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  438. }
  439. if (sizeof($aHome) > 0)
  440. {
  441. $rnd = rand (0, sizeof($aHome) - 1);
  442. $home->image = $aHome[$rnd]["image"];
  443. $home->url = $aHome[$rnd]["url"];
  444. }
  445. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  446. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  447. $events = Event::where('online', '=', true)->orderBy('title')->get();
  448. $sections = Section::orderBy('position')->get();
  449. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  450. //if($breaking_news->count() == 0)
  451. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  452. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  453. $season_id = @Season::where('default', '=', true)->first()->id;
  454. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  455. $calendars = array();
  456. foreach($cals as $c)
  457. {
  458. if ($c->category->grp != '')
  459. {
  460. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  461. if ($c->group_id > 0)
  462. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  463. else
  464. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  465. }
  466. }
  467. $search = '';
  468. $videos = array();
  469. return view('search', compact('news', 'search', 'home', 'sections', 'sections_menu', 'regions', 'pages', 'breaking_news', 'videos', 'events', 'calendars', 'aHome'));
  470. });
  471. Route::post('/ricerca', function(){
  472. $search = $_POST["search"];
  473. if ($search != '')
  474. {
  475. $news = News::where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->where(function ($q) use ($search) {
  476. $q->where('title', 'like', '%' . $search . '%')
  477. ->orWhere('title_region_1', 'like', '%' . $search . '%')
  478. ->orWhere('title_region_2', 'like', '%' . $search . '%')
  479. ->orWhere('text_short', 'like', '%' . $search . '%')
  480. ->orWhere('text', 'like', '%' . $search . '%');
  481. })->orderBy('date', 'DESC')->get();
  482. }
  483. else
  484. $news = News::where('id', -1)->get();
  485. $home = Home::first();
  486. if ($home != null)
  487. $home->loadData();
  488. $aHome = array();
  489. if ($home->image != '')
  490. {
  491. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  492. }
  493. if ($home->image_2 != '')
  494. {
  495. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  496. }
  497. if ($home->image_3 != '')
  498. {
  499. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  500. }
  501. if ($home->image_4 != '')
  502. {
  503. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  504. }
  505. if ($home->image_5 != '')
  506. {
  507. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  508. }
  509. if (sizeof($aHome) > 0)
  510. {
  511. $rnd = rand (0, sizeof($aHome) - 1);
  512. $home->image = $aHome[$rnd]["image"];
  513. $home->url = $aHome[$rnd]["url"];
  514. }
  515. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  516. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  517. $events = Event::where('online', '=', true)->orderBy('title')->get();
  518. $sections = Section::orderBy('position')->get();
  519. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  520. //if($breaking_news->count() == 0)
  521. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  522. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  523. $season_id = @Season::where('default', '=', true)->first()->id;
  524. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  525. $calendars = array();
  526. foreach($cals as $c)
  527. {
  528. if ($c->category->grp != '')
  529. {
  530. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  531. if ($c->group_id > 0)
  532. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  533. else
  534. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  535. }
  536. }
  537. $videos = array();
  538. return view('search', compact('news', 'search', 'home', 'sections', 'sections_menu', 'regions', 'pages', 'breaking_news', 'videos', 'events', 'calendars', 'aHome'));
  539. });
  540. Route::get('/eventi', function(){
  541. $news = News::where('id', -1)->get();
  542. $home = Home::first();
  543. if ($home != null)
  544. $home->loadData();
  545. $aHome = array();
  546. if ($home->image != '')
  547. {
  548. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  549. }
  550. if ($home->image_2 != '')
  551. {
  552. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  553. }
  554. if ($home->image_3 != '')
  555. {
  556. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  557. }
  558. if ($home->image_4 != '')
  559. {
  560. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  561. }
  562. if ($home->image_5 != '')
  563. {
  564. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  565. }
  566. if (sizeof($aHome) > 0)
  567. {
  568. $rnd = rand (0, sizeof($aHome) - 1);
  569. $home->image = $aHome[$rnd]["image"];
  570. $home->url = $aHome[$rnd]["url"];
  571. }
  572. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  573. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  574. $events = Event::where('online', '=', true)->orderBy('title')->get();
  575. $sections = Section::orderBy('position')->get();
  576. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  577. //if($breaking_news->count() == 0)
  578. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  579. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  580. $season_id = @Season::where('default', '=', true)->first()->id;
  581. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  582. $calendars = array();
  583. foreach($cals as $c)
  584. {
  585. if ($c->category->grp != '')
  586. {
  587. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  588. if ($c->group_id > 0)
  589. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  590. else
  591. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  592. }
  593. }
  594. $videos = array();
  595. return view('events', compact('news', 'home', 'sections', 'sections_menu', 'regions', 'pages', 'breaking_news', 'videos', 'events', 'calendars', 'aHome'));
  596. });
  597. Route::get('/video/{id}', function ($id) {
  598. $video = Video::findOrFail($id);
  599. if ($video->file != '')
  600. {
  601. $html = '<video width="640" height="480" controls>
  602. <source src="/files/videos/' . $video->file . '" type="video/mp4">
  603. Your browser does not support the video tag.
  604. </video>';
  605. print $html;
  606. }
  607. else
  608. print $video->embed;
  609. });
  610. Route::get('/section/{id}', function ($id) {
  611. $home = Home::first();
  612. if ($home != null)
  613. $home->loadData();
  614. $aHome = array();
  615. if ($home->image != '')
  616. {
  617. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  618. }
  619. if ($home->image_2 != '')
  620. {
  621. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  622. }
  623. if ($home->image_3 != '')
  624. {
  625. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  626. }
  627. if (sizeof($aHome) > 0)
  628. {
  629. $rnd = rand (0, sizeof($aHome) - 1);
  630. $home->image = $aHome[$rnd]["image"];
  631. $home->url = $aHome[$rnd]["url"];
  632. }
  633. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  634. $events = Event::where('online', '=', true)->orderBy('title')->get();
  635. //$sections = Section::orderBy('position')->get();
  636. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  637. $sections = Section::where('layout', '!=', '')->orderBy('position')->get();
  638. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  639. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  640. //if($breaking_news->count() == 0)
  641. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  642. $news = News::where('section_id', '=', $id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
  643. $season_id = @Season::where('default', '=', true)->first()->id;
  644. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  645. $calendars = array();
  646. foreach($cals as $c)
  647. {
  648. if ($c->category->grp != '')
  649. {
  650. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  651. if ($c->group_id > 0)
  652. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  653. else
  654. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  655. }
  656. }
  657. return view('section', compact('home', 'news', 'sections', 'sections_menu', 'pages', 'regions', 'events', 'breaking_news', 'calendars', 'aHome'));
  658. });
  659. Route::get('/admin', function () {
  660. if (Auth::check())
  661. return Redirect::to('/admin/dashboard');
  662. else
  663. return view('admin');
  664. });
  665. Route::get('/logout', function () {
  666. Auth::logout();
  667. return Redirect::to('/admin');
  668. });
  669. Route::post('/login', function(){
  670. if ($user = Auth::attempt(['email' => $_POST["email"], 'password' => $_POST["password"]]))
  671. return Redirect::to('/admin/dashboard');
  672. else
  673. return view('admin')->with('message', 'Errore login');
  674. });
  675. Route::group(['middleware' => 'auth'], function () {
  676. Route::prefix('admin')->group(function () {
  677. Route::get('/dashboard', function ()
  678. {
  679. $sections = Section::where('type', '=', 'section')->orderBy('position')->get();
  680. $regions = Section::where('type', '=', 'region')->orderBy('position')->get();
  681. return view('admin.dashboard', compact('sections', 'regions'));
  682. });
  683. Route::get('/home', function () {
  684. $home = Home::first();
  685. if ($home == null)
  686. {
  687. $home = new Home();
  688. $home->save();
  689. }
  690. $home->loadData();
  691. $aAssigned = array();
  692. if ($home->slide1 != '')
  693. $aAssigned[] = $home->slide1->id;
  694. if ($home->left1 != '')
  695. $aAssigned[] = $home->left1->id;
  696. if ($home->left2 != '')
  697. $aAssigned[] = $home->left2->id;
  698. if ($home->left3 != '')
  699. $aAssigned[] = $home->left3->id;
  700. if ($home->right1 != '')
  701. $aAssigned[] = $home->right1->id;
  702. if ($home->right2 != '')
  703. $aAssigned[] = $home->right2->id;
  704. if ($home->right3 != '')
  705. $aAssigned[] = $home->right3->id;
  706. $news = News::where('online', '=', 1)->whereNotIn('id', $aAssigned)->orderBy('date', 'DESC')->limit(1000)->get();
  707. return view('admin.home',compact('home', 'news'));
  708. })->name('home');
  709. Route::post('/home', function () {
  710. $home = Home::first();
  711. if ($home == null)
  712. $home = new Home();
  713. $slide1 = isset($_POST["slide1"]) ? $_POST["slide1"] : '';
  714. $left1 = isset($_POST["left1"]) ? $_POST["left1"] : '';
  715. $left2 = isset($_POST["left2"]) ? $_POST["left2"] : '';
  716. $left3 = isset($_POST["left3"]) ? $_POST["left3"] : '';
  717. $left4 = isset($_POST["left4"]) ? $_POST["left4"] : '';
  718. $left5 = isset($_POST["left5"]) ? $_POST["left5"] : '';
  719. $right1 = isset($_POST["right1"]) ? $_POST["right1"] : '';
  720. $right2 = isset($_POST["right2"]) ? $_POST["right2"] : '';
  721. $right3 = isset($_POST["right3"]) ? $_POST["right3"] : '';
  722. $right4 = isset($_POST["right4"]) ? $_POST["right4"] : '';
  723. $right5 = isset($_POST["right5"]) ? $_POST["right5"] : '';
  724. if (isset($_POST["delete_image"]))
  725. {
  726. $image = '';
  727. $home->image = $image;
  728. }
  729. else
  730. {
  731. if(isset($_POST["image"]))
  732. {
  733. $file = $_POST["image"];
  734. $filename = time() . '_' . $file->getClientOriginalName();
  735. $path = public_path('files');
  736. $_POST["image"]->move($path, $filename);
  737. $image = $filename;
  738. $home->image = $image;
  739. }
  740. }
  741. //$url = isset($_POST["url"]) ? $_POST["url"] : '';
  742. $home->slide1 = $slide1;
  743. $home->left1 = $left1;
  744. $home->left2 = $left2;
  745. $home->left3 = $left3;
  746. $home->left4 = $left4;
  747. $home->left5 = $left5;
  748. $home->right1 = $right1;
  749. $home->right2 = $right2;
  750. $home->right3 = $right3;
  751. $home->right4 = $right4;
  752. $home->right5 = $right5;
  753. //$home->url = $url;
  754. $home->save();
  755. return Redirect::to('/admin/home');
  756. })->name('home');
  757. Route::get('/home_adv', function () {
  758. $home = Home::first();
  759. if ($home == null)
  760. {
  761. $home = new Home();
  762. $home->save();
  763. }
  764. $home->loadData();
  765. return view('admin.home_adv',compact('home'));
  766. })->name('home_adv');
  767. Route::post('/home_adv', function () {
  768. $home = Home::first();
  769. if ($home == null)
  770. $home = new Home();
  771. if (isset($_POST["delete_image"]))
  772. {
  773. $image = '';
  774. $home->image = $image;
  775. }
  776. else
  777. {
  778. if(request()->image)
  779. {
  780. $file = request()->image;
  781. $filename = time() . '_' . $file->getClientOriginalName();
  782. $path = public_path('files');
  783. request()->image->move($path, $filename);
  784. $image = $filename;
  785. $home->image = $image;
  786. }
  787. }
  788. $url = isset($_POST["url"]) ? $_POST["url"] : '';
  789. $home->url = $url;
  790. if (isset($_POST["delete_image_2"]))
  791. {
  792. $image_2 = '';
  793. $home->image_2 = $image_2;
  794. }
  795. else
  796. {
  797. if(request()->image_2)
  798. {
  799. $file = request()->image_2;
  800. $filename = time() . '_' . $file->getClientOriginalName();
  801. $path = public_path('files');
  802. request()->image_2->move($path, $filename);
  803. $image_2 = $filename;
  804. $home->image_2 = $image_2;
  805. }
  806. }
  807. $url_2 = isset($_POST["url_2"]) ? $_POST["url_2"] : '';
  808. $home->url_2 = $url_2;
  809. if (isset($_POST["delete_image_3"]))
  810. {
  811. $image_3 = '';
  812. $home->image_3 = $image_3;
  813. }
  814. else
  815. {
  816. if(request()->image_3)
  817. {
  818. $file = request()->image_3;
  819. $filename = time() . '_' . $file->getClientOriginalName();
  820. $path = public_path('files');
  821. request()->image_3->move($path, $filename);
  822. $image_3 = $filename;
  823. $home->image_3 = $image_3;
  824. }
  825. }
  826. $url_3 = isset($_POST["url_3"]) ? $_POST["url_3"] : '';
  827. $home->url_3 = $url_3;
  828. if (isset($_POST["delete_image_4"]))
  829. {
  830. $image_4 = '';
  831. $home->image_4 = $image_4;
  832. }
  833. else
  834. {
  835. if(request()->image_4)
  836. {
  837. $file = request()->image_4;
  838. $filename = time() . '_' . $file->getClientOriginalName();
  839. $path = public_path('files');
  840. request()->image_4->move($path, $filename);
  841. $image_4 = $filename;
  842. $home->image_4 = $image_4;
  843. }
  844. }
  845. $url_4 = isset($_POST["url_4"]) ? $_POST["url_4"] : '';
  846. $home->url_4 = $url_4;
  847. if (isset($_POST["delete_image_5"]))
  848. {
  849. $image_5 = '';
  850. $home->image_5 = $image_5;
  851. }
  852. else
  853. {
  854. if(request()->image_5)
  855. {
  856. $file = request()->image_5;
  857. $filename = time() . '_' . $file->getClientOriginalName();
  858. $path = public_path('files');
  859. request()->image_5->move($path, $filename);
  860. $image_5 = $filename;
  861. $home->image_5 = $image_5;
  862. }
  863. }
  864. $url_5 = isset($_POST["url_5"]) ? $_POST["url_5"] : '';
  865. $home->url_5 = $url_5;
  866. if (isset($_POST["delete_banner_top"]))
  867. {
  868. $banner_top = '';
  869. $home->banner_top = $banner_top;
  870. }
  871. else
  872. {
  873. if(request()->banner_top)
  874. {
  875. $file = request()->banner_top;
  876. $filename = time() . '_' . $file->getClientOriginalName();
  877. $path = public_path('files');
  878. request()->banner_top->move($path, $filename);
  879. $banner_top = $filename;
  880. $home->banner_top = $banner_top;
  881. }
  882. }
  883. $banner_top_url = isset($_POST["banner_top_url"]) ? $_POST["banner_top_url"] : '';
  884. $home->banner_top_url = $banner_top_url;
  885. if (isset($_POST["delete_banner_top_2"]))
  886. {
  887. $banner_top_2 = '';
  888. $home->banner_top_2 = $banner_top_2;
  889. }
  890. else
  891. {
  892. if(request()->banner_top_2)
  893. {
  894. $file = request()->banner_top_2;
  895. $filename = time() . '_' . $file->getClientOriginalName();
  896. $path = public_path('files');
  897. request()->banner_top_2->move($path, $filename);
  898. $banner_top_2 = $filename;
  899. $home->banner_top_2 = $banner_top_2;
  900. }
  901. }
  902. $banner_top_2_url = isset($_POST["banner_top_2_url"]) ? $_POST["banner_top_2_url"] : '';
  903. $home->banner_top_2_url = $banner_top_2_url;
  904. if (isset($_POST["delete_banner_top_3"]))
  905. {
  906. $banner_top_3 = '';
  907. $home->banner_top_3 = $banner_top_3;
  908. }
  909. else
  910. {
  911. if(request()->banner_top_3)
  912. {
  913. $file = request()->banner_top_3;
  914. $filename = time() . '_' . $file->getClientOriginalName();
  915. $path = public_path('files');
  916. request()->banner_top_3->move($path, $filename);
  917. $banner_top_3 = $filename;
  918. $home->banner_top_3 = $banner_top_3;
  919. }
  920. }
  921. $banner_top_3_url = isset($_POST["banner_top_3_url"]) ? $_POST["banner_top_3_url"] : '';
  922. $home->banner_top_3_url = $banner_top_3_url;
  923. if (isset($_POST["delete_banner_top_4"]))
  924. {
  925. $banner_top_4 = '';
  926. $home->banner_top_4 = $banner_top_4;
  927. }
  928. else
  929. {
  930. if(request()->banner_top_4)
  931. {
  932. $file = request()->banner_top_4;
  933. $filename = time() . '_' . $file->getClientOriginalName();
  934. $path = public_path('files');
  935. request()->banner_top_4->move($path, $filename);
  936. $banner_top_4 = $filename;
  937. $home->banner_top_4 = $banner_top_4;
  938. }
  939. }
  940. $banner_top_4_url = isset($_POST["banner_top_4_url"]) ? $_POST["banner_top_4_url"] : '';
  941. $home->banner_top_4_url = $banner_top_4_url;
  942. if (isset($_POST["delete_banner_top_5"]))
  943. {
  944. $banner_top_5 = '';
  945. $home->banner_top_5 = $banner_top_5;
  946. }
  947. else
  948. {
  949. if(request()->banner_top_5)
  950. {
  951. $file = request()->banner_top_5;
  952. $filename = time() . '_' . $file->getClientOriginalName();
  953. $path = public_path('files');
  954. request()->banner_top_5->move($path, $filename);
  955. $banner_top_5 = $filename;
  956. $home->banner_top_5 = $banner_top_5;
  957. }
  958. }
  959. $banner_top_5_url = isset($_POST["banner_top_5_url"]) ? $_POST["banner_top_5_url"] : '';
  960. $home->banner_top_5_url = $banner_top_5_url;
  961. $banner_top_google = isset($_POST["banner_top_google"]) ? $_POST["banner_top_google"] : '';
  962. $home->banner_top_google = $banner_top_google;
  963. if (isset($_POST["delete_banner_underb"]))
  964. {
  965. $banner_underb = '';
  966. $home->banner_underb = $banner_underb;
  967. }
  968. else
  969. {
  970. if(request()->banner_underb)
  971. {
  972. $file = request()->banner_underb;
  973. $filename = time() . '_' . $file->getClientOriginalName();
  974. $path = public_path('files');
  975. request()->banner_underb->move($path, $filename);
  976. $banner_underb = $filename;
  977. $home->banner_underb = $banner_underb;
  978. }
  979. }
  980. $banner_underb_url = isset($_POST["banner_underb_url"]) ? $_POST["banner_underb_url"] : '';
  981. $home->banner_underb_url = $banner_underb_url;
  982. if (isset($_POST["delete_banner_underb_2"]))
  983. {
  984. $banner_underb_2 = '';
  985. $home->banner_underb_2 = $banner_underb_2;
  986. }
  987. else
  988. {
  989. if(request()->banner_underb_2)
  990. {
  991. $file = request()->banner_underb_2;
  992. $filename = time() . '_' . $file->getClientOriginalName();
  993. $path = public_path('files');
  994. request()->banner_underb_2->move($path, $filename);
  995. $banner_underb_2 = $filename;
  996. $home->banner_underb_2 = $banner_underb_2;
  997. }
  998. }
  999. $banner_underb_2_url = isset($_POST["banner_underb_2_url"]) ? $_POST["banner_underb_2_url"] : '';
  1000. $home->banner_underb_2_url = $banner_underb_2_url;
  1001. if (isset($_POST["delete_banner_underb_3"]))
  1002. {
  1003. $banner_underb_3 = '';
  1004. $home->banner_underb_3 = $banner_underb_3;
  1005. }
  1006. else
  1007. {
  1008. if(request()->banner_underb_3)
  1009. {
  1010. $file = request()->banner_underb_3;
  1011. $filename = time() . '_' . $file->getClientOriginalName();
  1012. $path = public_path('files');
  1013. request()->banner_underb_3->move($path, $filename);
  1014. $banner_underb_3 = $filename;
  1015. $home->banner_underb_3 = $banner_underb_3;
  1016. }
  1017. }
  1018. $banner_underb_3_url = isset($_POST["banner_underb_3_url"]) ? $_POST["banner_underb_3_url"] : '';
  1019. $home->banner_underb_3_url = $banner_underb_3_url;
  1020. if (isset($_POST["delete_banner_underb_4"]))
  1021. {
  1022. $banner_underb_4 = '';
  1023. $home->banner_underb_4 = $banner_underb_4;
  1024. }
  1025. else
  1026. {
  1027. if(request()->banner_underb_4)
  1028. {
  1029. $file = request()->banner_underb_4;
  1030. $filename = time() . '_' . $file->getClientOriginalName();
  1031. $path = public_path('files');
  1032. request()->banner_underb_4->move($path, $filename);
  1033. $banner_underb_4 = $filename;
  1034. $home->banner_underb_4 = $banner_underb_4;
  1035. }
  1036. }
  1037. $banner_underb_4_url = isset($_POST["banner_underb_4_url"]) ? $_POST["banner_underb_4_url"] : '';
  1038. $home->banner_underb_4_url = $banner_underb_4_url;
  1039. if (isset($_POST["delete_banner_underb_5"]))
  1040. {
  1041. $banner_underb_5 = '';
  1042. $home->banner_underb_5 = $banner_underb_5;
  1043. }
  1044. else
  1045. {
  1046. if(request()->banner_underb_5)
  1047. {
  1048. $file = request()->banner_underb_5;
  1049. $filename = time() . '_' . $file->getClientOriginalName();
  1050. $path = public_path('files');
  1051. request()->banner_underb_5->move($path, $filename);
  1052. $banner_underb_5 = $filename;
  1053. $home->banner_underb_5 = $banner_underb_5;
  1054. }
  1055. }
  1056. $banner_underb_5_url = isset($_POST["banner_underb_5_url"]) ? $_POST["banner_underb_5_url"] : '';
  1057. $home->banner_underb_5_url = $banner_underb_5_url;
  1058. $banner_underb_google = isset($_POST["banner_underb_google"]) ? $_POST["banner_underb_google"] : '';
  1059. $home->banner_underb_google = $banner_underb_google;
  1060. if (isset($_POST["delete_banner_middle"]))
  1061. {
  1062. $banner_middle = '';
  1063. $home->banner_middle = $banner_middle;
  1064. }
  1065. else
  1066. {
  1067. if(request()->banner_middle)
  1068. {
  1069. $file = request()->banner_middle;
  1070. $filename = time() . '_' . $file->getClientOriginalName();
  1071. $path = public_path('files');
  1072. request()->banner_middle->move($path, $filename);
  1073. $banner_middle = $filename;
  1074. $home->banner_middle = $banner_middle;
  1075. }
  1076. }
  1077. $banner_middle_url = isset($_POST["banner_middle_url"]) ? $_POST["banner_middle_url"] : '';
  1078. $home->banner_middle_url = $banner_middle_url;
  1079. if (isset($_POST["delete_banner_middle_2"]))
  1080. {
  1081. $banner_middle_2 = '';
  1082. $home->banner_middle_2 = $banner_middle_2;
  1083. }
  1084. else
  1085. {
  1086. if(request()->banner_middle_2)
  1087. {
  1088. $file = request()->banner_middle_2;
  1089. $filename = time() . '_' . $file->getClientOriginalName();
  1090. $path = public_path('files');
  1091. request()->banner_middle_2->move($path, $filename);
  1092. $banner_middle_2 = $filename;
  1093. $home->banner_middle_2 = $banner_middle_2;
  1094. }
  1095. }
  1096. $banner_middle_2_url = isset($_POST["banner_middle_2_url"]) ? $_POST["banner_middle_2_url"] : '';
  1097. $home->banner_middle_2_url = $banner_middle_2_url;
  1098. if (isset($_POST["delete_banner_middle_3"]))
  1099. {
  1100. $banner_middle_3 = '';
  1101. $home->banner_middle_3 = $banner_middle_3;
  1102. }
  1103. else
  1104. {
  1105. if(request()->banner_middle_3)
  1106. {
  1107. $file = request()->banner_middle_3;
  1108. $filename = time() . '_' . $file->getClientOriginalName();
  1109. $path = public_path('files');
  1110. request()->banner_middle_3->move($path, $filename);
  1111. $banner_middle_3 = $filename;
  1112. $home->banner_middle_3 = $banner_middle_3;
  1113. }
  1114. }
  1115. $banner_middle_3_url = isset($_POST["banner_middle_3_url"]) ? $_POST["banner_middle_3_url"] : '';
  1116. $home->banner_middle_3_url = $banner_middle_3_url;
  1117. if (isset($_POST["delete_banner_middle_4"]))
  1118. {
  1119. $banner_middle_4 = '';
  1120. $home->banner_middle_4 = $banner_middle_4;
  1121. }
  1122. else
  1123. {
  1124. if(request()->banner_middle_4)
  1125. {
  1126. $file = request()->banner_middle_4;
  1127. $filename = time() . '_' . $file->getClientOriginalName();
  1128. $path = public_path('files');
  1129. request()->banner_middle_4->move($path, $filename);
  1130. $banner_middle_4 = $filename;
  1131. $home->banner_middle_4 = $banner_middle_4;
  1132. }
  1133. }
  1134. $banner_middle_4_url = isset($_POST["banner_middle_4_url"]) ? $_POST["banner_middle_4_url"] : '';
  1135. $home->banner_middle_4_url = $banner_middle_4_url;
  1136. if (isset($_POST["delete_banner_middle_5"]))
  1137. {
  1138. $banner_middle_5 = '';
  1139. $home->banner_middle_5 = $banner_middle_5;
  1140. }
  1141. else
  1142. {
  1143. if(request()->banner_middle_5)
  1144. {
  1145. $file = request()->banner_middle_5;
  1146. $filename = time() . '_' . $file->getClientOriginalName();
  1147. $path = public_path('files');
  1148. request()->banner_middle_5->move($path, $filename);
  1149. $banner_middle_5 = $filename;
  1150. $home->banner_middle_5 = $banner_middle_5;
  1151. }
  1152. }
  1153. $banner_middle_5_url = isset($_POST["banner_middle_5_url"]) ? $_POST["banner_middle_5_url"] : '';
  1154. $home->banner_middle_5_url = $banner_middle_5_url;
  1155. $banner_middle_google = isset($_POST["banner_middle_google"]) ? $_POST["banner_middle_google"] : '';
  1156. $home->banner_middle_google = $banner_middle_google;
  1157. if (isset($_POST["delete_banner_first"]))
  1158. {
  1159. $banner_first = '';
  1160. $home->banner_first = $banner_first;
  1161. }
  1162. else
  1163. {
  1164. if(request()->banner_first)
  1165. {
  1166. $file = request()->banner_first;
  1167. $filename = time() . '_' . $file->getClientOriginalName();
  1168. $path = public_path('files');
  1169. request()->banner_first->move($path, $filename);
  1170. $banner_first = $filename;
  1171. $home->banner_first = $banner_first;
  1172. }
  1173. }
  1174. $banner_first_url = isset($_POST["banner_first_url"]) ? $_POST["banner_first_url"] : '';
  1175. $home->banner_first_url = $banner_first_url;
  1176. if (isset($_POST["delete_banner_first_2"]))
  1177. {
  1178. $banner_first_2 = '';
  1179. $home->banner_first_2 = $banner_first_2;
  1180. }
  1181. else
  1182. {
  1183. if(request()->banner_first_2)
  1184. {
  1185. $file = request()->banner_first_2;
  1186. $filename = time() . '_' . $file->getClientOriginalName();
  1187. $path = public_path('files');
  1188. request()->banner_first_2->move($path, $filename);
  1189. $banner_first_2 = $filename;
  1190. $home->banner_first_2 = $banner_first_2;
  1191. }
  1192. }
  1193. $banner_first_2_url = isset($_POST["banner_first_2_url"]) ? $_POST["banner_first_2_url"] : '';
  1194. $home->banner_first_2_url = $banner_first_2_url;
  1195. if (isset($_POST["delete_banner_first_3"]))
  1196. {
  1197. $banner_first_3 = '';
  1198. $home->banner_first_3 = $banner_first_3;
  1199. }
  1200. else
  1201. {
  1202. if(request()->banner_first_3)
  1203. {
  1204. $file = request()->banner_first_3;
  1205. $filename = time() . '_' . $file->getClientOriginalName();
  1206. $path = public_path('files');
  1207. request()->banner_first_3->move($path, $filename);
  1208. $banner_first_3 = $filename;
  1209. $home->banner_first_3 = $banner_first_3;
  1210. }
  1211. }
  1212. $banner_first_3_url = isset($_POST["banner_first_3_url"]) ? $_POST["banner_first_3_url"] : '';
  1213. $home->banner_first_3_url = $banner_first_3_url;
  1214. if (isset($_POST["delete_banner_first_4"]))
  1215. {
  1216. $banner_first_4 = '';
  1217. $home->banner_first_4 = $banner_first_4;
  1218. }
  1219. else
  1220. {
  1221. if(request()->banner_first_4)
  1222. {
  1223. $file = request()->banner_first_4;
  1224. $filename = time() . '_' . $file->getClientOriginalName();
  1225. $path = public_path('files');
  1226. request()->banner_first_4->move($path, $filename);
  1227. $banner_first_4 = $filename;
  1228. $home->banner_first_4 = $banner_first_4;
  1229. }
  1230. }
  1231. $banner_first_4_url = isset($_POST["banner_first_4_url"]) ? $_POST["banner_first_4_url"] : '';
  1232. $home->banner_first_4_url = $banner_first_4_url;
  1233. if (isset($_POST["delete_banner_first_5"]))
  1234. {
  1235. $banner_first_5 = '';
  1236. $home->banner_first_5 = $banner_first_5;
  1237. }
  1238. else
  1239. {
  1240. if(request()->banner_first_5)
  1241. {
  1242. $file = request()->banner_first_5;
  1243. $filename = time() . '_' . $file->getClientOriginalName();
  1244. $path = public_path('files');
  1245. request()->banner_first_5->move($path, $filename);
  1246. $banner_first_5 = $filename;
  1247. $home->banner_first_5 = $banner_first_5;
  1248. }
  1249. }
  1250. $banner_first_5_url = isset($_POST["banner_first_5_url"]) ? $_POST["banner_first_5_url"] : '';
  1251. $home->banner_first_5_url = $banner_first_5_url;
  1252. $banner_first_google = isset($_POST["banner_first_google"]) ? $_POST["banner_first_google"] : '';
  1253. $home->banner_first_google = $banner_first_google;
  1254. if (isset($_POST["delete_banner_right_top"]))
  1255. {
  1256. $banner_right_top = '';
  1257. $home->banner_right_top = $banner_right_top;
  1258. }
  1259. else
  1260. {
  1261. if(request()->banner_right_top)
  1262. {
  1263. $file = request()->banner_right_top;
  1264. $filename = time() . '_' . $file->getClientOriginalName();
  1265. $path = public_path('files');
  1266. request()->banner_right_top->move($path, $filename);
  1267. $banner_right_top = $filename;
  1268. $home->banner_right_top = $banner_right_top;
  1269. }
  1270. }
  1271. $banner_right_top_url = isset($_POST["banner_right_top_url"]) ? $_POST["banner_right_top_url"] : '';
  1272. $home->banner_right_top_url = $banner_right_top_url;
  1273. if (isset($_POST["delete_banner_right_top_2"]))
  1274. {
  1275. $banner_right_top_2 = '';
  1276. $home->banner_right_top_2 = $banner_right_top_2;
  1277. }
  1278. else
  1279. {
  1280. if(request()->banner_right_top_2)
  1281. {
  1282. $file = request()->banner_right_top_2;
  1283. $filename = time() . '_' . $file->getClientOriginalName();
  1284. $path = public_path('files');
  1285. request()->banner_right_top_2->move($path, $filename);
  1286. $banner_right_top_2 = $filename;
  1287. $home->banner_right_top_2 = $banner_right_top_2;
  1288. }
  1289. }
  1290. $banner_right_top_2_url = isset($_POST["banner_right_top_2_url"]) ? $_POST["banner_right_top_2_url"] : '';
  1291. $home->banner_right_top_2_url = $banner_right_top_2_url;
  1292. if (isset($_POST["delete_banner_right_top_3"]))
  1293. {
  1294. $banner_right_top_3 = '';
  1295. $home->banner_right_top_3 = $banner_right_top_3;
  1296. }
  1297. else
  1298. {
  1299. if(request()->banner_right_top_3)
  1300. {
  1301. $file = request()->banner_right_top_3;
  1302. $filename = time() . '_' . $file->getClientOriginalName();
  1303. $path = public_path('files');
  1304. request()->banner_right_top_3->move($path, $filename);
  1305. $banner_right_top_3 = $filename;
  1306. $home->banner_right_top_3 = $banner_right_top_3;
  1307. }
  1308. }
  1309. $banner_right_top_3_url = isset($_POST["banner_right_top_3_url"]) ? $_POST["banner_right_top_3_url"] : '';
  1310. $home->banner_right_top_3_url = $banner_right_top_3_url;
  1311. if (isset($_POST["delete_banner_right_top_4"]))
  1312. {
  1313. $banner_right_top_4 = '';
  1314. $home->banner_right_top_4 = $banner_right_top_4;
  1315. }
  1316. else
  1317. {
  1318. if(request()->banner_right_top_4)
  1319. {
  1320. $file = request()->banner_right_top_4;
  1321. $filename = time() . '_' . $file->getClientOriginalName();
  1322. $path = public_path('files');
  1323. request()->banner_right_top_4->move($path, $filename);
  1324. $banner_right_top_4 = $filename;
  1325. $home->banner_right_top_4 = $banner_right_top_4;
  1326. }
  1327. }
  1328. $banner_right_top_4_url = isset($_POST["banner_right_top_4_url"]) ? $_POST["banner_right_top_4_url"] : '';
  1329. $home->banner_right_top_4_url = $banner_right_top_4_url;
  1330. if (isset($_POST["delete_banner_right_top_5"]))
  1331. {
  1332. $banner_right_top_5 = '';
  1333. $home->banner_right_top_5 = $banner_right_top_5;
  1334. }
  1335. else
  1336. {
  1337. if(request()->banner_right_top_5)
  1338. {
  1339. $file = request()->banner_right_top_5;
  1340. $filename = time() . '_' . $file->getClientOriginalName();
  1341. $path = public_path('files');
  1342. request()->banner_right_top_5->move($path, $filename);
  1343. $banner_right_top_5 = $filename;
  1344. $home->banner_right_top_5 = $banner_right_top_5;
  1345. }
  1346. }
  1347. $banner_right_top_5_url = isset($_POST["banner_right_top_5_url"]) ? $_POST["banner_right_top_5_url"] : '';
  1348. $home->banner_right_top_5_url = $banner_right_top_5_url;
  1349. $banner_right_top_google = isset($_POST["banner_right_top_google"]) ? $_POST["banner_right_top_google"] : '';
  1350. $home->banner_right_top_google = $banner_right_top_google;
  1351. if (isset($_POST["delete_banner_right_bottom"]))
  1352. {
  1353. $banner_right_bottom = '';
  1354. $home->banner_right_bottom = $banner_right_bottom;
  1355. }
  1356. else
  1357. {
  1358. if(request()->banner_right_bottom)
  1359. {
  1360. $file = request()->banner_right_bottom;
  1361. $filename = time() . '_' . $file->getClientOriginalName();
  1362. $path = public_path('files');
  1363. request()->banner_right_bottom->move($path, $filename);
  1364. $banner_right_bottom = $filename;
  1365. $home->banner_right_bottom = $banner_right_bottom;
  1366. }
  1367. }
  1368. $banner_right_bottom_url = isset($_POST["banner_right_bottom_url"]) ? $_POST["banner_right_bottom_url"] : '';
  1369. $home->banner_right_bottom_url = $banner_right_bottom_url;
  1370. if (isset($_POST["delete_banner_right_bottom_2"]))
  1371. {
  1372. $banner_right_bottom_2 = '';
  1373. $home->banner_right_bottom_2 = $banner_right_bottom_2;
  1374. }
  1375. else
  1376. {
  1377. if(request()->banner_right_bottom_2)
  1378. {
  1379. $file = request()->banner_right_bottom_2;
  1380. $filename = time() . '_' . $file->getClientOriginalName();
  1381. $path = public_path('files');
  1382. request()->banner_right_bottom_2->move($path, $filename);
  1383. $banner_right_bottom_2 = $filename;
  1384. $home->banner_right_bottom_2 = $banner_right_bottom_2;
  1385. }
  1386. }
  1387. $banner_right_bottom_2_url = isset($_POST["banner_right_bottom_2_url"]) ? $_POST["banner_right_bottom_2_url"] : '';
  1388. $home->banner_right_bottom_2_url = $banner_right_bottom_2_url;
  1389. if (isset($_POST["delete_banner_right_bottom_3"]))
  1390. {
  1391. $banner_right_bottom_3 = '';
  1392. $home->banner_right_bottom_3 = $banner_right_bottom_3;
  1393. }
  1394. else
  1395. {
  1396. if(request()->banner_right_bottom_3)
  1397. {
  1398. $file = request()->banner_right_bottom_3;
  1399. $filename = time() . '_' . $file->getClientOriginalName();
  1400. $path = public_path('files');
  1401. request()->banner_right_bottom_3->move($path, $filename);
  1402. $banner_right_bottom_3 = $filename;
  1403. $home->banner_right_bottom_3 = $banner_right_bottom_3;
  1404. }
  1405. }
  1406. $banner_right_bottom_3_url = isset($_POST["banner_right_bottom_3_url"]) ? $_POST["banner_right_bottom_3_url"] : '';
  1407. $home->banner_right_bottom_3_url = $banner_right_bottom_3_url;
  1408. if (isset($_POST["delete_banner_right_bottom_4"]))
  1409. {
  1410. $banner_right_bottom_4 = '';
  1411. $home->banner_right_bottom_4 = $banner_right_bottom_4;
  1412. }
  1413. else
  1414. {
  1415. if(request()->banner_right_bottom_4)
  1416. {
  1417. $file = request()->banner_right_bottom_4;
  1418. $filename = time() . '_' . $file->getClientOriginalName();
  1419. $path = public_path('files');
  1420. request()->banner_right_bottom_4->move($path, $filename);
  1421. $banner_right_bottom_4 = $filename;
  1422. $home->banner_right_bottom_4 = $banner_right_bottom_4;
  1423. }
  1424. }
  1425. $banner_right_bottom_4_url = isset($_POST["banner_right_bottom_4_url"]) ? $_POST["banner_right_bottom_4_url"] : '';
  1426. $home->banner_right_bottom_4_url = $banner_right_bottom_4_url;
  1427. if (isset($_POST["delete_banner_right_bottom_5"]))
  1428. {
  1429. $banner_right_bottom_5 = '';
  1430. $home->banner_right_bottom_5 = $banner_right_bottom_5;
  1431. }
  1432. else
  1433. {
  1434. if(request()->banner_right_bottom_5)
  1435. {
  1436. $file = request()->banner_right_bottom_5;
  1437. $filename = time() . '_' . $file->getClientOriginalName();
  1438. $path = public_path('files');
  1439. request()->banner_right_bottom_5->move($path, $filename);
  1440. $banner_right_bottom_5 = $filename;
  1441. $home->banner_right_bottom_5 = $banner_right_bottom_5;
  1442. }
  1443. }
  1444. $banner_right_bottom_5_url = isset($_POST["banner_right_bottom_5_url"]) ? $_POST["banner_right_bottom_5_url"] : '';
  1445. $home->banner_right_bottom_5_url = $banner_right_bottom_5_url;
  1446. $banner_right_bottom_google = isset($_POST["banner_right_bottom_google"]) ? $_POST["banner_right_bottom_google"] : '';
  1447. $home->banner_right_bottom_google = $banner_right_bottom_google;
  1448. if (isset($_POST["delete_banner_right_big"]))
  1449. {
  1450. $banner_right_big = '';
  1451. $home->banner_right_big = $banner_right_big;
  1452. }
  1453. else
  1454. {
  1455. if(request()->banner_right_big)
  1456. {
  1457. $file = request()->banner_right_big;
  1458. $filename = time() . '_' . $file->getClientOriginalName();
  1459. $path = public_path('files');
  1460. request()->banner_right_big->move($path, $filename);
  1461. $banner_right_big = $filename;
  1462. $home->banner_right_big = $banner_right_big;
  1463. }
  1464. }
  1465. $banner_right_big_url = isset($_POST["banner_right_big_url"]) ? $_POST["banner_right_big_url"] : '';
  1466. $home->banner_right_big_url = $banner_right_big_url;
  1467. if (isset($_POST["delete_banner_right_big_2"]))
  1468. {
  1469. $banner_right_big_2 = '';
  1470. $home->banner_right_big_2 = $banner_right_big_2;
  1471. }
  1472. else
  1473. {
  1474. if(request()->banner_right_big_2)
  1475. {
  1476. $file = request()->banner_right_big_2;
  1477. $filename = time() . '_' . $file->getClientOriginalName();
  1478. $path = public_path('files');
  1479. request()->banner_right_big_2->move($path, $filename);
  1480. $banner_right_big_2 = $filename;
  1481. $home->banner_right_big_2 = $banner_right_big_2;
  1482. }
  1483. }
  1484. $banner_right_big_2_url = isset($_POST["banner_right_big_2_url"]) ? $_POST["banner_right_big_2_url"] : '';
  1485. $home->banner_right_big_2_url = $banner_right_big_2_url;
  1486. if (isset($_POST["delete_banner_right_big_3"]))
  1487. {
  1488. $banner_right_big_3 = '';
  1489. $home->banner_right_big_3 = $banner_right_big_3;
  1490. }
  1491. else
  1492. {
  1493. if(request()->banner_right_big_3)
  1494. {
  1495. $file = request()->banner_right_big_3;
  1496. $filename = time() . '_' . $file->getClientOriginalName();
  1497. $path = public_path('files');
  1498. request()->banner_right_big_3->move($path, $filename);
  1499. $banner_right_big_3 = $filename;
  1500. $home->banner_right_big_3 = $banner_right_big_3;
  1501. }
  1502. }
  1503. $banner_right_big_3_url = isset($_POST["banner_right_big_3_url"]) ? $_POST["banner_right_big_3_url"] : '';
  1504. $home->banner_right_big_3_url = $banner_right_big_3_url;
  1505. if (isset($_POST["delete_banner_right_big_4"]))
  1506. {
  1507. $banner_right_big_4 = '';
  1508. $home->banner_right_big_4 = $banner_right_big_4;
  1509. }
  1510. else
  1511. {
  1512. if(request()->banner_right_big_4)
  1513. {
  1514. $file = request()->banner_right_big_4;
  1515. $filename = time() . '_' . $file->getClientOriginalName();
  1516. $path = public_path('files');
  1517. request()->banner_right_big_4->move($path, $filename);
  1518. $banner_right_big_4 = $filename;
  1519. $home->banner_right_big_4 = $banner_right_big_4;
  1520. }
  1521. }
  1522. $banner_right_big_4_url = isset($_POST["banner_right_big_4_url"]) ? $_POST["banner_right_big_4_url"] : '';
  1523. $home->banner_right_big_4_url = $banner_right_big_4_url;
  1524. if (isset($_POST["delete_banner_right_big_5"]))
  1525. {
  1526. $banner_right_big_5 = '';
  1527. $home->banner_right_big_5 = $banner_right_big_5;
  1528. }
  1529. else
  1530. {
  1531. if(request()->banner_right_big_5)
  1532. {
  1533. $file = request()->banner_right_big_5;
  1534. $filename = time() . '_' . $file->getClientOriginalName();
  1535. $path = public_path('files');
  1536. request()->banner_right_big_5->move($path, $filename);
  1537. $banner_right_big_5 = $filename;
  1538. $home->banner_right_big_5 = $banner_right_big_5;
  1539. }
  1540. }
  1541. $banner_right_big_5_url = isset($_POST["banner_right_big_5_url"]) ? $_POST["banner_right_big_5_url"] : '';
  1542. $home->banner_right_big_5_url = $banner_right_big_5_url;
  1543. $banner_right_big_google = isset($_POST["banner_right_big_google"]) ? $_POST["banner_right_big_google"] : '';
  1544. $home->banner_right_big_google = $banner_right_big_google;
  1545. $home->save();
  1546. return Redirect::to('/admin/home_adv');
  1547. })->name('home_adv');
  1548. Route::get('/home_radio', function () {
  1549. $home = Home::first();
  1550. if ($home == null)
  1551. {
  1552. $home = new Home();
  1553. $home->save();
  1554. }
  1555. $home->loadData();
  1556. return view('admin.home_radio',compact('home'));
  1557. })->name('home_radio');
  1558. Route::post('/home_radio', function () {
  1559. $home = Home::first();
  1560. if ($home == null)
  1561. $home = new Home();
  1562. if (isset($_POST["delete_radio1"]))
  1563. {
  1564. $radio1_file = '';
  1565. $home->radio1_file = $radio1_file;
  1566. }
  1567. else
  1568. {
  1569. if(request()->radio1_file)
  1570. {
  1571. $file = request()->radio1_file;
  1572. $filename = time() . '_' . $file->getClientOriginalName();
  1573. $path = public_path('files');
  1574. request()->radio1_file->move($path, $filename);
  1575. $radio1_file = $filename;
  1576. $home->radio1_file = $radio1_file;
  1577. }
  1578. }
  1579. $radio1_url = isset($_POST["radio1_url"]) ? $_POST["radio1_url"] : '';
  1580. $home->radio1_url = $radio1_url;
  1581. $home->radio1_title = isset($_POST["radio1_title"]) ? $_POST["radio1_title"] : '';
  1582. if (isset($_POST["delete_radio2"]))
  1583. {
  1584. $radio2_file = '';
  1585. $home->radio2_file = $radio2_file;
  1586. }
  1587. else
  1588. {
  1589. if(request()->radio2_file)
  1590. {
  1591. $file = request()->radio2_file;
  1592. $filename = time() . '_' . $file->getClientOriginalName();
  1593. $path = public_path('files');
  1594. request()->radio2_file->move($path, $filename);
  1595. $radio2_file = $filename;
  1596. $home->radio2_file = $radio2_file;
  1597. }
  1598. }
  1599. $radio2_url = isset($_POST["radio2_url"]) ? $_POST["radio2_url"] : '';
  1600. $home->radio2_url = $radio2_url;
  1601. $home->radio2_title = isset($_POST["radio2_title"]) ? $_POST["radio2_title"] : '';
  1602. if (isset($_POST["delete_radio3"]))
  1603. {
  1604. $radio3_file = '';
  1605. $home->radio3_file = $radio3_file;
  1606. }
  1607. else
  1608. {
  1609. if(request()->radio3_file)
  1610. {
  1611. $file = request()->radio3_file;
  1612. $filename = time() . '_' . $file->getClientOriginalName();
  1613. $path = public_path('files');
  1614. request()->radio3_file->move($path, $filename);
  1615. $radio3_file = $filename;
  1616. $home->radio3_file = $radio3_file;
  1617. }
  1618. }
  1619. $radio3_url = isset($_POST["radio3_url"]) ? $_POST["radio3_url"] : '';
  1620. $home->radio3_url = $radio3_url;
  1621. $home->radio3_title = isset($_POST["radio3_title"]) ? $_POST["radio3_title"] : '';
  1622. $home->save();
  1623. return Redirect::to('/admin/home_radio');
  1624. })->name('home_radio');
  1625. Route::get('/news/duplicate/{id}', function ($id) {
  1626. $news = News::findOrFail($id);
  1627. $new_news = $news->replicate();
  1628. $new_news->title .= ' - COPY';
  1629. $new_news->online = false;
  1630. $new_news->save();
  1631. return Redirect::to('/admin/news/' . $new_news->id . "/edit");
  1632. })->name('news.duplicate');
  1633. Route::get('/news/crop', function () {
  1634. return view('news.crop');
  1635. })->name('news.crop');
  1636. Route::post('/news/crop', function () {
  1637. $image = $_POST["imagebase64H"];
  1638. $imageInfo = explode(";base64,", $image);
  1639. $imgExt = str_replace('data:image/', '', $imageInfo[0]);
  1640. $image = str_replace(' ', '+', $imageInfo[1]);
  1641. $imageName = time().".".$imgExt;
  1642. $path = public_path()."/files/news/".$imageName;
  1643. file_put_contents($path, base64_decode($image));
  1644. $imageV = $_POST["imagebase64V"];
  1645. $imageInfoV = explode(";base64,", $imageV);
  1646. $imgExtV = str_replace('data:image/', '', $imageInfoV[0]);
  1647. $imageV = str_replace(' ', '+', $imageInfoV[1]);
  1648. $imageNameV = "V_".time().".".$imgExt;
  1649. $pathV = public_path()."/files/news/".$imageNameV;
  1650. file_put_contents($pathV, base64_decode($imageV));
  1651. if ($_POST["news_id"] > 0)
  1652. {
  1653. $news = News::findOrFail($_POST["news_id"]);
  1654. $news->image = $imageName;
  1655. $news->save();
  1656. return Redirect::to('/admin/news/' . $_POST["news_id"] . "/edit");
  1657. }
  1658. else
  1659. return Redirect::to('/admin/news/create?filename=' . $imageName);
  1660. })->name('news.crop_save');
  1661. Route::get('news/load_json', 'NewsController@load_json')->name('load_json');
  1662. Route::get('news/status/{id}/{status}', function ($id, $status) {
  1663. $n = News::findOrFail($id);
  1664. $n->online = $status == 'online';
  1665. if ($status == 'online')
  1666. {
  1667. if ($n->date <= date("Y-m-d H:i:s"))
  1668. {
  1669. if ($n->section_position != '')
  1670. {
  1671. $s = Section::findOrFail($n->section_id);
  1672. $s[$n->section_position] = $n->id;
  1673. $s->save();
  1674. $n->section_position = '';
  1675. }
  1676. if ($n->region_1_position != '')
  1677. {
  1678. $s = Section::findOrFail($n->region_1_id);
  1679. $s[$n->region_1_position] = $n->id;
  1680. $s->save();
  1681. $n->region_1_position = '';
  1682. }
  1683. if ($n->region_2_position != '')
  1684. {
  1685. $s = Section::findOrFail($n->region_2_id);
  1686. $s[$n->region_2_position] = $n->id;
  1687. $s->save();
  1688. $n->region_2_position = '';
  1689. }
  1690. $n->save();
  1691. if (!$n->published)
  1692. {
  1693. // $n->notify(new FacebookPost());
  1694. $n->notify(new TwitterPost());
  1695. $n->published = true;
  1696. }
  1697. }
  1698. }
  1699. else
  1700. {
  1701. }
  1702. $n->save();
  1703. return Redirect::to('/admin/news');
  1704. });
  1705. Route::resource('news','NewsController');
  1706. Route::resource('breaking_news','BreakingNewsController');
  1707. Route::get('/sections/sort/{ids}', function ($ids) {
  1708. $idx = explode(",", $ids);
  1709. foreach($idx as $x => $id)
  1710. {
  1711. $s = Section::findOrFail($id);
  1712. $s->position = $x;
  1713. $s->save();
  1714. }
  1715. });
  1716. Route::get('/sections/layout/{id}', function ($id) {
  1717. $section = Section::findOrFail($id);
  1718. if (isset($_GET["layout"]))
  1719. {
  1720. $section->big = '';
  1721. $section->small1 = '';
  1722. $section->small2 = '';
  1723. $section->small3 = '';
  1724. $section->small4 = '';
  1725. $section->small5 = '';
  1726. $section->small6 = '';
  1727. $section->save();
  1728. }
  1729. $section->loadLayout();
  1730. $aAssigned = array();
  1731. if ($section->big != '')
  1732. $aAssigned[] = @$section->big->id;
  1733. if ($section->small1 != '')
  1734. $aAssigned[] = @$section->small1->id;
  1735. if ($section->small2 != '')
  1736. $aAssigned[] = @$section->small2->id;
  1737. if ($section->small3 != '')
  1738. $aAssigned[] = @$section->small3->id;
  1739. if ($section->small4 != '')
  1740. $aAssigned[] = @$section->small4->id;
  1741. if ($section->small5 != '')
  1742. $aAssigned[] = @$section->small5->id;
  1743. if ($section->small6 != '')
  1744. $aAssigned[] = @$section->small6->id;
  1745. $news = News::whereNotIn('id', $aAssigned)->where(function ($q) use ($id) {
  1746. $q->where('section_id', '=', $id)->orWhere('region_1_id', '=', $id)->orWhere('region_2_id', '=', $id);
  1747. })->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
  1748. return view('sections.layout',compact('section', 'news'));
  1749. })->name('sections.layout');
  1750. Route::post('/sections/layout/{id}', function ($id) {
  1751. $section = Section::findOrFail($id);
  1752. $layout = isset($_POST["layout"]) ? $_POST["layout"] : '';
  1753. $big = isset($_POST["big"]) ? $_POST["big"] : '';
  1754. $small1 = isset($_POST["small1"]) ? $_POST["small1"] : '';
  1755. $small2 = isset($_POST["small2"]) ? $_POST["small2"] : '';
  1756. $small3 = isset($_POST["small3"]) ? $_POST["small3"] : '';
  1757. $small4 = isset($_POST["small4"]) ? $_POST["small4"] : '';
  1758. $small5 = isset($_POST["small5"]) ? $_POST["small5"] : '';
  1759. $small6 = isset($_POST["small6"]) ? $_POST["small6"] : '';
  1760. $aSel = array();
  1761. if (isset($_POST["big"]))
  1762. $aSel[] = $_POST["big"];
  1763. if (isset($_POST["small1"]))
  1764. $aSel[] = $_POST["small1"];
  1765. if (isset($_POST["small2"]))
  1766. $aSel[] = $_POST["small2"];
  1767. if (isset($_POST["small3"]))
  1768. $aSel[] = $_POST["small3"];
  1769. if (isset($_POST["small4"]))
  1770. $aSel[] = $_POST["small4"];
  1771. if (isset($_POST["small5"]))
  1772. $aSel[] = $_POST["small5"];
  1773. if (isset($_POST["small6"]))
  1774. $aSel[] = $_POST["small6"];
  1775. // Riempio i vuoti
  1776. $news = News::whereNotIn('id', $aSel)->where(function ($q) use ($id) {
  1777. $q->where('section_id', '=', $id)->orWhere('region_1_id', '=', $id)->orWhere('region_2_id', '=', $id);
  1778. })->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
  1779. $idx = 0;
  1780. $section->layout = $layout;
  1781. if ($big == '')
  1782. {
  1783. $section->big = @$news[$idx]->id;
  1784. $idx++;
  1785. }
  1786. else
  1787. $section->big = $big;
  1788. if ($small1 == '')
  1789. {
  1790. $section->small1 = @$news[$idx]->id;
  1791. $idx++;
  1792. }
  1793. else
  1794. $section->small1 = $small1;
  1795. if ($small2 == '')
  1796. {
  1797. $section->small2 = @$news[$idx]->id;
  1798. $idx++;
  1799. }
  1800. else
  1801. $section->small2 = $small2;
  1802. if ($small3 == '')
  1803. {
  1804. $section->small3 = @$news[$idx]->id;
  1805. $idx++;
  1806. }
  1807. else
  1808. $section->small3 = $small3;
  1809. if ($layout == 'layout_3' || $layout == 'layout_4' || $layout == 'layout_5' || $layout == 'layout_7')
  1810. {
  1811. if ($small4 == '')
  1812. {
  1813. $section->small4 = @$news[$idx]->id;
  1814. $idx++;
  1815. }
  1816. else
  1817. $section->small4 = $small4;
  1818. if ($layout == 'layout_4')
  1819. {
  1820. if ($small5 == '')
  1821. {
  1822. $section->small5 = @$news[$idx]->id;
  1823. $idx++;
  1824. }
  1825. else
  1826. $section->small5 = $small5;
  1827. if ($small6 == '')
  1828. {
  1829. $section->small6 = @$news[$idx]->id;
  1830. $idx++;
  1831. }
  1832. else
  1833. $section->small6 = $small6;
  1834. }
  1835. else
  1836. {
  1837. $section->small5 = '';
  1838. $section->small6 = '';
  1839. }
  1840. }
  1841. else
  1842. {
  1843. $section->small4 = '';
  1844. $section->small5 = '';
  1845. $section->small6 = '';
  1846. }
  1847. $section->save();
  1848. // CLEARLAYOUT
  1849. // $section->clearLayout();
  1850. return Redirect::to('/admin/sections');
  1851. });
  1852. Route::get('/events/layout/{id}', function ($id) {
  1853. $event = Event::findOrFail($id);
  1854. $event->loadLayout();
  1855. $aAssigned = array();
  1856. if ($event->big != '')
  1857. $aAssigned[] = @$event->big->id;
  1858. if ($event->small1 != '')
  1859. $aAssigned[] = @$event->small1->id;
  1860. if ($event->small2 != '')
  1861. $aAssigned[] = @$event->small2->id;
  1862. if ($event->small3 != '')
  1863. $aAssigned[] = @$event->small3->id;
  1864. if ($event->small4 != '')
  1865. $aAssigned[] = @$event->small4->id;
  1866. $news = News::whereNotIn('id', $aAssigned)->where('event_id', '=', $id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
  1867. return view('events.layout',compact('event', 'news'));
  1868. })->name('events.layout');
  1869. Route::post('/events/layout/{id}', function ($id) {
  1870. $event = Event::findOrFail($id);
  1871. $big = isset($_POST["big"]) ? $_POST["big"] : '';
  1872. $small1 = isset($_POST["small1"]) ? $_POST["small1"] : '';
  1873. $small2 = isset($_POST["small2"]) ? $_POST["small2"] : '';
  1874. $small3 = isset($_POST["small3"]) ? $_POST["small3"] : '';
  1875. $small4 = isset($_POST["small4"]) ? $_POST["small4"] : '';
  1876. $aSel = array();
  1877. if (isset($_POST["big"]))
  1878. $aSel[] = $_POST["big"];
  1879. if (isset($_POST["small1"]))
  1880. $aSel[] = $_POST["small1"];
  1881. if (isset($_POST["small2"]))
  1882. $aSel[] = $_POST["small2"];
  1883. if (isset($_POST["small3"]))
  1884. $aSel[] = $_POST["small3"];
  1885. if (isset($_POST["small4"]))
  1886. $aSel[] = $_POST["small4"];
  1887. $news = News::whereNotIn('id', $aSel)->where('event_id', '=', $id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
  1888. $idx = 0;
  1889. if ($big == '')
  1890. {
  1891. $event->big = @$news[$idx]->id;
  1892. $idx++;
  1893. }
  1894. else
  1895. $event->big = $big;
  1896. if ($small1 == '')
  1897. {
  1898. $event->small1 = @$news[$idx]->id;
  1899. $idx++;
  1900. }
  1901. else
  1902. $event->small1 = $small1;
  1903. if ($small2 == '')
  1904. {
  1905. $event->small2 = @$news[$idx]->id;
  1906. $idx++;
  1907. }
  1908. else
  1909. $event->small2 = $small2;
  1910. if ($small3 == '')
  1911. {
  1912. $event->small3 = @$news[$idx]->id;
  1913. $idx++;
  1914. }
  1915. else
  1916. $event->small3 = $small3;
  1917. if ($small4 == '')
  1918. {
  1919. $event->small4 = @$news[$idx]->id;
  1920. $idx++;
  1921. }
  1922. else
  1923. $event->small4 = $small4;
  1924. $event->save();
  1925. return Redirect::to('/admin/events');
  1926. });
  1927. Route::get('/sections/to_event/{id}', function ($id) {
  1928. $section = Section::findOrFail($id);
  1929. $event = new Event();
  1930. $event->title = $section->name;
  1931. $event->text_short = '';
  1932. $event->text = '';
  1933. $event->image = '';
  1934. $event->slug = $section->slug;
  1935. $event->online = true;
  1936. $event->save();
  1937. $news = News::where('section_id', '=', $id)->get();
  1938. foreach($news as $n)
  1939. {
  1940. $n->event_id = $event->id;
  1941. $n->section_id = null;
  1942. $n->save();
  1943. }
  1944. $news = News::where('region_1_id', '=', $id)->get();
  1945. foreach($news as $n)
  1946. {
  1947. $n->event_id = $event->id;
  1948. $n->region_1_id = null;
  1949. $n->save();
  1950. }
  1951. $news = News::where('region_2_id', '=', $id)->get();
  1952. foreach($news as $n)
  1953. {
  1954. $n->event_id = $event->id;
  1955. $n->region_2_id = null;
  1956. $n->save();
  1957. }
  1958. $advs = SectionAdv::where('section_id', '=', $id)->get();
  1959. foreach($advs as $adv)
  1960. {
  1961. $adv->section_id = null;
  1962. $adv->save();
  1963. }
  1964. // $section->slug = $section->slug . "_old";
  1965. $section->delete();
  1966. return Redirect::to('/admin/events/' . $event->id . '/edit');
  1967. })->name('sections.to_event');
  1968. Route::resource('sections.advs','SectionAdvController');
  1969. Route::resource('sections','SectionController');
  1970. Route::resource('categories.groups','GroupController');
  1971. Route::resource('categories','CategoryController');
  1972. Route::get('/adv/sort/{ids}', function ($ids) {
  1973. $idx = explode(",", $ids);
  1974. foreach($idx as $x => $id)
  1975. {
  1976. $s = PageAdv::findOrFail($id);
  1977. $s->sort = $x;
  1978. $s->save();
  1979. }
  1980. });
  1981. Route::resource('pages.advs','PageAdvController');
  1982. Route::resource('pages','PageController');
  1983. Route::resource('events.advs','EventAdvController');
  1984. Route::resource('events','EventController');
  1985. Route::get('/calendars/sort/{ids}', function ($ids) {
  1986. $idx = explode(",", $ids);
  1987. foreach($idx as $x => $id)
  1988. {
  1989. $c = Calendar::findOrFail($id);
  1990. $c->position = $x;
  1991. $c->save();
  1992. }
  1993. });
  1994. Route::resource('calendars','CalendarController');
  1995. Route::get('/calendars/archive/{id}', function ($id) {
  1996. $c = Calendar::findOrFail($id);
  1997. $c->archived = true;
  1998. $c->save();
  1999. return Redirect::to('/admin/calendars');
  2000. })->name('calendars.archive');
  2001. Route::get('/calendars/games/{id}', function ($id) {
  2002. $calendar = CalendarGame::where('calendar_id', '=', $id)->get();;
  2003. $games = array();
  2004. foreach($calendar as $c)
  2005. {
  2006. $games[$c->day . " " . $c->type][] = $c;
  2007. }
  2008. $c = Calendar::findOrFail($id);
  2009. $aRates = $c->getRates();
  2010. $count = 1;
  2011. foreach($aRates as $idx => $r)
  2012. {
  2013. if ($r["penality"] != '')
  2014. {
  2015. $aRates[$idx]["team"] = $r["team"] . ' ' . str_repeat('*', $count);
  2016. $aRates[$idx]["penality"] = str_repeat('*', $count) . $r["penality"];
  2017. $count += 1;
  2018. }
  2019. }
  2020. return view('calendars.games',compact('games', 'aRates'));
  2021. })->name('calendars.games');
  2022. Route::get('/calendars/games/{id}/{day}/{type}', function ($id, $day, $type) {
  2023. $games = CalendarGame::where('calendar_id', '=', $id)->where('day', '=', $day)->where('type', '=', $type)->get();;
  2024. return view('calendars.games_edit',compact('games', 'id', 'day', 'type'));
  2025. })->name('calendars.games_edit');
  2026. Route::post('/calendars/games/{id}/{day}/{type}', function ($id, $day, $type) {
  2027. $games = CalendarGame::where('calendar_id', '=', $id)->where('day', '=', $day)->where('type', '=', $type)->get();;
  2028. foreach($games as $g)
  2029. {
  2030. $date = isset($_POST["date_" . $g->id]) ? $_POST["date_" . $g->id] : '';
  2031. list($day, $month, $year) = explode("/", $date);
  2032. $g->date = $year . "-" . $month . "-" . $day;
  2033. $g->save();
  2034. $home_goals = isset($_POST["home_goals_" . $g->id]) ? $_POST["home_goals_" . $g->id] : '';
  2035. $away_goals = isset($_POST["away_goals_" . $g->id]) ? $_POST["away_goals_" . $g->id] : '';
  2036. $delete = isset($_POST["delete_" . $g->id]) ? true : false;
  2037. if ($delete)
  2038. {
  2039. $g->played = false;
  2040. $g->home_goals = null;
  2041. $g->away_goals = null;
  2042. $g->home_points = 0;
  2043. $g->away_points = 0;
  2044. $g->save();
  2045. }
  2046. else
  2047. {
  2048. if ($home_goals != '' && $away_goals != '')
  2049. {
  2050. $home_points = 0;
  2051. $away_points = 0;
  2052. if ($home_goals > $away_goals)
  2053. {
  2054. $home_points = 3;
  2055. $away_points = 0;
  2056. }
  2057. else if ($home_goals == $away_goals)
  2058. {
  2059. $home_points = 1;
  2060. $away_points = 1;
  2061. }
  2062. else
  2063. {
  2064. $home_points = 0;
  2065. $away_points = 3;
  2066. }
  2067. $g->played = true;
  2068. $g->home_goals = $home_goals;
  2069. $g->away_goals = $away_goals;
  2070. $g->home_points = $home_points;
  2071. $g->away_points = $away_points;
  2072. $g->save();
  2073. }
  2074. }
  2075. }
  2076. return Redirect::to('/admin/calendars/games/' . $id);
  2077. });
  2078. Route::resource('seasons','SeasonController');
  2079. Route::resource('teams','TeamController');
  2080. Route::get('/videos/sort/{ids}', function ($ids) {
  2081. $idx = explode(",", $ids);
  2082. foreach($idx as $x => $id)
  2083. {
  2084. $v = Video::findOrFail($id);
  2085. $v->position = $x;
  2086. $v->save();
  2087. }
  2088. });
  2089. Route::resource('videos','VideoController');
  2090. Route::resource('users','UserController');
  2091. Route::get('/load_categories/{type}', function ($type) {
  2092. $categories = Category::where('type', '=', $type)->get();
  2093. return $categories->toJson();
  2094. });
  2095. Route::get('/load_groups/{category}', function ($category) {
  2096. $groups = Group::where('category_id', '=', $category)->get();
  2097. return $groups->toJson();
  2098. });
  2099. });
  2100. });
  2101. Route::get('/{slug}/elenco', function ($slug) {
  2102. $home = Home::first();
  2103. if ($home != null)
  2104. $home->loadData();
  2105. $aHome = array();
  2106. if ($home->image != '')
  2107. {
  2108. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  2109. }
  2110. if ($home->image_2 != '')
  2111. {
  2112. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  2113. }
  2114. if ($home->image_3 != '')
  2115. {
  2116. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  2117. }
  2118. if ($home->image_4 != '')
  2119. {
  2120. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  2121. }
  2122. if ($home->image_5 != '')
  2123. {
  2124. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  2125. }
  2126. if (sizeof($aHome) > 0)
  2127. {
  2128. $rnd = rand (0, sizeof($aHome) - 1);
  2129. $home->image = $aHome[$rnd]["image"];
  2130. $home->url = $aHome[$rnd]["url"];
  2131. }
  2132. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  2133. $events = Event::where('online', '=', true)->orderBy('title')->get();
  2134. $sections = Section::orderBy('position')->get();
  2135. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  2136. //if($breaking_news->count() == 0)
  2137. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  2138. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  2139. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  2140. $season_id = @Season::where('default', '=', true)->first()->id;
  2141. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  2142. $calendars = array();
  2143. foreach($cals as $c)
  2144. {
  2145. if ($c->category->grp != '')
  2146. {
  2147. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  2148. if ($c->group_id > 0)
  2149. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  2150. else
  2151. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  2152. }
  2153. }
  2154. $page = Page::where('slug', '=', $slug)->first();
  2155. if ($page != null)
  2156. {
  2157. $section = $page;
  2158. $news = News::where('page_id', '=', $page->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
  2159. return view('section', compact('home', 'news', 'sections', 'pages', 'section', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome'));
  2160. }
  2161. });
  2162. Route::get('/eventi/{slug}', function ($slug) {
  2163. $home = Home::first();
  2164. if ($home != null)
  2165. $home->loadData();
  2166. $aHome = array();
  2167. if ($home->image != '')
  2168. {
  2169. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  2170. }
  2171. if ($home->image_2 != '')
  2172. {
  2173. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  2174. }
  2175. if ($home->image_3 != '')
  2176. {
  2177. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  2178. }
  2179. if ($home->image_4 != '')
  2180. {
  2181. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  2182. }
  2183. if ($home->image_5 != '')
  2184. {
  2185. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  2186. }
  2187. if (sizeof($aHome) > 0)
  2188. {
  2189. $rnd = rand (0, sizeof($aHome) - 1);
  2190. $home->image = $aHome[$rnd]["image"];
  2191. $home->url = $aHome[$rnd]["url"];
  2192. }
  2193. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  2194. $events = Event::where('online', '=', true)->orderBy('title')->get();
  2195. $sections = Section::orderBy('position')->get();
  2196. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  2197. //if($breaking_news->count() == 0)
  2198. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  2199. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  2200. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  2201. $season_id = @Season::where('default', '=', true)->first()->id;
  2202. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  2203. $calendars = array();
  2204. foreach($cals as $c)
  2205. {
  2206. if ($c->category->grp != '')
  2207. {
  2208. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  2209. if ($c->group_id > 0)
  2210. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  2211. else
  2212. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  2213. }
  2214. }
  2215. $event = Event::where('slug', '=', $slug)->first();
  2216. if ($event != null)
  2217. {
  2218. $event->loadLayout();
  2219. /*$aAssigned = array();
  2220. if ($event->big != '')
  2221. $aAssigned[] = @$event->big->id;
  2222. if ($event->small1 != '')
  2223. $aAssigned[] = @$event->small1->id;
  2224. if ($event->small2 != '')
  2225. $aAssigned[] = @$event->small2->id;
  2226. if ($event->small3 != '')
  2227. $aAssigned[] = @$event->small3->id;
  2228. if ($event->small4 != '')
  2229. $aAssigned[] = @$event->small4->id;*/
  2230. $elements = News::where('event_id', '=', $event->id)->take(5)->get();
  2231. return view('event', compact('home', 'event', 'elements', 'sections', 'pages', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome'));
  2232. }
  2233. });
  2234. Route::get('/eventi/{slug}/elenco', function ($slug) {
  2235. $home = Home::first();
  2236. if ($home != null)
  2237. $home->loadData();
  2238. $aHome = array();
  2239. if ($home->image != '')
  2240. {
  2241. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  2242. }
  2243. if ($home->image_2 != '')
  2244. {
  2245. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  2246. }
  2247. if ($home->image_3 != '')
  2248. {
  2249. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  2250. }
  2251. if ($home->image_4 != '')
  2252. {
  2253. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  2254. }
  2255. if ($home->image_5 != '')
  2256. {
  2257. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  2258. }
  2259. if (sizeof($aHome) > 0)
  2260. {
  2261. $rnd = rand (0, sizeof($aHome) - 1);
  2262. $home->image = $aHome[$rnd]["image"];
  2263. $home->url = $aHome[$rnd]["url"];
  2264. }
  2265. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  2266. $events = Event::where('online', '=', true)->orderBy('title')->get();
  2267. $sections = Section::orderBy('position')->get();
  2268. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  2269. //if($breaking_news->count() == 0)
  2270. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  2271. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  2272. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  2273. $season_id = @Season::where('default', '=', true)->first()->id;
  2274. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  2275. $calendars = array();
  2276. foreach($cals as $c)
  2277. {
  2278. if ($c->category->grp != '')
  2279. {
  2280. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  2281. if ($c->group_id > 0)
  2282. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  2283. else
  2284. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  2285. }
  2286. }
  2287. $event = Event::where('slug', '=', $slug)->first();
  2288. if ($event != null)
  2289. {
  2290. $section = $event;
  2291. $news = News::where('event_id', '=', $event->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
  2292. return view('section', compact('home', 'news', 'sections', 'pages', 'section', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome'));
  2293. }
  2294. });
  2295. Route::get('/{slug}/{slug2}', function ($slug, $slug2) {
  2296. $home = Home::first();
  2297. if ($home != null)
  2298. $home->loadData();
  2299. $aHome = array();
  2300. if ($home->image != '')
  2301. {
  2302. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  2303. }
  2304. if ($home->image_2 != '')
  2305. {
  2306. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  2307. }
  2308. if ($home->image_3 != '')
  2309. {
  2310. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  2311. }
  2312. if ($home->image_4 != '')
  2313. {
  2314. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  2315. }
  2316. if ($home->image_5 != '')
  2317. {
  2318. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  2319. }
  2320. if (sizeof($aHome) > 0)
  2321. {
  2322. $rnd = rand (0, sizeof($aHome) - 1);
  2323. $home->image = $aHome[$rnd]["image"];
  2324. $home->url = $aHome[$rnd]["url"];
  2325. }
  2326. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  2327. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  2328. $events = Event::where('online', '=', true)->orderBy('title')->get();
  2329. $sections = Section::orderBy('position')->get();
  2330. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  2331. //if($breaking_news->count() == 0)
  2332. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  2333. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  2334. $season_id = @Season::where('default', '=', true)->first()->id;
  2335. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  2336. $calendars = array();
  2337. foreach($cals as $c)
  2338. {
  2339. if ($c->category->grp != '')
  2340. {
  2341. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  2342. if ($c->group_id > 0)
  2343. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  2344. else
  2345. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  2346. }
  2347. }
  2348. $page = Page::where('slug', '=', $slug)->first();
  2349. if ($page != null)
  2350. {
  2351. $news = News::where('slug', '=', $slug2)->first();
  2352. $clicks = $news->clicks;
  2353. if (!$clicks || $clicks == null)
  2354. $clicks = 0;
  2355. $news->clicks = $clicks + 1;
  2356. $news->save();
  2357. $aImages = array();
  2358. if ($news->image1 != '')
  2359. $aImages[] = $news->image1;
  2360. if ($news->image2 != '')
  2361. $aImages[] = $news->image2;
  2362. if ($news->image3 != '')
  2363. $aImages[] = $news->image3;
  2364. if ($news->image4 != '')
  2365. $aImages[] = $news->image4;
  2366. if ($news->image5 != '')
  2367. $aImages[] = $news->image5;
  2368. $elements = News::where('page_id', '=', $page->id)->where('id', '<>', $news->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->limit(4)->get();
  2369. return view('page', compact('home', 'page', 'elements', 'sections', 'pages', 'news', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aImages', 'regions', 'aHome'));
  2370. }
  2371. });
  2372. Route::get('/calendario/{name}/{id}', function ($name, $id) {
  2373. $home = Home::first();
  2374. if ($home != null)
  2375. $home->loadData();
  2376. $aHome = array();
  2377. if ($home->image != '')
  2378. {
  2379. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  2380. }
  2381. if ($home->image_2 != '')
  2382. {
  2383. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  2384. }
  2385. if ($home->image_3 != '')
  2386. {
  2387. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  2388. }
  2389. if ($home->image_4 != '')
  2390. {
  2391. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  2392. }
  2393. if ($home->image_5 != '')
  2394. {
  2395. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  2396. }
  2397. if (sizeof($aHome) > 0)
  2398. {
  2399. $rnd = rand (0, sizeof($aHome) - 1);
  2400. $home->image = $aHome[$rnd]["image"];
  2401. $home->url = $aHome[$rnd]["url"];
  2402. }
  2403. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  2404. $events = Event::where('online', '=', true)->orderBy('title')->get();
  2405. $sections = Section::orderBy('position')->get();
  2406. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  2407. //if($breaking_news->count() == 0)
  2408. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  2409. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  2410. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  2411. $calendar_games = CalendarGame::where('calendar_id', '=', $id)->get();
  2412. $season_id = @Season::where('default', '=', true)->first()->id;
  2413. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  2414. $calendars = array();
  2415. foreach($cals as $c)
  2416. {
  2417. if ($c->category->grp != '')
  2418. {
  2419. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  2420. if ($c->group_id > 0)
  2421. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  2422. else
  2423. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  2424. }
  2425. }
  2426. $sel = '';
  2427. $games = array();
  2428. $d = '';
  2429. $t = '';
  2430. foreach($calendar_games as $c)
  2431. {
  2432. $games[$c->day . " " . $c->type][] = $c;
  2433. if ($c->date <= date("Y-m-d 00:00:00"))
  2434. {
  2435. $d = $c->day;
  2436. $t = $c->type;
  2437. }
  2438. }
  2439. $c = Calendar::findOrFail($id);
  2440. $aRates = $c->getRates();
  2441. $count = 1;
  2442. foreach($aRates as $idx => $r)
  2443. {
  2444. if ($r["penality"] != '')
  2445. {
  2446. $aRates[$idx]["team"] = $r["team"] . ' ' . str_repeat('*', $count);
  2447. $aRates[$idx]["penality"] = str_repeat('*', $count) . $r["penality"];
  2448. $count += 1;
  2449. }
  2450. }
  2451. $categoryImage = [];
  2452. if ($c->group)
  2453. {
  2454. $categoryImage = array('url' => $c->group->url, "file" => $c->group->image);
  2455. }
  2456. else
  2457. {
  2458. if ($c->category)
  2459. $categoryImage = array('url' => $c->category->url, "file" => $c->category->image);
  2460. }
  2461. return view('calendar', compact('categoryImage', 'home', 'sections', 'pages', 'c', 'games', 'aRates', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome', 'd', 't', 'sel'));
  2462. });
  2463. Route::get('/{slug}', function ($slug) {
  2464. $home = Home::first();
  2465. if ($home != null)
  2466. $home->loadData();
  2467. $aHome = array();
  2468. if ($home->image != '')
  2469. {
  2470. $aHome[] = ['image' => $home->image, 'url' => $home->url];
  2471. }
  2472. if ($home->image_2 != '')
  2473. {
  2474. $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
  2475. }
  2476. if ($home->image_3 != '')
  2477. {
  2478. $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
  2479. }
  2480. if ($home->image_4 != '')
  2481. {
  2482. $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
  2483. }
  2484. if ($home->image_5 != '')
  2485. {
  2486. $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
  2487. }
  2488. if (sizeof($aHome) > 0)
  2489. {
  2490. $rnd = rand (0, sizeof($aHome) - 1);
  2491. $home->image = $aHome[$rnd]["image"];
  2492. $home->url = $aHome[$rnd]["url"];
  2493. }
  2494. $pages = Page::where('online', '=', true)->orderBy('title')->get();
  2495. $events = Event::where('online', '=', true)->orderBy('title')->get();
  2496. $sections = Section::orderBy('position')->get();
  2497. $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
  2498. //if($breaking_news->count() == 0)
  2499. // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
  2500. $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
  2501. $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
  2502. $season_id = @Season::where('default', '=', true)->first()->id;
  2503. $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
  2504. $calendars = array();
  2505. foreach($cals as $c)
  2506. {
  2507. if ($c->category->grp != '')
  2508. {
  2509. $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
  2510. if ($c->group_id > 0)
  2511. $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
  2512. else
  2513. $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
  2514. }
  2515. }
  2516. // Controllo se è una sezione o regione, altrimenti news
  2517. $section = Section::where('slug', '=', $slug)->first();
  2518. if ($section != null)
  2519. {
  2520. if ($section->type == 'section')
  2521. $news = News::where('section_id', '=', $section->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
  2522. else
  2523. {
  2524. $news = News::where('online', '=', true)->where(function ($q) use ($section) {
  2525. $q->where('region_1_id', '=', $section->id)->orWhere('region_2_id', '=', $section->id);
  2526. })->orderBy('date', 'DESC')->get();
  2527. }
  2528. return view('section', compact('home', 'news', 'sections', 'pages', 'section', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome'));
  2529. }
  2530. $news = News::where('slug', '=', $slug)->first();
  2531. if ($news != null)
  2532. {
  2533. // Controllo se è online altrimenti vado alla home
  2534. if (!$news->online || $news->date > date("Y-m-d H:i:s"))
  2535. return Redirect::to('/');
  2536. $clicks = $news->clicks;
  2537. if (!$clicks || $clicks == null)
  2538. $clicks = 0;
  2539. $news->clicks = $clicks + 1;
  2540. $news->save();
  2541. $aImages = array();
  2542. if ($news->image1 != '')
  2543. $aImages[] = $news->image1;
  2544. if ($news->image2 != '')
  2545. $aImages[] = $news->image2;
  2546. if ($news->image3 != '')
  2547. $aImages[] = $news->image3;
  2548. if ($news->image4 != '')
  2549. $aImages[] = $news->image4;
  2550. if ($news->image5 != '')
  2551. $aImages[] = $news->image5;
  2552. $elements = News::where('section_id', '=', $news->section_id)->where('id', '<>', $news->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->limit(5)->get();
  2553. // Se la news è associata ad una pagina, carico gli advs di quella pagina
  2554. $advs = array();
  2555. if ($news->page_id > 0)
  2556. {
  2557. $page = $news->page;
  2558. $advs = $news->page->getAdvs();
  2559. $elements = News::where('page_id', '=', $news->page_id)->where('id', '<>', @$news->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->limit(4)->get();
  2560. return view('page', compact('home', 'page', 'elements', 'sections', 'pages', 'news', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aImages', 'aHome', 'advs'));
  2561. }
  2562. else
  2563. return view('news', compact('home', 'news', 'elements', 'sections', 'pages', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aImages', 'aHome', 'advs'));
  2564. }
  2565. $page = Page::where('slug', '=', $slug)->first();
  2566. if ($page != null)
  2567. {
  2568. $news = News::where('page_id', '=', $page->id)->orderBy('date', 'DESC')->first();
  2569. $aImages = array();
  2570. if ($news)
  2571. {
  2572. if ($news->image1 != '')
  2573. $aImages[] = $news->image1;
  2574. if ($news->image2 != '')
  2575. $aImages[] = $news->image2;
  2576. if ($news->image3 != '')
  2577. $aImages[] = $news->image3;
  2578. if ($news->image4 != '')
  2579. $aImages[] = $news->image4;
  2580. if ($news->image5 != '')
  2581. $aImages[] = $news->image5;
  2582. }
  2583. $elements = News::where('page_id', '=', $page->id)->where('id', '<>', @$news->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->limit(4)->get();
  2584. // $news = $elements->first();
  2585. $advs = $page->getAdvs();
  2586. return view('page', compact('home', 'page', 'elements', 'sections', 'pages', 'news', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aImages', 'aHome', 'advs'));
  2587. }
  2588. /*$event = Event::where('slug', '=', $slug)->first();
  2589. if ($event != null)
  2590. {
  2591. $event->loadLayout();
  2592. $aAssigned = array();
  2593. if ($event->big != '')
  2594. $aAssigned[] = @$event->big->id;
  2595. if ($event->small1 != '')
  2596. $aAssigned[] = @$event->small1->id;
  2597. if ($event->small2 != '')
  2598. $aAssigned[] = @$event->small2->id;
  2599. if ($event->small3 != '')
  2600. $aAssigned[] = @$event->small3->id;
  2601. if ($event->small4 != '')
  2602. $aAssigned[] = @$event->small4->id;
  2603. $elements = News::whereNotIn('id', $aAssigned)->where('event_id', '=', $event->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->limit(5)->get();
  2604. return view('event', compact('home', 'event', 'elements', 'sections', 'pages', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome'));
  2605. }*/
  2606. });