| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498 |
- <?php
- use Illuminate\Support\Facades\Route;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\URL;
- use Illuminate\Support\Facades\App;
- use Illuminate\Support\Str;
- use Illuminate\Support\Facades\Redirect;
- use Illuminate\Http\Request;
- use App\News;
- use App\BreakingNews;
- use App\Section;
- use App\Home;
- use App\Page;
- use App\PageAdv;
- use App\SectionAdv;
- use App\Event;
- use App\Season;
- use App\Video;
- use App\Calendar;
- use App\Category;
- use App\Group;
- use App\CalendarGame;
- use App\Notifications\FacebookPost;
- use App\Notifications\TwitterPost;
- /*
- |--------------------------------------------------------------------------
- | Web Routes
- |--------------------------------------------------------------------------
- |
- | Here is where you can register web routes for your application. These
- | routes are loaded by the RouteServiceProvider within a group which
- | contains the "web" middleware group. Now create something great!
- |
- */
- ini_set("auto_detect_line_endings", true);
- date_default_timezone_set('Europe/Rome');
- Route::get('/test_fb', function(){
- print env('FACEBOOK_ACCESS_TOKEN', '');
- $n = News::findOrFail(41436);
- $n->notify(new FacebookPost());
- });
- Route::get('/update/sections', function () {
- $aPositions = array('big', 'small1', 'small2', 'small3', 'small4', 'small5', 'small6');
- $sections = Section::all();
- foreach($sections as $section)
- {
- print $section->name . "<br>";
- $section_id = $section->id;
- // Carico il layout
- $layout = $section->layout;
- /*$aExist = array();
- foreach($aPositions as $p)
- {
- if ($section[$p] != null)
- $aExist[] = $section[$p];
- }*/
- // Controllo se ci sono news che devono essere pubblicate appartenenti a questa sezione
- $checks = News::where('date', '<=', date('Y-m-d H:i:s'))->where('online', '=', true)->where(function ($q) use ($section_id) {
- $q->where('region_1_id', '=', $section_id)->orWhere('region_2_id', '=', $section_id)->orWhere('section_id', '=', $section_id);
- })->where(function ($q) {
- $q->where('region_1_position', '<>', '')->orWhere('region_2_position', '<>', '')->orWhere('section_position', '<>', '');
- })->get();
- foreach($checks as $n)
- {
- // Controllo se questa news era già in qualche altra posizione
- $old_position = Section::where('big', '=', $n->id)
- ->orWhere('small1', '=', $n->id)
- ->orWhere('small2', '=', $n->id)
- ->orWhere('small3', '=', $n->id)
- ->orWhere('small4', '=', $n->id)
- ->orWhere('small5', '=', $n->id)
- ->orWhere('small6', '=', $n->id)->get();
- if ($old_position->count() > 0)
- {
- foreach($old_position as $old_p)
- {
- foreach($aPositions as $p)
- {
- if ($old_p[$p] == $n->id)
- {
- $old_p[$p] = '';
- $old_p->save();
- }
- }
- }
- }
- // Metto la news nella posizione dove deve essere messa
- foreach($aPositions as $p)
- {
- if ($n->section_id == $section_id && $n->section_position == $p)
- {
- print "Metto la news " . $n->title . " nella posizione " . $p . " della sezione/regione " . $section->name . "<br>";
- $section[$p] = $n->id;
- $section->save();
- $n->section_position = '';
- if (!$n->published)
- {
- //$n->notify(new FacebookPost());
- //$n->notify(new TwitterPost());
- $n->published = true;
- }
- $n->save();
- }
- if ($n->region_1_id == $section_id && $n->region_1_position == $p)
- {
- print "Metto la news " . $n->title . " nella posizione " . $p . " della sezione/regione " . $section->name . "<br>";
- $section[$p] = $n->id;
- $section->save();
- $n->region_1_position = '';
- if (!$n->published)
- {
- // $n->notify(new FacebookPost());
- $n->notify(new TwitterPost());
- $n->published = true;
- }
- $n->save();
- }
- if ($n->region_2_id == $section_id && $n->region_2_position == $p)
- {
- print "Metto la news " . $n->title . " nella posizione " . $p . " della sezione/regione " . $section->name . "<br>";
- $section[$p] = $n->id;
- $section->save();
- $n->region_2_position = '';
- if (!$n->published)
- {
- // $n->notify(new FacebookPost());
- $n->notify(new TwitterPost());
- $n->published = true;
- }
- $n->save();
- }
- }
- }
- }
- $sections = Section::all();
- foreach($sections as $section)
- {
- $aExist = array();
- foreach($aPositions as $p)
- {
- if ($section[$p] != null)
- $aExist[] = $section[$p];
- }
- // Riempio i vuoti
- $news = News::whereNotIn('id', $aExist)->where(function ($q) use ($section_id) {
- $q->where('section_id', '=', $section_id)->orWhere('region_1_id', '=', $section_id)->orWhere('region_2_id', '=', $section_id);
- })->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
- $idx = 0;
- if ($section->big == '')
- {
- $section->big = @$news[$idx]->id;
- $idx++;
- }
- if ($section->small1 == '')
- {
- $section->small1 = @$news[$idx]->id;
- $idx++;
- }
- if ($section->small2 == '')
- {
- $section->small2 = @$news[$idx]->id;
- $idx++;
- }
- if ($section->small3 == '')
- {
- $section->small3 = @$news[$idx]->id;
- $idx++;
- }
- if ($layout == 'layout_3' || $layout == 'layout_4' || $layout == 'layout_5')
- {
- if ($section->small4 == '')
- {
- $section->small4 = @$news[$idx]->id;
- $idx++;
- }
- if ($layout == 'layout_4')
- {
- if ($section->small5 == '')
- {
- $section->small5 = @$news[$idx]->id;
- $idx++;
- }
- if ($section->small6 == '')
- {
- $section->small6 = @$news[$idx]->id;
- $idx++;
- }
- }
- else
- {
- $section->small5 = '';
- $section->small6 = '';
- }
- }
- else
- {
- $section->small4 = '';
- $section->small5 = '';
- $section->small6 = '';
- }
- $section->save();
- }
- });
- Route::get('sitemap.xml', function() {
- // create new sitemap object
- $sitemap = App::make('sitemap');
- // set cache key (string), duration in minutes (Carbon|Datetime|int), turn on/off (boolean)
- // by default cache is disabled
- $sitemap->setCache('laravel.sitemap', 60);
- // check if there is cached sitemap and build new only if is not
- if (!$sitemap->isCached())
- {
- // add item to the sitemap (url, date, priority, freq)
- $sitemap->add(URL::to('/'), date("Y-m-d H:i:s"), '1.0', 'daily');
- $sections = Section::orderBy('position')->get();
- foreach($sections as $section)
- $sitemap->add(URL::to('/' . $section->slug), date("Y-m-d H:i:s", strtotime($section->updated_at)), '0.9', 'daily');
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- foreach($pages as $page)
- $sitemap->add(URL::to('/' . $page->slug), date("Y-m-d H:i:s", strtotime($page->updated_at)), '0.9', 'daily');
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- foreach($events as $event)
- $sitemap->add(URL::to('/' . $event->slug), date("Y-m-d H:i:s", strtotime($event->updated_at)), '0.9', 'daily');
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- foreach($calendars as $type => $categories)
- {
- foreach($categories as $category => $groups)
- {
- if(is_array($groups))
- {
- foreach($groups as $group => $cal)
- {
- $sitemap->add(URL::to('/calendario/' . Str::slug($category) . "-" . Str::slug($group) . "/" . $cal), date("Y-m-d H:i:s"), '0.9', 'daily');
- }
- }
- else
- $sitemap->add(URL::to('/calendario/' . Str::slug($category) . "-" . Str::slug($groups)), date("Y-m-d H:i:s"), '0.9', 'daily');
- }
- }
- //$news = News::where('online', '=', true)->where('breaking_news', '=', false)->orderBy('date', 'DESC')->get();
- //foreach($news as $n)
- // $sitemap->add(URL::to('/' . $n->slug), date("Y-m-d H:i:s", strtotime($n->updated_at)), '0.9', 'hourly');
- //$cals = Calendar::orderBy('position')->get();
- //foreach($cals as $c)
- // $sitemap->add(URL::to('/' . $c->slug), date("Y-m-d H:i:s", strtotime($c->updated_at)), '0.9', 'daily');
- /*
- //$sitemap->add(URL::to('page'), '2012-08-26T12:30:00+02:00', '0.9', 'monthly');
- /*
- // add item with translations (url, date, priority, freq, images, title, translations)
- $translations = [
- ['language' => 'fr', 'url' => URL::to('pageFr')],
- ['language' => 'de', 'url' => URL::to('pageDe')],
- ['language' => 'bg', 'url' => URL::to('pageBg')],
- ];
- $sitemap->add(URL::to('pageEn'), '2015-06-24T14:30:00+02:00', '0.9', 'monthly', [], null, $translations);
- // add item with images
- $images = [
- ['url' => URL::to('images/pic1.jpg'), 'title' => 'Image title', 'caption' => 'Image caption', 'geo_location' => 'Plovdiv, Bulgaria'],
- ['url' => URL::to('images/pic2.jpg'), 'title' => 'Image title2', 'caption' => 'Image caption2'],
- ['url' => URL::to('images/pic3.jpg'), 'title' => 'Image title3'],
- ];
- $sitemap->add(URL::to('post-with-images'), '2015-06-24T14:30:00+02:00', '0.9', 'monthly', $images);
- // get all posts from db
- $posts = DB::table('posts')->orderBy('created_at', 'desc')->get();
- // add every post to the sitemap
- foreach ($posts as $post) {
- $sitemap->add($post->slug, $post->modified, $post->priority, $post->freq);
- }*/
- }
- // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
- return $sitemap->render('xml');
- });
- Route::get('/', function () {
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = 0;//rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $show_top = true;
- if ($home->banner_right_big != '' || $home->banner_right_big_2 != '' || $home->banner_right_big_3 != '' || $home->banner_right_big_google != '')
- $show_top = false;
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- // $sections = Section::where('type', '=', 'section')->orderBy('position')->get();
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $sections = Section::where('layout', '!=', '')->orderBy('position')->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $videos = Video::where('online', '=', true)->limit(10)->orderBy('position')->get();
- foreach($videos as $i => $v)
- {
- $x = $v->url;
- $x = str_replace("https", "", $x);
- $x = str_replace("http", "", $x);
- $v->url = $x;
- }
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- // $sections_after = Section::where('type', '=', 'section')->where('after', '=', true)->where('layout', '!=', '')->orderBy('position')->get();
- return view('index', compact('home', 'sections', 'sections_menu', 'regions', 'pages', 'breaking_news', 'videos', 'events', 'calendars', 'aHome', 'show_top'));
- });
- Route::get('/videos', function(){
- $videos = Video::where('online', '=', true)->orderBy('date', 'DESC')->get();
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- $sections = Section::orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- /*$calendars = array();
- foreach($cals as $c)
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->name][$c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->name] = $c->id;
- }*/
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- return view('video', compact('videos', 'home', 'sections', 'sections_menu', 'regions', 'pages', 'breaking_news', 'videos', 'events', 'calendars', 'aHome'));
- });
- Route::get('/ricerca', function(){
- $news = News::where('id', -1)->get();
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- $sections = Section::orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- $search = '';
- $videos = array();
- return view('search', compact('news', 'search', 'home', 'sections', 'sections_menu', 'regions', 'pages', 'breaking_news', 'videos', 'events', 'calendars', 'aHome'));
- });
- Route::post('/ricerca', function(){
- $search = $_POST["search"];
- if ($search != '')
- {
- $news = News::where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->where(function ($q) use ($search) {
- $q->where('title', 'like', '%' . $search . '%')
- ->orWhere('title_region_1', 'like', '%' . $search . '%')
- ->orWhere('title_region_2', 'like', '%' . $search . '%')
- ->orWhere('text_short', 'like', '%' . $search . '%')
- ->orWhere('text', 'like', '%' . $search . '%');
- })->orderBy('date', 'DESC')->get();
- }
- else
- $news = News::where('id', -1)->get();
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- $sections = Section::orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- $videos = array();
- return view('search', compact('news', 'search', 'home', 'sections', 'sections_menu', 'regions', 'pages', 'breaking_news', 'videos', 'events', 'calendars', 'aHome'));
- });
- Route::get('/eventi', function(){
- $news = News::where('id', -1)->get();
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- $sections = Section::orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- $videos = array();
- return view('events', compact('news', 'home', 'sections', 'sections_menu', 'regions', 'pages', 'breaking_news', 'videos', 'events', 'calendars', 'aHome'));
- });
- Route::get('/archivio', function() {
- $news = News::where('id', -1)->get();
- $home = Home::first();
- if ($home != null) {
- $home->loadData();
- }
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $archivedCalendars = Calendar::where('archived', true)
- ->with(['category', 'group']) // Eager load relationships
- ->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- $seasons = Season::where('default', false)->orderBy('name', 'desc')->get();
- $sections = Section::where('type', '=', 'section')
- ->orderBy('position')
- ->get();
- $regions = Section::where('type', '=', 'region')
- ->orderBy('name')
- ->get();
- $categories = Category::orderBy('name')->get();
- $groups = Group::orderBy('name')->get();
- $seasonsForJs = $seasons->map(function($season) {
- return [
- 'id' => $season->id,
- 'name' => $season->name
- ];
- });
- return view('calendar_archive', compact(
- 'news',
- 'home',
- 'sections',
- 'sections_menu',
- 'regions',
- 'pages',
- 'breaking_news',
- 'seasons',
- 'seasonsForJs',
- 'categories',
- 'groups',
- 'archivedCalendars',
- 'aHome',
- 'calendars'
- ));
- });
- Route::get('/api/archive/calendars/search', function(Request $request) {
- $query = Calendar::with(['season', 'category', 'group']) // Eager load relationships
- ->where('archived', true);
- if ($request->season_id) {
- $query->where('season_id', $request->season_id);
- }
- if ($request->type) {
- $query->whereHas('category', function($q) use ($request) {
- $q->where('type', $request->type);
- });
- }
- if ($request->category_id) {
- $query->where('category_id', $request->category_id);
- }
- if ($request->group_id) {
- $query->where('group_id', $request->group_id);
- }
- $calendars = $query->orderBy('position')->get()
- ->map(function($calendar) {
- return [
- 'id' => $calendar->id,
- 'name' => $calendar->name,
- 'season' => $calendar->season ? $calendar->season->name : '',
- 'category' => $calendar->category ? $calendar->category->name : '',
- 'group' => $calendar->group ? $calendar->group->name : '',
- 'type' => $calendar->category ? $calendar->category->type : '',
- 'position' => $calendar->position
- ];
- });
- return response()->json([
- 'success' => true,
- 'data' => $calendars
- ]);
- });
- Route::get('/video/{id}', function ($id) {
- $video = Video::findOrFail($id);
- if ($video->file != '')
- {
- $html = '<video width="640" height="480" controls>
- <source src="/files/videos/' . $video->file . '" type="video/mp4">
- Your browser does not support the video tag.
- </video>';
- print $html;
- }
- else
- print $video->embed;
- });
- Route::get('/section/{id}', function ($id) {
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- //$sections = Section::orderBy('position')->get();
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $sections = Section::where('layout', '!=', '')->orderBy('position')->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $news = News::where('section_id', '=', $id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- return view('section', compact('home', 'news', 'sections', 'sections_menu', 'pages', 'regions', 'events', 'breaking_news', 'calendars', 'aHome'));
- });
- Route::get('/admin', function () {
- if (Auth::check())
- return Redirect::to('/admin/dashboard');
- else
- return view('admin');
- });
- Route::get('/logout', function () {
- Auth::logout();
- return Redirect::to('/admin');
- });
- Route::post('/login', function(){
- if ($user = Auth::attempt(['email' => $_POST["email"], 'password' => $_POST["password"]]))
- return Redirect::to('/admin/dashboard');
- else
- return view('admin')->with('message', 'Errore login');
- });
- Route::group(['middleware' => 'auth'], function () {
- Route::prefix('admin')->group(function () {
- Route::get('/dashboard', function ()
- {
- $sections = Section::where('type', '=', 'section')->orderBy('position')->get();
- $regions = Section::where('type', '=', 'region')->orderBy('position')->get();
- return view('admin.dashboard', compact('sections', 'regions'));
- });
- Route::get('/home', function () {
- $home = Home::first();
- if ($home == null)
- {
- $home = new Home();
- $home->save();
- }
- $home->loadData();
- $aAssigned = array();
- if ($home->slide1 != '')
- $aAssigned[] = $home->slide1->id;
- if ($home->left1 != '')
- $aAssigned[] = $home->left1->id;
- if ($home->left2 != '')
- $aAssigned[] = $home->left2->id;
- if ($home->left3 != '')
- $aAssigned[] = $home->left3->id;
- if ($home->right1 != '')
- $aAssigned[] = $home->right1->id;
- if ($home->right2 != '')
- $aAssigned[] = $home->right2->id;
- if ($home->right3 != '')
- $aAssigned[] = $home->right3->id;
- $news = News::where('online', '=', 1)->whereNotIn('id', $aAssigned)->orderBy('date', 'DESC')->limit(1000)->get();
- return view('admin.home',compact('home', 'news'));
- })->name('home');
- Route::post('/home', function () {
- $home = Home::first();
- if ($home == null)
- $home = new Home();
- $slide1 = isset($_POST["slide1"]) ? $_POST["slide1"] : '';
- $left1 = isset($_POST["left1"]) ? $_POST["left1"] : '';
- $left2 = isset($_POST["left2"]) ? $_POST["left2"] : '';
- $left3 = isset($_POST["left3"]) ? $_POST["left3"] : '';
- $left4 = isset($_POST["left4"]) ? $_POST["left4"] : '';
- $left5 = isset($_POST["left5"]) ? $_POST["left5"] : '';
- $right1 = isset($_POST["right1"]) ? $_POST["right1"] : '';
- $right2 = isset($_POST["right2"]) ? $_POST["right2"] : '';
- $right3 = isset($_POST["right3"]) ? $_POST["right3"] : '';
- $right4 = isset($_POST["right4"]) ? $_POST["right4"] : '';
- $right5 = isset($_POST["right5"]) ? $_POST["right5"] : '';
- if (isset($_POST["delete_image"]))
- {
- $image = '';
- $home->image = $image;
- }
- else
- {
- if(isset($_POST["image"]))
- {
- $file = $_POST["image"];
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- $_POST["image"]->move($path, $filename);
- $image = $filename;
- $home->image = $image;
- }
- }
- //$url = isset($_POST["url"]) ? $_POST["url"] : '';
- $home->slide1 = $slide1;
- $home->left1 = $left1;
- $home->left2 = $left2;
- $home->left3 = $left3;
- $home->left4 = $left4;
- $home->left5 = $left5;
- $home->right1 = $right1;
- $home->right2 = $right2;
- $home->right3 = $right3;
- $home->right4 = $right4;
- $home->right5 = $right5;
- //$home->url = $url;
- $home->save();
- return Redirect::to('/admin/home');
- })->name('home');
- Route::get('/home_adv', function () {
- $home = Home::first();
- if ($home == null)
- {
- $home = new Home();
- $home->save();
- }
- $home->loadData();
- return view('admin.home_adv',compact('home'));
- })->name('home_adv');
- Route::post('/home_adv', function () {
- $home = Home::first();
- if ($home == null)
- $home = new Home();
- if (isset($_POST["delete_image"]))
- {
- $image = '';
- $home->image = $image;
- }
- else
- {
- if(request()->image)
- {
- $file = request()->image;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->image->move($path, $filename);
- $image = $filename;
- $home->image = $image;
- }
- }
- $url = isset($_POST["url"]) ? $_POST["url"] : '';
- $home->url = $url;
- if (isset($_POST["delete_image_2"]))
- {
- $image_2 = '';
- $home->image_2 = $image_2;
- }
- else
- {
- if(request()->image_2)
- {
- $file = request()->image_2;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->image_2->move($path, $filename);
- $image_2 = $filename;
- $home->image_2 = $image_2;
- }
- }
- $url_2 = isset($_POST["url_2"]) ? $_POST["url_2"] : '';
- $home->url_2 = $url_2;
- if (isset($_POST["delete_image_3"]))
- {
- $image_3 = '';
- $home->image_3 = $image_3;
- }
- else
- {
- if(request()->image_3)
- {
- $file = request()->image_3;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->image_3->move($path, $filename);
- $image_3 = $filename;
- $home->image_3 = $image_3;
- }
- }
- $url_3 = isset($_POST["url_3"]) ? $_POST["url_3"] : '';
- $home->url_3 = $url_3;
- if (isset($_POST["delete_image_4"]))
- {
- $image_4 = '';
- $home->image_4 = $image_4;
- }
- else
- {
- if(request()->image_4)
- {
- $file = request()->image_4;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->image_4->move($path, $filename);
- $image_4 = $filename;
- $home->image_4 = $image_4;
- }
- }
- $url_4 = isset($_POST["url_4"]) ? $_POST["url_4"] : '';
- $home->url_4 = $url_4;
- if (isset($_POST["delete_image_5"]))
- {
- $image_5 = '';
- $home->image_5 = $image_5;
- }
- else
- {
- if(request()->image_5)
- {
- $file = request()->image_5;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->image_5->move($path, $filename);
- $image_5 = $filename;
- $home->image_5 = $image_5;
- }
- }
- $url_5 = isset($_POST["url_5"]) ? $_POST["url_5"] : '';
- $home->url_5 = $url_5;
- if (isset($_POST["delete_banner_top"]))
- {
- $banner_top = '';
- $home->banner_top = $banner_top;
- }
- else
- {
- if(request()->banner_top)
- {
- $file = request()->banner_top;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_top->move($path, $filename);
- $banner_top = $filename;
- $home->banner_top = $banner_top;
- }
- }
- $banner_top_url = isset($_POST["banner_top_url"]) ? $_POST["banner_top_url"] : '';
- $home->banner_top_url = $banner_top_url;
- if (isset($_POST["delete_banner_top_2"]))
- {
- $banner_top_2 = '';
- $home->banner_top_2 = $banner_top_2;
- }
- else
- {
- if(request()->banner_top_2)
- {
- $file = request()->banner_top_2;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_top_2->move($path, $filename);
- $banner_top_2 = $filename;
- $home->banner_top_2 = $banner_top_2;
- }
- }
- $banner_top_2_url = isset($_POST["banner_top_2_url"]) ? $_POST["banner_top_2_url"] : '';
- $home->banner_top_2_url = $banner_top_2_url;
- if (isset($_POST["delete_banner_top_3"]))
- {
- $banner_top_3 = '';
- $home->banner_top_3 = $banner_top_3;
- }
- else
- {
- if(request()->banner_top_3)
- {
- $file = request()->banner_top_3;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_top_3->move($path, $filename);
- $banner_top_3 = $filename;
- $home->banner_top_3 = $banner_top_3;
- }
- }
- $banner_top_3_url = isset($_POST["banner_top_3_url"]) ? $_POST["banner_top_3_url"] : '';
- $home->banner_top_3_url = $banner_top_3_url;
- if (isset($_POST["delete_banner_top_4"]))
- {
- $banner_top_4 = '';
- $home->banner_top_4 = $banner_top_4;
- }
- else
- {
- if(request()->banner_top_4)
- {
- $file = request()->banner_top_4;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_top_4->move($path, $filename);
- $banner_top_4 = $filename;
- $home->banner_top_4 = $banner_top_4;
- }
- }
- $banner_top_4_url = isset($_POST["banner_top_4_url"]) ? $_POST["banner_top_4_url"] : '';
- $home->banner_top_4_url = $banner_top_4_url;
- if (isset($_POST["delete_banner_top_5"]))
- {
- $banner_top_5 = '';
- $home->banner_top_5 = $banner_top_5;
- }
- else
- {
- if(request()->banner_top_5)
- {
- $file = request()->banner_top_5;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_top_5->move($path, $filename);
- $banner_top_5 = $filename;
- $home->banner_top_5 = $banner_top_5;
- }
- }
- $banner_top_5_url = isset($_POST["banner_top_5_url"]) ? $_POST["banner_top_5_url"] : '';
- $home->banner_top_5_url = $banner_top_5_url;
- $banner_top_google = isset($_POST["banner_top_google"]) ? $_POST["banner_top_google"] : '';
- $home->banner_top_google = $banner_top_google;
- if (isset($_POST["delete_banner_underb"]))
- {
- $banner_underb = '';
- $home->banner_underb = $banner_underb;
- }
- else
- {
- if(request()->banner_underb)
- {
- $file = request()->banner_underb;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_underb->move($path, $filename);
- $banner_underb = $filename;
- $home->banner_underb = $banner_underb;
- }
- }
- $banner_underb_url = isset($_POST["banner_underb_url"]) ? $_POST["banner_underb_url"] : '';
- $home->banner_underb_url = $banner_underb_url;
- if (isset($_POST["delete_banner_underb_2"]))
- {
- $banner_underb_2 = '';
- $home->banner_underb_2 = $banner_underb_2;
- }
- else
- {
- if(request()->banner_underb_2)
- {
- $file = request()->banner_underb_2;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_underb_2->move($path, $filename);
- $banner_underb_2 = $filename;
- $home->banner_underb_2 = $banner_underb_2;
- }
- }
- $banner_underb_2_url = isset($_POST["banner_underb_2_url"]) ? $_POST["banner_underb_2_url"] : '';
- $home->banner_underb_2_url = $banner_underb_2_url;
- if (isset($_POST["delete_banner_underb_3"]))
- {
- $banner_underb_3 = '';
- $home->banner_underb_3 = $banner_underb_3;
- }
- else
- {
- if(request()->banner_underb_3)
- {
- $file = request()->banner_underb_3;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_underb_3->move($path, $filename);
- $banner_underb_3 = $filename;
- $home->banner_underb_3 = $banner_underb_3;
- }
- }
- $banner_underb_3_url = isset($_POST["banner_underb_3_url"]) ? $_POST["banner_underb_3_url"] : '';
- $home->banner_underb_3_url = $banner_underb_3_url;
- if (isset($_POST["delete_banner_underb_4"]))
- {
- $banner_underb_4 = '';
- $home->banner_underb_4 = $banner_underb_4;
- }
- else
- {
- if(request()->banner_underb_4)
- {
- $file = request()->banner_underb_4;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_underb_4->move($path, $filename);
- $banner_underb_4 = $filename;
- $home->banner_underb_4 = $banner_underb_4;
- }
- }
- $banner_underb_4_url = isset($_POST["banner_underb_4_url"]) ? $_POST["banner_underb_4_url"] : '';
- $home->banner_underb_4_url = $banner_underb_4_url;
- if (isset($_POST["delete_banner_underb_5"]))
- {
- $banner_underb_5 = '';
- $home->banner_underb_5 = $banner_underb_5;
- }
- else
- {
- if(request()->banner_underb_5)
- {
- $file = request()->banner_underb_5;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_underb_5->move($path, $filename);
- $banner_underb_5 = $filename;
- $home->banner_underb_5 = $banner_underb_5;
- }
- }
- $banner_underb_5_url = isset($_POST["banner_underb_5_url"]) ? $_POST["banner_underb_5_url"] : '';
- $home->banner_underb_5_url = $banner_underb_5_url;
- $banner_underb_google = isset($_POST["banner_underb_google"]) ? $_POST["banner_underb_google"] : '';
- $home->banner_underb_google = $banner_underb_google;
- if (isset($_POST["delete_banner_middle"]))
- {
- $banner_middle = '';
- $home->banner_middle = $banner_middle;
- }
- else
- {
- if(request()->banner_middle)
- {
- $file = request()->banner_middle;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_middle->move($path, $filename);
- $banner_middle = $filename;
- $home->banner_middle = $banner_middle;
- }
- }
- $banner_middle_url = isset($_POST["banner_middle_url"]) ? $_POST["banner_middle_url"] : '';
- $home->banner_middle_url = $banner_middle_url;
- if (isset($_POST["delete_banner_middle_2"]))
- {
- $banner_middle_2 = '';
- $home->banner_middle_2 = $banner_middle_2;
- }
- else
- {
- if(request()->banner_middle_2)
- {
- $file = request()->banner_middle_2;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_middle_2->move($path, $filename);
- $banner_middle_2 = $filename;
- $home->banner_middle_2 = $banner_middle_2;
- }
- }
- $banner_middle_2_url = isset($_POST["banner_middle_2_url"]) ? $_POST["banner_middle_2_url"] : '';
- $home->banner_middle_2_url = $banner_middle_2_url;
- if (isset($_POST["delete_banner_middle_3"]))
- {
- $banner_middle_3 = '';
- $home->banner_middle_3 = $banner_middle_3;
- }
- else
- {
- if(request()->banner_middle_3)
- {
- $file = request()->banner_middle_3;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_middle_3->move($path, $filename);
- $banner_middle_3 = $filename;
- $home->banner_middle_3 = $banner_middle_3;
- }
- }
- $banner_middle_3_url = isset($_POST["banner_middle_3_url"]) ? $_POST["banner_middle_3_url"] : '';
- $home->banner_middle_3_url = $banner_middle_3_url;
- if (isset($_POST["delete_banner_middle_4"]))
- {
- $banner_middle_4 = '';
- $home->banner_middle_4 = $banner_middle_4;
- }
- else
- {
- if(request()->banner_middle_4)
- {
- $file = request()->banner_middle_4;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_middle_4->move($path, $filename);
- $banner_middle_4 = $filename;
- $home->banner_middle_4 = $banner_middle_4;
- }
- }
- $banner_middle_4_url = isset($_POST["banner_middle_4_url"]) ? $_POST["banner_middle_4_url"] : '';
- $home->banner_middle_4_url = $banner_middle_4_url;
- if (isset($_POST["delete_banner_middle_5"]))
- {
- $banner_middle_5 = '';
- $home->banner_middle_5 = $banner_middle_5;
- }
- else
- {
- if(request()->banner_middle_5)
- {
- $file = request()->banner_middle_5;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_middle_5->move($path, $filename);
- $banner_middle_5 = $filename;
- $home->banner_middle_5 = $banner_middle_5;
- }
- }
- $banner_middle_5_url = isset($_POST["banner_middle_5_url"]) ? $_POST["banner_middle_5_url"] : '';
- $home->banner_middle_5_url = $banner_middle_5_url;
- $banner_middle_google = isset($_POST["banner_middle_google"]) ? $_POST["banner_middle_google"] : '';
- $home->banner_middle_google = $banner_middle_google;
- if (isset($_POST["delete_banner_first"]))
- {
- $banner_first = '';
- $home->banner_first = $banner_first;
- }
- else
- {
- if(request()->banner_first)
- {
- $file = request()->banner_first;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_first->move($path, $filename);
- $banner_first = $filename;
- $home->banner_first = $banner_first;
- }
- }
- $banner_first_url = isset($_POST["banner_first_url"]) ? $_POST["banner_first_url"] : '';
- $home->banner_first_url = $banner_first_url;
- if (isset($_POST["delete_banner_first_2"]))
- {
- $banner_first_2 = '';
- $home->banner_first_2 = $banner_first_2;
- }
- else
- {
- if(request()->banner_first_2)
- {
- $file = request()->banner_first_2;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_first_2->move($path, $filename);
- $banner_first_2 = $filename;
- $home->banner_first_2 = $banner_first_2;
- }
- }
- $banner_first_2_url = isset($_POST["banner_first_2_url"]) ? $_POST["banner_first_2_url"] : '';
- $home->banner_first_2_url = $banner_first_2_url;
- if (isset($_POST["delete_banner_first_3"]))
- {
- $banner_first_3 = '';
- $home->banner_first_3 = $banner_first_3;
- }
- else
- {
- if(request()->banner_first_3)
- {
- $file = request()->banner_first_3;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_first_3->move($path, $filename);
- $banner_first_3 = $filename;
- $home->banner_first_3 = $banner_first_3;
- }
- }
- $banner_first_3_url = isset($_POST["banner_first_3_url"]) ? $_POST["banner_first_3_url"] : '';
- $home->banner_first_3_url = $banner_first_3_url;
- if (isset($_POST["delete_banner_first_4"]))
- {
- $banner_first_4 = '';
- $home->banner_first_4 = $banner_first_4;
- }
- else
- {
- if(request()->banner_first_4)
- {
- $file = request()->banner_first_4;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_first_4->move($path, $filename);
- $banner_first_4 = $filename;
- $home->banner_first_4 = $banner_first_4;
- }
- }
- $banner_first_4_url = isset($_POST["banner_first_4_url"]) ? $_POST["banner_first_4_url"] : '';
- $home->banner_first_4_url = $banner_first_4_url;
- if (isset($_POST["delete_banner_first_5"]))
- {
- $banner_first_5 = '';
- $home->banner_first_5 = $banner_first_5;
- }
- else
- {
- if(request()->banner_first_5)
- {
- $file = request()->banner_first_5;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_first_5->move($path, $filename);
- $banner_first_5 = $filename;
- $home->banner_first_5 = $banner_first_5;
- }
- }
- $banner_first_5_url = isset($_POST["banner_first_5_url"]) ? $_POST["banner_first_5_url"] : '';
- $home->banner_first_5_url = $banner_first_5_url;
- $banner_first_google = isset($_POST["banner_first_google"]) ? $_POST["banner_first_google"] : '';
- $home->banner_first_google = $banner_first_google;
- if (isset($_POST["delete_banner_right_top"]))
- {
- $banner_right_top = '';
- $home->banner_right_top = $banner_right_top;
- }
- else
- {
- if(request()->banner_right_top)
- {
- $file = request()->banner_right_top;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_top->move($path, $filename);
- $banner_right_top = $filename;
- $home->banner_right_top = $banner_right_top;
- }
- }
- $banner_right_top_url = isset($_POST["banner_right_top_url"]) ? $_POST["banner_right_top_url"] : '';
- $home->banner_right_top_url = $banner_right_top_url;
- if (isset($_POST["delete_banner_right_top_2"]))
- {
- $banner_right_top_2 = '';
- $home->banner_right_top_2 = $banner_right_top_2;
- }
- else
- {
- if(request()->banner_right_top_2)
- {
- $file = request()->banner_right_top_2;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_top_2->move($path, $filename);
- $banner_right_top_2 = $filename;
- $home->banner_right_top_2 = $banner_right_top_2;
- }
- }
- $banner_right_top_2_url = isset($_POST["banner_right_top_2_url"]) ? $_POST["banner_right_top_2_url"] : '';
- $home->banner_right_top_2_url = $banner_right_top_2_url;
- if (isset($_POST["delete_banner_right_top_3"]))
- {
- $banner_right_top_3 = '';
- $home->banner_right_top_3 = $banner_right_top_3;
- }
- else
- {
- if(request()->banner_right_top_3)
- {
- $file = request()->banner_right_top_3;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_top_3->move($path, $filename);
- $banner_right_top_3 = $filename;
- $home->banner_right_top_3 = $banner_right_top_3;
- }
- }
- $banner_right_top_3_url = isset($_POST["banner_right_top_3_url"]) ? $_POST["banner_right_top_3_url"] : '';
- $home->banner_right_top_3_url = $banner_right_top_3_url;
- if (isset($_POST["delete_banner_right_top_4"]))
- {
- $banner_right_top_4 = '';
- $home->banner_right_top_4 = $banner_right_top_4;
- }
- else
- {
- if(request()->banner_right_top_4)
- {
- $file = request()->banner_right_top_4;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_top_4->move($path, $filename);
- $banner_right_top_4 = $filename;
- $home->banner_right_top_4 = $banner_right_top_4;
- }
- }
- $banner_right_top_4_url = isset($_POST["banner_right_top_4_url"]) ? $_POST["banner_right_top_4_url"] : '';
- $home->banner_right_top_4_url = $banner_right_top_4_url;
- if (isset($_POST["delete_banner_right_top_5"]))
- {
- $banner_right_top_5 = '';
- $home->banner_right_top_5 = $banner_right_top_5;
- }
- else
- {
- if(request()->banner_right_top_5)
- {
- $file = request()->banner_right_top_5;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_top_5->move($path, $filename);
- $banner_right_top_5 = $filename;
- $home->banner_right_top_5 = $banner_right_top_5;
- }
- }
- $banner_right_top_5_url = isset($_POST["banner_right_top_5_url"]) ? $_POST["banner_right_top_5_url"] : '';
- $home->banner_right_top_5_url = $banner_right_top_5_url;
- $banner_right_top_google = isset($_POST["banner_right_top_google"]) ? $_POST["banner_right_top_google"] : '';
- $home->banner_right_top_google = $banner_right_top_google;
- if (isset($_POST["delete_banner_right_bottom"]))
- {
- $banner_right_bottom = '';
- $home->banner_right_bottom = $banner_right_bottom;
- }
- else
- {
- if(request()->banner_right_bottom)
- {
- $file = request()->banner_right_bottom;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_bottom->move($path, $filename);
- $banner_right_bottom = $filename;
- $home->banner_right_bottom = $banner_right_bottom;
- }
- }
- $banner_right_bottom_url = isset($_POST["banner_right_bottom_url"]) ? $_POST["banner_right_bottom_url"] : '';
- $home->banner_right_bottom_url = $banner_right_bottom_url;
- if (isset($_POST["delete_banner_right_bottom_2"]))
- {
- $banner_right_bottom_2 = '';
- $home->banner_right_bottom_2 = $banner_right_bottom_2;
- }
- else
- {
- if(request()->banner_right_bottom_2)
- {
- $file = request()->banner_right_bottom_2;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_bottom_2->move($path, $filename);
- $banner_right_bottom_2 = $filename;
- $home->banner_right_bottom_2 = $banner_right_bottom_2;
- }
- }
- $banner_right_bottom_2_url = isset($_POST["banner_right_bottom_2_url"]) ? $_POST["banner_right_bottom_2_url"] : '';
- $home->banner_right_bottom_2_url = $banner_right_bottom_2_url;
- if (isset($_POST["delete_banner_right_bottom_3"]))
- {
- $banner_right_bottom_3 = '';
- $home->banner_right_bottom_3 = $banner_right_bottom_3;
- }
- else
- {
- if(request()->banner_right_bottom_3)
- {
- $file = request()->banner_right_bottom_3;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_bottom_3->move($path, $filename);
- $banner_right_bottom_3 = $filename;
- $home->banner_right_bottom_3 = $banner_right_bottom_3;
- }
- }
- $banner_right_bottom_3_url = isset($_POST["banner_right_bottom_3_url"]) ? $_POST["banner_right_bottom_3_url"] : '';
- $home->banner_right_bottom_3_url = $banner_right_bottom_3_url;
- if (isset($_POST["delete_banner_right_bottom_4"]))
- {
- $banner_right_bottom_4 = '';
- $home->banner_right_bottom_4 = $banner_right_bottom_4;
- }
- else
- {
- if(request()->banner_right_bottom_4)
- {
- $file = request()->banner_right_bottom_4;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_bottom_4->move($path, $filename);
- $banner_right_bottom_4 = $filename;
- $home->banner_right_bottom_4 = $banner_right_bottom_4;
- }
- }
- $banner_right_bottom_4_url = isset($_POST["banner_right_bottom_4_url"]) ? $_POST["banner_right_bottom_4_url"] : '';
- $home->banner_right_bottom_4_url = $banner_right_bottom_4_url;
- if (isset($_POST["delete_banner_right_bottom_5"]))
- {
- $banner_right_bottom_5 = '';
- $home->banner_right_bottom_5 = $banner_right_bottom_5;
- }
- else
- {
- if(request()->banner_right_bottom_5)
- {
- $file = request()->banner_right_bottom_5;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_bottom_5->move($path, $filename);
- $banner_right_bottom_5 = $filename;
- $home->banner_right_bottom_5 = $banner_right_bottom_5;
- }
- }
- $banner_right_bottom_5_url = isset($_POST["banner_right_bottom_5_url"]) ? $_POST["banner_right_bottom_5_url"] : '';
- $home->banner_right_bottom_5_url = $banner_right_bottom_5_url;
- $banner_right_bottom_google = isset($_POST["banner_right_bottom_google"]) ? $_POST["banner_right_bottom_google"] : '';
- $home->banner_right_bottom_google = $banner_right_bottom_google;
- if (isset($_POST["delete_banner_right_big"]))
- {
- $banner_right_big = '';
- $home->banner_right_big = $banner_right_big;
- }
- else
- {
- if(request()->banner_right_big)
- {
- $file = request()->banner_right_big;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_big->move($path, $filename);
- $banner_right_big = $filename;
- $home->banner_right_big = $banner_right_big;
- }
- }
- $banner_right_big_url = isset($_POST["banner_right_big_url"]) ? $_POST["banner_right_big_url"] : '';
- $home->banner_right_big_url = $banner_right_big_url;
- if (isset($_POST["delete_banner_right_big_2"]))
- {
- $banner_right_big_2 = '';
- $home->banner_right_big_2 = $banner_right_big_2;
- }
- else
- {
- if(request()->banner_right_big_2)
- {
- $file = request()->banner_right_big_2;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_big_2->move($path, $filename);
- $banner_right_big_2 = $filename;
- $home->banner_right_big_2 = $banner_right_big_2;
- }
- }
- $banner_right_big_2_url = isset($_POST["banner_right_big_2_url"]) ? $_POST["banner_right_big_2_url"] : '';
- $home->banner_right_big_2_url = $banner_right_big_2_url;
- if (isset($_POST["delete_banner_right_big_3"]))
- {
- $banner_right_big_3 = '';
- $home->banner_right_big_3 = $banner_right_big_3;
- }
- else
- {
- if(request()->banner_right_big_3)
- {
- $file = request()->banner_right_big_3;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_big_3->move($path, $filename);
- $banner_right_big_3 = $filename;
- $home->banner_right_big_3 = $banner_right_big_3;
- }
- }
- $banner_right_big_3_url = isset($_POST["banner_right_big_3_url"]) ? $_POST["banner_right_big_3_url"] : '';
- $home->banner_right_big_3_url = $banner_right_big_3_url;
- if (isset($_POST["delete_banner_right_big_4"]))
- {
- $banner_right_big_4 = '';
- $home->banner_right_big_4 = $banner_right_big_4;
- }
- else
- {
- if(request()->banner_right_big_4)
- {
- $file = request()->banner_right_big_4;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_big_4->move($path, $filename);
- $banner_right_big_4 = $filename;
- $home->banner_right_big_4 = $banner_right_big_4;
- }
- }
- $banner_right_big_4_url = isset($_POST["banner_right_big_4_url"]) ? $_POST["banner_right_big_4_url"] : '';
- $home->banner_right_big_4_url = $banner_right_big_4_url;
- if (isset($_POST["delete_banner_right_big_5"]))
- {
- $banner_right_big_5 = '';
- $home->banner_right_big_5 = $banner_right_big_5;
- }
- else
- {
- if(request()->banner_right_big_5)
- {
- $file = request()->banner_right_big_5;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->banner_right_big_5->move($path, $filename);
- $banner_right_big_5 = $filename;
- $home->banner_right_big_5 = $banner_right_big_5;
- }
- }
- $banner_right_big_5_url = isset($_POST["banner_right_big_5_url"]) ? $_POST["banner_right_big_5_url"] : '';
- $home->banner_right_big_5_url = $banner_right_big_5_url;
- $banner_right_big_google = isset($_POST["banner_right_big_google"]) ? $_POST["banner_right_big_google"] : '';
- $home->banner_right_big_google = $banner_right_big_google;
- $home->save();
- return Redirect::to('/admin/home_adv');
- })->name('home_adv');
- Route::get('/home_radio', function () {
-
- $home = Home::first();
- if ($home == null)
- {
- $home = new Home();
- $home->save();
- }
- $home->loadData();
- return view('admin.home_radio',compact('home'));
- })->name('home_radio');
- Route::post('/home_radio', function () {
- $home = Home::first();
- if ($home == null)
- $home = new Home();
- if (isset($_POST["delete_radio1"]))
- {
- $radio1_file = '';
- $home->radio1_file = $radio1_file;
- }
- else
- {
- if(request()->radio1_file)
- {
- $file = request()->radio1_file;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->radio1_file->move($path, $filename);
- $radio1_file = $filename;
- $home->radio1_file = $radio1_file;
- }
- }
- $radio1_url = isset($_POST["radio1_url"]) ? $_POST["radio1_url"] : '';
- $home->radio1_url = $radio1_url;
- $home->radio1_title = isset($_POST["radio1_title"]) ? $_POST["radio1_title"] : '';
- if (isset($_POST["delete_radio2"]))
- {
- $radio2_file = '';
- $home->radio2_file = $radio2_file;
- }
- else
- {
- if(request()->radio2_file)
- {
- $file = request()->radio2_file;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->radio2_file->move($path, $filename);
- $radio2_file = $filename;
- $home->radio2_file = $radio2_file;
- }
- }
- $radio2_url = isset($_POST["radio2_url"]) ? $_POST["radio2_url"] : '';
- $home->radio2_url = $radio2_url;
- $home->radio2_title = isset($_POST["radio2_title"]) ? $_POST["radio2_title"] : '';
- if (isset($_POST["delete_radio3"]))
- {
- $radio3_file = '';
- $home->radio3_file = $radio3_file;
- }
- else
- {
- if(request()->radio3_file)
- {
- $file = request()->radio3_file;
- $filename = time() . '_' . $file->getClientOriginalName();
- $path = public_path('files');
- request()->radio3_file->move($path, $filename);
- $radio3_file = $filename;
- $home->radio3_file = $radio3_file;
- }
- }
- $radio3_url = isset($_POST["radio3_url"]) ? $_POST["radio3_url"] : '';
- $home->radio3_url = $radio3_url;
- $home->radio3_title = isset($_POST["radio3_title"]) ? $_POST["radio3_title"] : '';
- $home->save();
- return Redirect::to('/admin/home_radio');
- })->name('home_radio');
- Route::get('/news/duplicate/{id}', function ($id) {
- $news = News::findOrFail($id);
- $new_news = $news->replicate();
- $new_news->title .= ' - COPY';
- $new_news->online = false;
- $new_news->save();
- return Redirect::to('/admin/news/' . $new_news->id . "/edit");
- })->name('news.duplicate');
- Route::get('/news/crop', function () {
- return view('news.crop');
- })->name('news.crop');
- Route::post('/news/crop', function () {
- Log::info('=== CROP POST METHOD START ===');
- Log::info('POST data received:', $_POST);
- Log::info('FILES data:', $_FILES ?? 'No files');
- try {
- // Check if required data exists
- if (!isset($_POST["imagebase64H"]) || !isset($_POST["imagebase64V"])) {
- Log::error('Missing required image data');
- Log::error('imagebase64H exists:', [isset($_POST["imagebase64H"])]);
- Log::error('imagebase64V exists:', [isset($_POST["imagebase64V"])]);
- return redirect()->back()->with('error', 'Missing image data');
- }
- $image = $_POST["imagebase64H"];
- Log::info('Processing horizontal image, length:', [strlen($image)]);
- $imageInfo = explode(";base64,", $image);
- if (count($imageInfo) < 2) {
- Log::error('Invalid image format - missing base64 separator');
- return redirect()->back()->with('error', 'Invalid image format');
- }
- $imgExt = str_replace('data:image/', '', $imageInfo[0]);
- $image = str_replace(' ', '+', $imageInfo[1]);
- $imageName = time().".".$imgExt;
- Log::info('Image details:', [
- 'extension' => $imgExt,
- 'filename' => $imageName,
- 'base64_length' => strlen($image)
- ]);
- // Make sure the directory exists
- $newsDir = public_path()."/files/news";
- if (!File::exists($newsDir)) {
- Log::info('Creating news directory:', [$newsDir]);
- File::makeDirectory($newsDir, 0755, true);
- } else {
- Log::info('News directory exists:', [$newsDir]);
- }
- $path = $newsDir."/".$imageName;
- Log::info('Saving image to:', [$path]);
- $result = file_put_contents($path, base64_decode($image));
- if ($result === false) {
- Log::error('Failed to save horizontal image');
- return redirect()->back()->with('error', 'Failed to save image');
- }
- Log::info('Horizontal image saved successfully, bytes written:', [$result]);
- Log::info('File exists after save:', [file_exists($path)]);
- // Process vertical image
- $imageV = $_POST["imagebase64V"];
- Log::info('Processing vertical image, length:', [strlen($imageV)]);
- $imageInfoV = explode(";base64,", $imageV);
- $imgExtV = str_replace('data:image/', '', $imageInfoV[0]);
- $imageV = str_replace(' ', '+', $imageInfoV[1]);
- $imageNameV = "V_".time().".".$imgExt;
- $pathV = $newsDir."/".$imageNameV;
- Log::info('Vertical image details:', [
- 'extension' => $imgExtV,
- 'filename' => $imageNameV,
- 'path' => $pathV
- ]);
- $resultV = file_put_contents($pathV, base64_decode($imageV));
- if ($resultV === false) {
- Log::error('Failed to save vertical image');
- } else {
- Log::info('Vertical image saved successfully, bytes written:', [$resultV]);
- }
- // Check news_id
- $news_id = isset($_POST["news_id"]) ? $_POST["news_id"] : '';
- Log::info('News ID from form:', [$news_id]);
- Log::info('News ID > 0:', [$news_id > 0]);
- if ($news_id > 0) {
- Log::info('Existing news - updating image');
- try {
- $news = News::findOrFail($news_id);
- Log::info('Found existing news:', [
- 'id' => $news->id,
- 'title' => $news->title,
- 'current_image' => $news->image
- ]);
- $news->image = $imageName;
- $news->save();
- Log::info('Updated existing news with new image:', [$imageName]);
- $redirectUrl = '/admin/news/' . $news_id . "/edit";
- Log::info('Redirecting to edit page:', [$redirectUrl]);
- return redirect()->to($redirectUrl);
- } catch (\Exception $e) {
- Log::error('Error updating existing news:', [
- 'message' => $e->getMessage(),
- 'file' => $e->getFile(),
- 'line' => $e->getLine()
- ]);
- return redirect()->back()->with('error', 'Error updating news: ' . $e->getMessage());
- }
- } else {
- Log::info('New news - redirecting to create with filename');
- $redirectUrl = '/admin/news/create?filename=' . $imageName;
- Log::info('Redirecting to create page:', [$redirectUrl]);
- // Also try using the route method
- try {
- Log::info('Attempting route redirect with filename parameter');
- return redirect()->route('news.create', ['filename' => $imageName]);
- } catch (\Exception $e) {
- Log::error('Route redirect failed, using direct redirect:', [$e->getMessage()]);
- return redirect()->to($redirectUrl);
- }
- }
- } catch (\Exception $e) {
- Log::error('=== CROP ERROR ===');
- Log::error('Error message:', [$e->getMessage()]);
- Log::error('Error file:', [$e->getFile()]);
- Log::error('Error line:', [$e->getLine()]);
- Log::error('Stack trace:', [$e->getTraceAsString()]);
- return redirect()->back()->with('error', 'An error occurred while processing the image: ' . $e->getMessage());
- }
- })->name('news.crop_save');
- Route::get('news/load_json', 'NewsController@load_json')->name('load_json');
- Route::get('news/status/{id}/{status}', function ($id, $status) {
- $n = News::findOrFail($id);
- $n->online = $status == 'online';
- if ($status == 'online')
- {
- if ($n->date <= date("Y-m-d H:i:s"))
- {
- if ($n->section_position != '')
- {
- $s = Section::findOrFail($n->section_id);
- $s[$n->section_position] = $n->id;
- $s->save();
- $n->section_position = '';
- }
- if ($n->region_1_position != '')
- {
- $s = Section::findOrFail($n->region_1_id);
- $s[$n->region_1_position] = $n->id;
- $s->save();
- $n->region_1_position = '';
- }
- if ($n->region_2_position != '')
- {
- $s = Section::findOrFail($n->region_2_id);
- $s[$n->region_2_position] = $n->id;
- $s->save();
- $n->region_2_position = '';
- }
- $n->save();
- if (!$n->published)
- {
- // $n->notify(new FacebookPost());
- $n->notify(new TwitterPost());
- $n->published = true;
- }
- }
- }
- else
- {
- }
- $n->save();
- return Redirect::to('/admin/news');
- });
- Route::resource('news','NewsController');
- Route::resource('breaking_news','BreakingNewsController');
- Route::get('/sections/sort/{ids}', function ($ids) {
- $idx = explode(",", $ids);
- foreach($idx as $x => $id)
- {
- $s = Section::findOrFail($id);
- $s->position = $x;
- $s->save();
- }
- });
- Route::get('/sections/layout/{id}', function ($id) {
- $section = Section::findOrFail($id);
- if (isset($_GET["layout"]))
- {
- $section->big = '';
- $section->small1 = '';
- $section->small2 = '';
- $section->small3 = '';
- $section->small4 = '';
- $section->small5 = '';
- $section->small6 = '';
- $section->save();
- }
- $section->loadLayout();
- $aAssigned = array();
- if ($section->big != '')
- $aAssigned[] = @$section->big->id;
- if ($section->small1 != '')
- $aAssigned[] = @$section->small1->id;
- if ($section->small2 != '')
- $aAssigned[] = @$section->small2->id;
- if ($section->small3 != '')
- $aAssigned[] = @$section->small3->id;
- if ($section->small4 != '')
- $aAssigned[] = @$section->small4->id;
- if ($section->small5 != '')
- $aAssigned[] = @$section->small5->id;
- if ($section->small6 != '')
- $aAssigned[] = @$section->small6->id;
- $news = News::whereNotIn('id', $aAssigned)->where(function ($q) use ($id) {
- $q->where('section_id', '=', $id)->orWhere('region_1_id', '=', $id)->orWhere('region_2_id', '=', $id);
- })->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
- return view('sections.layout',compact('section', 'news'));
- })->name('sections.layout');
- Route::post('/sections/layout/{id}', function ($id) {
- $section = Section::findOrFail($id);
- $layout = isset($_POST["layout"]) ? $_POST["layout"] : '';
- $big = isset($_POST["big"]) ? $_POST["big"] : '';
- $small1 = isset($_POST["small1"]) ? $_POST["small1"] : '';
- $small2 = isset($_POST["small2"]) ? $_POST["small2"] : '';
- $small3 = isset($_POST["small3"]) ? $_POST["small3"] : '';
- $small4 = isset($_POST["small4"]) ? $_POST["small4"] : '';
- $small5 = isset($_POST["small5"]) ? $_POST["small5"] : '';
- $small6 = isset($_POST["small6"]) ? $_POST["small6"] : '';
- $aSel = array();
- if (isset($_POST["big"]))
- $aSel[] = $_POST["big"];
- if (isset($_POST["small1"]))
- $aSel[] = $_POST["small1"];
- if (isset($_POST["small2"]))
- $aSel[] = $_POST["small2"];
- if (isset($_POST["small3"]))
- $aSel[] = $_POST["small3"];
- if (isset($_POST["small4"]))
- $aSel[] = $_POST["small4"];
- if (isset($_POST["small5"]))
- $aSel[] = $_POST["small5"];
- if (isset($_POST["small6"]))
- $aSel[] = $_POST["small6"];
- // Riempio i vuoti
- $news = News::whereNotIn('id', $aSel)->where(function ($q) use ($id) {
- $q->where('section_id', '=', $id)->orWhere('region_1_id', '=', $id)->orWhere('region_2_id', '=', $id);
- })->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
- $idx = 0;
- $section->layout = $layout;
- if ($big == '')
- {
- $section->big = @$news[$idx]->id;
- $idx++;
- }
- else
- $section->big = $big;
- if ($small1 == '')
- {
- $section->small1 = @$news[$idx]->id;
- $idx++;
- }
- else
- $section->small1 = $small1;
- if ($small2 == '')
- {
- $section->small2 = @$news[$idx]->id;
- $idx++;
- }
- else
- $section->small2 = $small2;
- if ($small3 == '')
- {
- $section->small3 = @$news[$idx]->id;
- $idx++;
- }
- else
- $section->small3 = $small3;
- if ($layout == 'layout_3' || $layout == 'layout_4' || $layout == 'layout_5' || $layout == 'layout_7')
- {
- if ($small4 == '')
- {
- $section->small4 = @$news[$idx]->id;
- $idx++;
- }
- else
- $section->small4 = $small4;
- if ($layout == 'layout_4')
- {
- if ($small5 == '')
- {
- $section->small5 = @$news[$idx]->id;
- $idx++;
- }
- else
- $section->small5 = $small5;
- if ($small6 == '')
- {
- $section->small6 = @$news[$idx]->id;
- $idx++;
- }
- else
- $section->small6 = $small6;
- }
- else
- {
- $section->small5 = '';
- $section->small6 = '';
- }
- }
- else
- {
- $section->small4 = '';
- $section->small5 = '';
- $section->small6 = '';
- }
- $section->save();
- // CLEARLAYOUT
- // $section->clearLayout();
- return Redirect::to('/admin/sections');
- });
- Route::get('/events/layout/{id}', function ($id) {
- $event = Event::findOrFail($id);
- $event->loadLayout();
- $aAssigned = array();
- if ($event->big != '')
- $aAssigned[] = @$event->big->id;
- if ($event->small1 != '')
- $aAssigned[] = @$event->small1->id;
- if ($event->small2 != '')
- $aAssigned[] = @$event->small2->id;
- if ($event->small3 != '')
- $aAssigned[] = @$event->small3->id;
- if ($event->small4 != '')
- $aAssigned[] = @$event->small4->id;
- $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();
- return view('events.layout',compact('event', 'news'));
- })->name('events.layout');
- Route::post('/events/layout/{id}', function ($id) {
- $event = Event::findOrFail($id);
- $big = isset($_POST["big"]) ? $_POST["big"] : '';
- $small1 = isset($_POST["small1"]) ? $_POST["small1"] : '';
- $small2 = isset($_POST["small2"]) ? $_POST["small2"] : '';
- $small3 = isset($_POST["small3"]) ? $_POST["small3"] : '';
- $small4 = isset($_POST["small4"]) ? $_POST["small4"] : '';
- $aSel = array();
- if (isset($_POST["big"]))
- $aSel[] = $_POST["big"];
- if (isset($_POST["small1"]))
- $aSel[] = $_POST["small1"];
- if (isset($_POST["small2"]))
- $aSel[] = $_POST["small2"];
- if (isset($_POST["small3"]))
- $aSel[] = $_POST["small3"];
- if (isset($_POST["small4"]))
- $aSel[] = $_POST["small4"];
- $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();
- $idx = 0;
- if ($big == '')
- {
- $event->big = @$news[$idx]->id;
- $idx++;
- }
- else
- $event->big = $big;
- if ($small1 == '')
- {
- $event->small1 = @$news[$idx]->id;
- $idx++;
- }
- else
- $event->small1 = $small1;
- if ($small2 == '')
- {
- $event->small2 = @$news[$idx]->id;
- $idx++;
- }
- else
- $event->small2 = $small2;
- if ($small3 == '')
- {
- $event->small3 = @$news[$idx]->id;
- $idx++;
- }
- else
- $event->small3 = $small3;
- if ($small4 == '')
- {
- $event->small4 = @$news[$idx]->id;
- $idx++;
- }
- else
- $event->small4 = $small4;
- $event->save();
- return Redirect::to('/admin/events');
- });
- Route::get('/sections/to_event/{id}', function ($id) {
- $section = Section::findOrFail($id);
- $event = new Event();
- $event->title = $section->name;
- $event->text_short = '';
- $event->text = '';
- $event->image = '';
- $event->slug = $section->slug;
- $event->online = true;
- $event->save();
- $news = News::where('section_id', '=', $id)->get();
- foreach($news as $n)
- {
- $n->event_id = $event->id;
- $n->section_id = null;
- $n->save();
- }
- $news = News::where('region_1_id', '=', $id)->get();
- foreach($news as $n)
- {
- $n->event_id = $event->id;
- $n->region_1_id = null;
- $n->save();
- }
- $news = News::where('region_2_id', '=', $id)->get();
- foreach($news as $n)
- {
- $n->event_id = $event->id;
- $n->region_2_id = null;
- $n->save();
- }
- $advs = SectionAdv::where('section_id', '=', $id)->get();
- foreach($advs as $adv)
- {
- $adv->section_id = null;
- $adv->save();
- }
- // $section->slug = $section->slug . "_old";
- $section->delete();
- return Redirect::to('/admin/events/' . $event->id . '/edit');
- })->name('sections.to_event');
- Route::resource('sections.advs','SectionAdvController');
- Route::resource('sections','SectionController');
- Route::resource('categories.groups','GroupController');
- Route::resource('categories','CategoryController');
- Route::get('/adv/sort/{ids}', function ($ids) {
- $idx = explode(",", $ids);
- foreach($idx as $x => $id)
- {
- $s = PageAdv::findOrFail($id);
- $s->sort = $x;
- $s->save();
- }
- });
- Route::resource('pages.advs','PageAdvController');
- Route::resource('pages','PageController');
- Route::resource('events.advs','EventAdvController');
- Route::resource('events','EventController');
- Route::get('/calendars/sort/{ids}', function ($ids) {
- $idx = explode(",", $ids);
- foreach($idx as $x => $id)
- {
- $c = Calendar::findOrFail($id);
- $c->position = $x;
- $c->save();
- }
- });
- Route::resource('calendars','CalendarController');
- Route::get('/calendars/archive/{id}', function ($id) {
- $c = Calendar::findOrFail($id);
- $c->archived = true;
- $c->save();
- return Redirect::to('/admin/calendars');
- })->name('calendars.archive');
- Route::get('/calendars/restore/{id}', function ($id) {
- $c = Calendar::findOrFail($id);
- $c->archived = false;
- $c->save();
- return Redirect::to('/admin/calendars');
- })->name('calendars.restore');
- Route::get('/calendars/games/{id}', function ($id) {
- $calendar = CalendarGame::where('calendar_id', '=', $id)->get();;
- $games = array();
- foreach($calendar as $c)
- {
- $games[$c->day . " " . $c->type][] = $c;
- }
- $c = Calendar::findOrFail($id);
- $aRates = $c->getRates();
- $count = 1;
- foreach($aRates as $idx => $r)
- {
- if ($r["penality"] != '')
- {
- $aRates[$idx]["team"] = $r["team"] . ' ' . str_repeat('*', $count);
- $aRates[$idx]["penality"] = str_repeat('*', $count) . $r["penality"];
- $count += 1;
- }
- }
- return view('calendars.games',compact('games', 'aRates'));
- })->name('calendars.games');
- Route::get('/calendars/games/{id}/{day}/{type}', function ($id, $day, $type) {
- $games = CalendarGame::where('calendar_id', '=', $id)->where('day', '=', $day)->where('type', '=', $type)->get();;
- return view('calendars.games_edit',compact('games', 'id', 'day', 'type'));
- })->name('calendars.games_edit');
- Route::post('/calendars/games/{id}/{day}/{type}', function ($id, $day, $type) {
- $games = CalendarGame::where('calendar_id', '=', $id)->where('day', '=', $day)->where('type', '=', $type)->get();;
- foreach($games as $g)
- {
- $date = isset($_POST["date_" . $g->id]) ? $_POST["date_" . $g->id] : '';
- list($day, $month, $year) = explode("/", $date);
- $g->date = $year . "-" . $month . "-" . $day;
- $g->save();
- $home_goals = isset($_POST["home_goals_" . $g->id]) ? $_POST["home_goals_" . $g->id] : '';
- $away_goals = isset($_POST["away_goals_" . $g->id]) ? $_POST["away_goals_" . $g->id] : '';
- $delete = isset($_POST["delete_" . $g->id]) ? true : false;
- if ($delete)
- {
- $g->played = false;
- $g->home_goals = null;
- $g->away_goals = null;
- $g->home_points = 0;
- $g->away_points = 0;
- $g->save();
- }
- else
- {
- if ($home_goals != '' && $away_goals != '')
- {
- $home_points = 0;
- $away_points = 0;
- if ($home_goals > $away_goals)
- {
- $home_points = 3;
- $away_points = 0;
- }
- else if ($home_goals == $away_goals)
- {
- $home_points = 1;
- $away_points = 1;
- }
- else
- {
- $home_points = 0;
- $away_points = 3;
- }
- $g->played = true;
- $g->home_goals = $home_goals;
- $g->away_goals = $away_goals;
- $g->home_points = $home_points;
- $g->away_points = $away_points;
- $g->save();
- }
- }
- }
- return Redirect::to('/admin/calendars/games/' . $id);
- });
- Route::resource('seasons','SeasonController');
- Route::resource('teams','TeamController');
- Route::get('/videos/sort/{ids}', function ($ids) {
- $idx = explode(",", $ids);
- foreach($idx as $x => $id)
- {
- $v = Video::findOrFail($id);
- $v->position = $x;
- $v->save();
- }
- });
- Route::resource('videos','VideoController');
- Route::resource('users','UserController');
- Route::get('/load_categories/{type}', function ($type) {
- $categories = Category::where('type', '=', $type)->get();
- return $categories->toJson();
- });
- Route::get('/load_groups/{category}', function ($category) {
- $groups = Group::where('category_id', '=', $category)->get();
- return $groups->toJson();
- });
- });
- });
- Route::get('/{slug}/elenco', function ($slug) {
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- $sections = Section::orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- $page = Page::where('slug', '=', $slug)->first();
- if ($page != null)
- {
- $section = $page;
- $news = News::where('page_id', '=', $page->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
- return view('section', compact('home', 'news', 'sections', 'pages', 'section', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome'));
- }
- });
- Route::get('/eventi/{slug}', function ($slug) {
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- $sections = Section::orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- $event = Event::where('slug', '=', $slug)->first();
- if ($event != null)
- {
- $event->loadLayout();
- /*$aAssigned = array();
- if ($event->big != '')
- $aAssigned[] = @$event->big->id;
- if ($event->small1 != '')
- $aAssigned[] = @$event->small1->id;
- if ($event->small2 != '')
- $aAssigned[] = @$event->small2->id;
- if ($event->small3 != '')
- $aAssigned[] = @$event->small3->id;
- if ($event->small4 != '')
- $aAssigned[] = @$event->small4->id;*/
- $elements = News::where('event_id', '=', $event->id)->take(5)->get();
- return view('event', compact('home', 'event', 'elements', 'sections', 'pages', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome'));
- }
- });
- Route::get('/eventi/{slug}/elenco', function ($slug) {
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- $sections = Section::orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- $event = Event::where('slug', '=', $slug)->first();
- if ($event != null)
- {
- $section = $event;
- $news = News::where('event_id', '=', $event->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
- return view('section', compact('home', 'news', 'sections', 'pages', 'section', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome'));
- }
- });
- Route::get('/{slug}/{slug2}', function ($slug, $slug2) {
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- $sections = Section::orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- $page = Page::where('slug', '=', $slug)->first();
- if ($page != null)
- {
- $news = News::where('slug', '=', $slug2)->first();
- $clicks = $news->clicks;
- if (!$clicks || $clicks == null)
- $clicks = 0;
- $news->clicks = $clicks + 1;
- $news->save();
- $aImages = array();
- if ($news->image1 != '')
- $aImages[] = $news->image1;
- if ($news->image2 != '')
- $aImages[] = $news->image2;
- if ($news->image3 != '')
- $aImages[] = $news->image3;
- if ($news->image4 != '')
- $aImages[] = $news->image4;
- if ($news->image5 != '')
- $aImages[] = $news->image5;
- $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();
- return view('page', compact('home', 'page', 'elements', 'sections', 'pages', 'news', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aImages', 'regions', 'aHome'));
- }
- });
- Route::get('/calendario/{name}/{id}', function ($name, $id) {
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- $sections = Section::orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $calendar_games = CalendarGame::where('calendar_id', '=', $id)->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- $sel = '';
- $games = array();
- $d = '';
- $t = '';
- foreach($calendar_games as $c)
- {
- $games[$c->day . " " . $c->type][] = $c;
- if ($c->date <= date("Y-m-d 00:00:00"))
- {
- $d = $c->day;
- $t = $c->type;
- }
- }
- $c = Calendar::findOrFail($id);
- $aRates = $c->getRates();
- $count = 1;
- foreach($aRates as $idx => $r)
- {
- if ($r["penality"] != '')
- {
- $aRates[$idx]["team"] = $r["team"] . ' ' . str_repeat('*', $count);
- $aRates[$idx]["penality"] = str_repeat('*', $count) . $r["penality"];
- $count += 1;
- }
- }
- $categoryImage = [];
- if ($c->group)
- {
- $categoryImage = array('url' => $c->group->url, "file" => $c->group->image);
- }
- else
- {
- if ($c->category)
- $categoryImage = array('url' => $c->category->url, "file" => $c->category->image);
- }
- return view('calendar', compact('categoryImage', 'home', 'sections', 'pages', 'c', 'games', 'aRates', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome', 'd', 't', 'sel'));
- });
- Route::get('/{slug}', function ($slug) {
- $home = Home::first();
- if ($home != null)
- $home->loadData();
- $aHome = array();
- if ($home->image != '')
- {
- $aHome[] = ['image' => $home->image, 'url' => $home->url];
- }
- if ($home->image_2 != '')
- {
- $aHome[] = ['image' => $home->image_2, 'url' => $home->url_2];
- }
- if ($home->image_3 != '')
- {
- $aHome[] = ['image' => $home->image_3, 'url' => $home->url_3];
- }
- if ($home->image_4 != '')
- {
- $aHome[] = ['image' => $home->image_4, 'url' => $home->url_4];
- }
- if ($home->image_5 != '')
- {
- $aHome[] = ['image' => $home->image_5, 'url' => $home->url_5];
- }
- if (sizeof($aHome) > 0)
- {
- $rnd = rand (0, sizeof($aHome) - 1);
- $home->image = $aHome[$rnd]["image"];
- $home->url = $aHome[$rnd]["url"];
- }
- $pages = Page::where('online', '=', true)->orderBy('title')->get();
- $events = Event::where('online', '=', true)->orderBy('title')->get();
- $sections = Section::orderBy('position')->get();
- $breaking_news = BreakingNews::where('online', '=', true)->orderBy('date', "DESC")->get();
- //if($breaking_news->count() == 0)
- // $breaking_news = News::where('breaking_news', '=', true)->orderBy('date', "DESC")->get();
- $sections_menu = Section::where('type', '=', 'section')->orderBy('position')->get();
- $regions = Section::where('type', '=', 'region')->orderBy('name')->get();
- $season_id = @Season::where('default', '=', true)->first()->id;
- $cals = Calendar::where('season_id', '=', $season_id)->orderBy('position')->get();
- $calendars = array();
- foreach($cals as $c)
- {
- if ($c->category->grp != '')
- {
- $type = $c->type == 'nation' ? 'Nazionale' : 'Regionale';
- if ($c->group_id > 0)
- $calendars[$type][$c->category->grp][$c->category->name . " - " . $c->group->name] = $c->id;
- else
- $calendars[$type][$c->category->grp][$c->category->name] = $c->id;
- }
- }
- // Controllo se è una sezione o regione, altrimenti news
- $section = Section::where('slug', '=', $slug)->first();
- if ($section != null)
- {
- if ($section->type == 'section')
- $news = News::where('section_id', '=', $section->id)->where('online', '=', true)->where('date', '<=', date("Y-m-d H:i:s"))->orderBy('date', 'DESC')->get();
- else
- {
- $news = News::where('online', '=', true)->where(function ($q) use ($section) {
- $q->where('region_1_id', '=', $section->id)->orWhere('region_2_id', '=', $section->id);
- })->orderBy('date', 'DESC')->get();
- }
- return view('section', compact('home', 'news', 'sections', 'pages', 'section', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome'));
- }
- $news = News::where('slug', '=', $slug)->first();
- if ($news != null)
- {
- // Controllo se è online altrimenti vado alla home
- if (!$news->online || $news->date > date("Y-m-d H:i:s"))
- return Redirect::to('/');
- $clicks = $news->clicks;
- if (!$clicks || $clicks == null)
- $clicks = 0;
- $news->clicks = $clicks + 1;
- $news->save();
- $aImages = array();
- if ($news->image1 != '')
- $aImages[] = $news->image1;
- if ($news->image2 != '')
- $aImages[] = $news->image2;
- if ($news->image3 != '')
- $aImages[] = $news->image3;
- if ($news->image4 != '')
- $aImages[] = $news->image4;
- if ($news->image5 != '')
- $aImages[] = $news->image5;
- $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();
- // Se la news è associata ad una pagina, carico gli advs di quella pagina
- $advs = array();
- if ($news->page_id > 0)
- {
- $page = $news->page;
- $advs = $news->page->getAdvs();
- $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();
- return view('page', compact('home', 'page', 'elements', 'sections', 'pages', 'news', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aImages', 'aHome', 'advs'));
- }
- else
- return view('news', compact('home', 'news', 'elements', 'sections', 'pages', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aImages', 'aHome', 'advs'));
- }
- $page = Page::where('slug', '=', $slug)->first();
- if ($page != null)
- {
- $news = News::where('page_id', '=', $page->id)->where('online', '=', true)->orderBy('date', 'DESC')->first();
- $aImages = array();
- if ($news)
- {
- if ($news->image1 != '')
- $aImages[] = $news->image1;
- if ($news->image2 != '')
- $aImages[] = $news->image2;
- if ($news->image3 != '')
- $aImages[] = $news->image3;
- if ($news->image4 != '')
- $aImages[] = $news->image4;
- if ($news->image5 != '')
- $aImages[] = $news->image5;
- }
- $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();
- // $news = $elements->first();
- $advs = $page->getAdvs();
- return view('page', compact('home', 'page', 'elements', 'sections', 'pages', 'news', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aImages', 'aHome', 'advs'));
- }
- /*$event = Event::where('slug', '=', $slug)->first();
- if ($event != null)
- {
- $event->loadLayout();
- $aAssigned = array();
- if ($event->big != '')
- $aAssigned[] = @$event->big->id;
- if ($event->small1 != '')
- $aAssigned[] = @$event->small1->id;
- if ($event->small2 != '')
- $aAssigned[] = @$event->small2->id;
- if ($event->small3 != '')
- $aAssigned[] = @$event->small3->id;
- if ($event->small4 != '')
- $aAssigned[] = @$event->small4->id;
- $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();
- return view('event', compact('home', 'event', 'elements', 'sections', 'pages', 'sections_menu', 'regions', 'events', 'breaking_news', 'sections_menu', 'calendars', 'aHome'));
- }*/
- });
|