Old UniVate Website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PagesController.php 176KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Foundation\Bus\DispatchesJobs;
  4. use Illuminate\Routing\Controller as BaseController;
  5. use Illuminate\Foundation\Validation\ValidatesRequests;
  6. use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Support\Facades\Input;
  9. use Illuminate\Support\Facades\Hash;
  10. use Illuminate\Support\Facades\Redirect;
  11. use Illuminate\Support\Facades\DB;
  12. use Illuminate\Support\Facades\Validator;
  13. use App\User;
  14. use App\Imports\TimesharesImport;
  15. use Maatwebsite\Excel\Facades\Excel;
  16. use App\Http\Controllers\Controller;
  17. use App\Timeshare;
  18. use App\Commercial;
  19. use App\Transfer;
  20. use App\Seller;
  21. use App\Residential;
  22. use App\Contact;
  23. use App\ContactResort;
  24. use App\Interest;
  25. use App\Post;
  26. use App\Agency;
  27. use App\Support;
  28. use Auth;
  29. use View;
  30. use Mail;
  31. use App\TimeshareLog;
  32. use App\TimeshareBulk;
  33. use App\Resort;
  34. class PagesController extends Controller {
  35. protected static $rules = [
  36. 'username' => 'required',
  37. 'password' => 'required'
  38. ];
  39. public function serveHome()
  40. {
  41. DB::table('uniresorts')->truncate();
  42. $arrContextOptions=array(
  43. "ssl"=>array(
  44. "verify_peer"=>false,
  45. "verify_peer_name"=>false,
  46. ),
  47. );
  48. $data = file_get_contents("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/", false, stream_context_create($arrContextOptions));
  49. $details = json_decode($data, true);
  50. foreach($details as $resort)
  51. {
  52. DB::table('uniresorts')->insert(['resort' => $resort['resortName']]);
  53. }
  54. return View::make('home');
  55. }
  56. public function serveAbout()
  57. {
  58. return View::make('about');
  59. }
  60. public function serveContact()
  61. {
  62. return View::make('contact-us');
  63. }
  64. public function serveFAQs()
  65. {
  66. return View::make('faqs');
  67. }
  68. public function servePrivacyPolicy()
  69. {
  70. return View::make('privacy-policy');
  71. }
  72. public function serveTimeshare()
  73. {
  74. return View::make('timeshare');
  75. }
  76. public function serveAdmin()
  77. {
  78. $timeshares = DB::table('timeshares')
  79. ->orderBy('published','asc')
  80. ->paginate(10);
  81. $resorts = DB::table('resorts')
  82. ->orderBy('resort','asc')
  83. ->get();
  84. if (Auth::check() && Auth::user()->role == "admin") {
  85. return View::make('admin.admin')
  86. ->with('resorts',$resorts)
  87. ->with('timeshares',$timeshares);
  88. }else{
  89. return Redirect::to('/');
  90. }
  91. }
  92. public function serveCommercialAdmin()
  93. {
  94. $commercials = DB::table('commercials')
  95. ->orderBy('name','asc')
  96. ->paginate(15);
  97. if (Auth::check() && Auth::user()->role == "admin") {
  98. return View::make('admin.commercial-admin')
  99. ->with('commercials',$commercials);
  100. }else{
  101. return Redirect::to('/');
  102. }
  103. }
  104. public function serveResidentialAdmin()
  105. {
  106. $residentials = DB::table('residentials')
  107. ->orderBy('name','asc')
  108. ->paginate(15);
  109. if (Auth::check() && Auth::user()->role == "admin") {
  110. return View::make('admin.residential-admin')
  111. ->with('residentials',$residentials);
  112. }else{
  113. return Redirect::to('/');
  114. }
  115. }
  116. public function serveToSell()
  117. {
  118. $resorts = DB::table('resorts')
  119. ->orderBy('resort','asc')
  120. ->get();
  121. return View::make('to-sell')
  122. ->with('resorts',$resorts);
  123. }
  124. public function handleToSell()
  125. {
  126. $validator = Validator::make(Input::all(),
  127. [
  128. 'resort' => 'required',
  129. 'week' => 'required',
  130. 'module' => 'required',
  131. 'bedrooms' => 'required',
  132. 'season' => 'required',
  133. 'sleeps' => 'required',
  134. 'unit' => 'required',
  135. 'region' => 'required'
  136. ]);
  137. if(!Input::has('mandate') && (Auth::check() && Auth::user()->agency!=NULL))
  138. {
  139. return Redirect::back()->with('view-error', 'A copy of a mandate is required to submit your timeshare.')->withInput()->withErrors($validator);
  140. }
  141. if(!Auth::check())
  142. {
  143. return Redirect::back()->with('view-error', 'You need to be logged in to submit a timeshare, please login or register if you do not have an account')->withInput()->withErrors($validator);
  144. }
  145. if($validator->fails())
  146. {
  147. return Redirect::back()->with('view-error', 'Some information is missing, please review and try again.')->withInput()->withErrors($validator);
  148. }
  149. //$id = Auth::user()->id;
  150. $seller = new Seller;
  151. $seller->paid = Input::get('paid');
  152. $seller->rental = Input::get('rental');
  153. $seller->spaceBanked = Input::get('spaceBanked');
  154. $seller->date = Input::get('date');
  155. $seller->purchasePrice = Input::get('purchasePrice');
  156. $seller->sellingPrice = Input::get('sellingPrice');
  157. $seller->estateAgency = Input::get('estateAgency');
  158. $seller->commission = Input::get('commission');
  159. $seller->agentName = Input::get('agentName');
  160. $seller->agencyName = Input::get('agencyName');
  161. $seller->referedBy = Input::get('referedBy');
  162. $seller->occupationDate1 = Input::get('occupationDate1');
  163. $seller->occupationDate2 = Input::get('occupationDate2');
  164. $seller->save();
  165. $timeshare = new Timeshare;
  166. $timeshare->resort = Input::get('resort');
  167. $timeshare->names = Auth::user()->name;
  168. $timeshare->email = Auth::user()->email;
  169. $timeshare->phone = Auth::user()->phone;
  170. $timeshare->mobile = Auth::user()->mobile;
  171. $timeshare->week = Input::get('week');
  172. $timeshare->season = Input::get('season');
  173. $timeshare->module = Input::get('module');
  174. $timeshare->region = Input::get('region');
  175. $timeshare->price = Input::get('sellingPrice');
  176. $timeshare->bedrooms = Input::get('bedrooms');
  177. $timeshare->other = Input::get('other');
  178. $timeshare->sleeps = Input::get('sleeps');
  179. $timeshare->unit = Input::get('unit');
  180. $timeshare->owner = Input::get('owner');
  181. $timeshare->listingFee = 'Pending';
  182. $timeshare->paid = Input::get('paid');
  183. $timeshare->levy = Input::get('levy');
  184. $timeshare->fromDate = Input::get('occupationDate1');
  185. $timeshare->toDate = Input::get('occupationDate2');
  186. $timeshare->spacebankedyear = Input::get('spacebankedyear');
  187. $timeshare->spacebankOwner = Input::get('spacebankOwner');
  188. $timeshare->agency = Auth::user()->agency;
  189. $timeshare->agent = Auth::user()->name;
  190. $request = request();
  191. if(Input::hasFile('mandate')){
  192. $mandate = $request->file('mandate');
  193. $profileImageSaveAsName = time() . Auth::id() . "-mandate." .
  194. $mandate->getClientOriginalExtension();
  195. $upload_path = public_path() .'mandates/';
  196. $profile_image_url = '/'.$upload_path . $profileImageSaveAsName;
  197. $success = $mandate->move($upload_path, $profileImageSaveAsName);
  198. $timeshare->mandate = $profile_image_url;
  199. }
  200. $timeshare->save();
  201. $data = ['timeshare' => $timeshare, 'seller' => $seller];
  202. if(Input::hasFile('mandate')){
  203. Mail::send('emails.timeshare', $data, function($message) use ($timeshare)
  204. {
  205. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New timeshare submission');
  206. $message->from('info@univateproperties.co.za');
  207. $message->attach($timeshare->mandate);
  208. });
  209. }
  210. else{
  211. Mail::send('emails.timeshare', $data, function($message) use ($timeshare)
  212. {
  213. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New timeshare submission');
  214. $message->from('info@univateproperties.co.za');
  215. });
  216. }
  217. return Redirect::to('/pay-listing-fee/'.$timeshare->id)->with('view-success',' Your Timeshare has been successfully submitted');
  218. }
  219. public function servePayListingFee($id)
  220. {
  221. $timeshare = DB::table('timeshares')
  222. ->where('id','=',$id)
  223. ->first();
  224. return View::make('pay-listing-fee')
  225. ->with('timeshare',$timeshare);
  226. }
  227. public function serveToBuy()
  228. {
  229. $timeshares = DB::table('timeshares')
  230. ->get();
  231. $resorts = DB::table('resorts')
  232. ->orderBy('resort','asc')
  233. ->get();
  234. $gauteng = NULL;
  235. $limpopo = NULL;
  236. $mpumalanga = NULL;
  237. $kwazulunatal = NULL;
  238. $freestate = NULL;
  239. $northwest = NULL;
  240. $northerncape = NULL;
  241. $westerncape = NULL;
  242. $easterncape = NULL;
  243. foreach($timeshares as $timeshare)
  244. {
  245. if($timeshare->region=='gauteng' and $timeshare->published=1)
  246. {
  247. $gauteng = DB::table('resorts')
  248. ->where('region','=','gauteng')
  249. ->groupBy('resort')
  250. ->get();
  251. }
  252. }
  253. foreach($timeshares as $timeshare)
  254. {
  255. if($timeshare->region=='limpopo' && $timeshare->published=1)
  256. {
  257. $limpopo = DB::table('resorts')
  258. ->where('region','=','limpopo')
  259. ->groupBy('resort')
  260. ->get();
  261. }
  262. }
  263. foreach($timeshares as $timeshare)
  264. {
  265. if($timeshare->region=='mpumalanga' && $timeshare->published=1)
  266. {
  267. $mpumalanga = DB::table('resorts')
  268. ->where('region','=','mpumalanga')
  269. ->groupBy('resort')
  270. ->get();
  271. }
  272. }
  273. foreach($timeshares as $timeshare)
  274. {
  275. if($timeshare->region=='Kwazulu Natal' && $timeshare->published=1)
  276. {
  277. $kwazulunatal = DB::table('resorts')
  278. ->where('region','=','Kwazulu Natal')
  279. ->groupBy('resort')
  280. ->get();
  281. }
  282. }
  283. foreach($timeshares as $timeshare)
  284. {
  285. if($timeshare->region=='free state' && $timeshare->published=1)
  286. {
  287. $freestate = DB::table('resorts')
  288. ->where('region','=','free state')
  289. ->groupBy('resort')
  290. ->get();
  291. }
  292. }
  293. foreach($timeshares as $timeshare)
  294. {
  295. if($timeshare->region=='north west' && $timeshare->published=1)
  296. {
  297. $northwest = DB::table('resorts')
  298. ->where('region','=','north west')
  299. ->groupBy('resort')
  300. ->get();
  301. }
  302. }
  303. foreach($timeshares as $timeshare)
  304. {
  305. if($timeshare->region=='northern cape' && $timeshare->published=1)
  306. {
  307. $northerncape = DB::table('resorts')
  308. ->where('region','=','northern cape')
  309. ->groupBy('resort')
  310. ->get();
  311. }
  312. }
  313. foreach($timeshares as $timeshare)
  314. {
  315. if($timeshare->region=='western cape' && $timeshare->published=1)
  316. {
  317. $westerncape = DB::table('resorts')
  318. ->where('region','=','western cape')
  319. ->groupBy('resort')
  320. ->get();
  321. }
  322. }
  323. foreach($timeshares as $timeshare)
  324. {
  325. if($timeshare->region=='eastern cape' && $timeshare->published=1)
  326. {
  327. $easterncape = DB::table('resorts')
  328. ->where('region','=','eastern cape')
  329. ->groupBy('resort')
  330. ->get();
  331. }
  332. }
  333. return View::make('to-buy')
  334. ->with('resorts',$resorts)
  335. ->with('easterncape',$easterncape)
  336. ->with('limpopo',$limpopo)
  337. ->with('northwest',$northwest)
  338. ->with('northerncape',$northerncape)
  339. ->with('westerncape',$westerncape)
  340. ->with('kwazulunatal',$kwazulunatal)
  341. ->with('mpumalanga',$mpumalanga)
  342. ->with('freestate',$freestate)
  343. ->with('gauteng',$gauteng);
  344. }
  345. public function serveResortUpload()
  346. {
  347. return View::make('resort-upload');
  348. }
  349. public function handleResortUpload()
  350. {
  351. $validator = Validator::make(Input::all(),
  352. [
  353. 'resort' => 'required',
  354. 'region' => 'required',
  355. 'information' => 'required',
  356. 'image1' => 'required',
  357. 'image2' => 'required',
  358. 'logo' => 'required'
  359. ]);
  360. if($validator->fails())
  361. {
  362. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  363. }
  364. $resort = new Resort;
  365. $resort->resort = Input::get('resort');
  366. $resort->information = Input::get('information');
  367. $resort->region = Input::get('region');
  368. if(Input::has('advisor'))
  369. {
  370. $resort->advisor = Input::get('advisor');
  371. }
  372. if(Input::has('awards'))
  373. {
  374. $resort->awards = implode(',',Input::get('awards'));
  375. }
  376. $file = Input::file('image1');
  377. $file->move('images/resorts/', $file->getClientOriginalName());
  378. $resort->image1 = '/images/resorts/'.$file->getClientOriginalName();
  379. $file = Input::file('image2');
  380. $file->move('images/resorts/', $file->getClientOriginalName());
  381. $resort->image2 = '/images/resorts/'.$file->getClientOriginalName();
  382. $file = Input::file('logo');
  383. $file->move('images/logos/', $file->getClientOriginalName());
  384. $resort->logo = '/images/logos/'.$file->getClientOriginalName();
  385. $resort->save();
  386. return Redirect::back()->with('view-success',' Resort has been successfully uploaded');
  387. }
  388. public function serveLogin()
  389. {
  390. return View::make('login');
  391. }
  392. public function handleLogin()
  393. {
  394. $validator = Validator::make(Input::all(), static::$rules);
  395. if (Auth::attempt(['username' => Input::get('username'), 'password' => Input::get('password')]))
  396. {
  397. //$role = Auth::user()->role;
  398. return Redirect::back();
  399. }
  400. elseif((Input::get('password'))==NULL and Input::get('username'))
  401. {
  402. return Redirect::back()->withInput()->withErrors($validator)->with('view-error', ' A password is required to login.');
  403. }
  404. elseif((Input::get('username'))==NULL and Input::get('password'))
  405. {
  406. return Redirect::back()->withInput()->withErrors($validator)->with('view-error', 'An username is required to login.');
  407. }
  408. elseif($validator->fails())
  409. {
  410. return Redirect::back()->withInput()->withErrors($validator)->with('view-error', '<strong>Oops!</strong> No credentials entered.');
  411. }
  412. else
  413. {
  414. return Redirect::back()->withInput()->with('view-error', 'The username and password you entered do not correspond, please try again.');
  415. }
  416. }
  417. public function handleLogout()
  418. {
  419. Auth::logout();
  420. Session::flush();
  421. return Redirect::to('/');
  422. }
  423. public function publishTimeshareAgent($id)
  424. {
  425. DB::table('users')
  426. ->where('id','=', $id)
  427. ->update(array(
  428. 'timeshare_publish' => 1
  429. ) // LUC
  430. );
  431. return Redirect::back()->withInput()->with('view-success', 'This agent has been successfully verified.');
  432. }
  433. public function publishTimeshare($id)
  434. {
  435. DB::table('timeshares')
  436. ->where('id','=', $id)
  437. ->update(array(
  438. 'published' => 1
  439. )
  440. );
  441. return Redirect::back()->withInput()->with('view-success', 'Timeshare successfully published.');
  442. }
  443. public function publishCommercial($id)
  444. {
  445. DB::table('commercials')
  446. ->where('id','=', $id)
  447. ->update(array(
  448. 'published' => 1
  449. )
  450. );
  451. return Redirect::back()->withInput()->with('view-success', 'Commercial property is successfully published.');
  452. }
  453. public function publishResidential($id)
  454. {
  455. DB::table('residentials')
  456. ->where('id','=', $id)
  457. ->update(array(
  458. 'published' => 1
  459. )
  460. );
  461. return Redirect::back()->withInput()->with('view-success', 'Residential property successfully published.');
  462. }
  463. public function serveInterested($id)
  464. {
  465. $timeshare = DB::table('timeshares')
  466. ->where('id','=',$id)
  467. ->first();
  468. return View::make('interested')
  469. ->with('timeshare',$timeshare);
  470. }
  471. public function handleInterested($id)
  472. {
  473. $timeshare = DB::table('timeshares')
  474. ->where('id','=',$id)
  475. ->first();
  476. $validator = Validator::make(Input::all(),
  477. [
  478. 'name' => 'required',
  479. 'email' => 'required'
  480. ]);
  481. if($validator->fails())
  482. {
  483. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  484. }
  485. $interested = new Interest;
  486. $interested->name = Input::get('name');
  487. $interested->email = Input::get('email');
  488. $interested->phone = Input::get('phone');
  489. $interested->mobile = Input::get('mobile');
  490. $interested->save();
  491. $data = ['interested' => $interested, 'timeshare' => $timeshare];
  492. Mail::send('emails.interested', $data, function($message)
  493. {
  494. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this resort');
  495. $message->from('info@univateproperties.co.za');
  496. });
  497. return Redirect::back()->with('view-success','Enquiry submitted.');
  498. }
  499. public function serveCommercialPropertyInterested($id)
  500. {
  501. $property = DB::table('commercials')
  502. ->where('id','=',$id)
  503. ->first();
  504. return View::make('interested-in-commercial-property')
  505. ->with('property',$property);
  506. }
  507. public function handleCommercialPropertyInterested($id)
  508. {
  509. $property = DB::table('commercials')
  510. ->where('id','=',$id)
  511. ->first();
  512. $validator = Validator::make(Input::all(),
  513. [
  514. 'name' => 'required',
  515. 'email' => 'required'
  516. ]);
  517. if($validator->fails())
  518. {
  519. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  520. }
  521. $interested = new Interest;
  522. $interested->name = Input::get('name');
  523. $interested->email = Input::get('email');
  524. $interested->phone = Input::get('phone');
  525. $interested->mobile = Input::get('mobile');
  526. $interested->save();
  527. $data = ['interested' => $interested, 'property' => $property];
  528. Mail::send('emails.interestedCommercialProperty', $data, function($message)
  529. {
  530. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this property');
  531. $message->from('info@univateproperties.co.za');
  532. });
  533. return Redirect::back()->with('view-success',' Enquiry submitted.');
  534. }
  535. public function serveResidentialPropertyInterested($id)
  536. {
  537. $property = DB::table('residentials')
  538. ->where('id','=',$id)
  539. ->first();
  540. return View::make('interest-in-residential-property')
  541. ->with('property',$property);
  542. }
  543. public function handleResidentialPropertyInterested($id)
  544. {
  545. $property = DB::table('residentials')
  546. ->where('id','=',$id)
  547. ->first();
  548. $validator = Validator::make(Input::all(),
  549. [
  550. 'name' => 'required',
  551. 'email' => 'required'
  552. ]);
  553. if($validator->fails())
  554. {
  555. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  556. }
  557. $interested = new Interest;
  558. $interested->name = Input::get('name');
  559. $interested->email = Input::get('email');
  560. $interested->phone = Input::get('phone');
  561. $interested->mobile = Input::get('mobile');
  562. $interested->save();
  563. $data = ['interested' => $interested, 'property' => $property];
  564. Mail::send('emails.interestedResidentialProperty', $data, function($message)
  565. {
  566. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this property');
  567. $message->from('info@univateproperties.co.za');
  568. });
  569. return Redirect::back()->with('view-success',' Enquiry submitted.');
  570. }
  571. public function serveResorts($province)
  572. {
  573. $resorts = DB::table('timeshares')
  574. ->where('region','=',$province)
  575. ->groupBy('resort')
  576. ->get();
  577. return View::make('resorts')
  578. ->with('province',$province)
  579. ->with('resorts',$resorts);
  580. }
  581. public function serveResort($slug)
  582. {
  583. $resort = DB::table('resorts')
  584. ->where('slug','=',$slug)
  585. ->orWhere('resort','=',$slug)
  586. ->first();
  587. $timeshares = DB::table('timeshares')
  588. ->where('resort','=',$resort->resort)
  589. ->where('published','=',1)
  590. ->paginate(5);
  591. $awards = explode(',',$resort->awards);
  592. $facilities = explode(',',$resort->facilities);
  593. //$wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/LE";
  594. //$details = json_decode(file_get_contents($wsdl), true);
  595. return View::make('resort')
  596. ->with('facilities',$facilities)
  597. ->with('awards',$awards)
  598. ->with('timeshares',$timeshares)
  599. ->with('resort',$resort);
  600. }
  601. public function serveEditTimeshare($id)
  602. {
  603. $timeshare = DB::table('timeshares')
  604. ->where('id','=',$id)
  605. ->first();
  606. return View::make('edit-timeshare')
  607. ->with('timeshare',$timeshare);
  608. }
  609. public function handleEditTimeshare($id)
  610. {
  611. $validator = Validator::make(Input::all(),
  612. [
  613. 'resort' => 'required',
  614. 'module' => 'required',
  615. 'week' => 'required',
  616. 'bedrooms' => 'required'
  617. ]);
  618. if($validator->fails())
  619. {
  620. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  621. }
  622. $timeshare = DB::table('timeshares')
  623. ->where('id','=',$id)
  624. ->first();
  625. if(Input::get('resort')!=$timeshare->resort)
  626. {
  627. $log = new TimeshareLog;
  628. $log->user_id = Auth::user()->id;
  629. $log->timeshare_id = $timeshare->id;
  630. $log->name = Auth::user()->name;
  631. $log->resort = $timeshare->resort;
  632. $log->module = $timeshare->module;
  633. $log->unit = $timeshare->unit;
  634. $log->change = 'Resort name changed from '.$timeshare->resort.' to '.Input::get('resort');
  635. $log->save();
  636. DB::table('timeshares')
  637. ->where('id','=', $id)
  638. ->update(array(
  639. 'resort' => Input::get('resort')
  640. )
  641. );
  642. }
  643. if(Input::get('module')!=$timeshare->module)
  644. {
  645. $log = new TimeshareLog;
  646. $log->user_id = Auth::user()->id;
  647. $log->timeshare_id = $timeshare->id;
  648. $log->name = Auth::user()->name;
  649. $log->resort = $timeshare->resort;
  650. $log->module = $timeshare->module;
  651. $log->unit = $timeshare->unit;
  652. $log->change = 'Module changed from '.$timeshare->module.' to '.Input::get('module');
  653. $log->save();
  654. DB::table('timeshares')
  655. ->where('id','=', $id)
  656. ->update(array(
  657. 'module' => Input::get('module')
  658. )
  659. );
  660. }
  661. if(Input::get('week')!=$timeshare->week)
  662. {
  663. $log = new TimeshareLog;
  664. $log->user_id = Auth::user()->id;
  665. $log->timeshare_id = $timeshare->id;
  666. $log->name = Auth::user()->name;
  667. $log->resort = $timeshare->resort;
  668. $log->module = $timeshare->module;
  669. $log->unit = $timeshare->unit;
  670. $log->change = 'Week changed from '.$timeshare->week.' to '.Input::get('week');
  671. $log->save();
  672. DB::table('timeshares')
  673. ->where('id','=', $id)
  674. ->update(array(
  675. 'week' => Input::get('week')
  676. )
  677. );
  678. }
  679. if(Input::get('levy')!=$timeshare->levy)
  680. {
  681. $log = new TimeshareLog;
  682. $log->user_id = Auth::user()->id;
  683. $log->timeshare_id = $timeshare->id;
  684. $log->name = Auth::user()->name;
  685. $log->resort = $timeshare->resort;
  686. $log->module = $timeshare->module;
  687. $log->unit = $timeshare->unit;
  688. $log->change = 'Levy changed from '.$timeshare->levy.' to '.Input::get('levy');
  689. $log->save();
  690. DB::table('timeshares')
  691. ->where('id','=', $id)
  692. ->update(array(
  693. 'levy' => Input::get('levy')
  694. )
  695. );
  696. }
  697. if(Input::get('fromDate')!=null)
  698. {
  699. $log = new TimeshareLog;
  700. $log->user_id = Auth::user()->id;
  701. $log->timeshare_id = $timeshare->id;
  702. $log->name = Auth::user()->name;
  703. $log->resort = $timeshare->resort;
  704. $log->module = $timeshare->module;
  705. $log->unit = $timeshare->unit;
  706. $log->change = 'Departure date changed from '.$timeshare->fromDate.' to '.Input::get('fromDate');
  707. $log->save();
  708. DB::table('timeshares')
  709. ->where('id','=', $id)
  710. ->update(array(
  711. 'fromDate' => Input::get('fromDate')
  712. )
  713. );
  714. }
  715. if(Input::get('toDate')!=null)
  716. {
  717. $log = new TimeshareLog;
  718. $log->user_id = Auth::user()->id;
  719. $log->timeshare_id = $timeshare->id;
  720. $log->name = Auth::user()->name;
  721. $log->resort = $timeshare->resort;
  722. $log->module = $timeshare->module;
  723. $log->unit = $timeshare->unit;
  724. $log->change = 'Arrival date changed from '.$timeshare->toDate.' to '.Input::get('toDate');
  725. $log->save();
  726. DB::table('timeshares')
  727. ->where('id','=', $id)
  728. ->update(array(
  729. 'toDate' => Input::get('toDate')
  730. )
  731. );
  732. }
  733. if(Input::get('season')!=$timeshare->season)
  734. {
  735. $log = new TimeshareLog;
  736. $log->user_id = Auth::user()->id;
  737. $log->timeshare_id = $timeshare->id;
  738. $log->name = Auth::user()->name;
  739. $log->resort = $timeshare->resort;
  740. $log->module = $timeshare->module;
  741. $log->unit = $timeshare->unit;
  742. $log->change = 'The season was changed from '.$timeshare->season.' to '.Input::get('season');
  743. $log->save();
  744. DB::table('timeshares')
  745. ->where('id','=', $id)
  746. ->update(array(
  747. 'season' => Input::get('season')
  748. )
  749. );
  750. }
  751. if(Input::get('region')!=$timeshare->region)
  752. {
  753. $log = new TimeshareLog;
  754. $log->user_id = Auth::user()->id;
  755. $log->timeshare_id = $timeshare->id;
  756. $log->name = Auth::user()->name;
  757. $log->resort = $timeshare->resort;
  758. $log->module = $timeshare->module;
  759. $log->unit = $timeshare->unit;
  760. $log->change = 'The region was changed from '.$timeshare->region.' to '.Input::get('region');
  761. $log->save();
  762. DB::table('timeshares')
  763. ->where('id','=', $id)
  764. ->update(array(
  765. 'region' => Input::get('region')
  766. )
  767. );
  768. }
  769. if(Input::get('setPrice')!=$timeshare->setPrice)
  770. {
  771. $log = new TimeshareLog;
  772. $log->user_id = Auth::user()->id;
  773. $log->timeshare_id = $timeshare->id;
  774. $log->name = Auth::user()->name;
  775. $log->resort = $timeshare->resort;
  776. $log->module = $timeshare->module;
  777. $log->unit = $timeshare->unit;
  778. $log->change = 'The set price was changed from '.$timeshare->setPrice.' to '.Input::get('setPrice');
  779. $log->save();
  780. DB::table('timeshares')
  781. ->where('id','=', $id)
  782. ->update(array(
  783. 'setPrice' => Input::get('setPrice')
  784. )
  785. );
  786. }
  787. if(Input::get('price')!=$timeshare->price)
  788. {
  789. $log = new TimeshareLog;
  790. $log->user_id = Auth::user()->id;
  791. $log->timeshare_id = $timeshare->id;
  792. $log->name = Auth::user()->name;
  793. $log->resort = $timeshare->resort;
  794. $log->module = $timeshare->module;
  795. $log->unit = $timeshare->unit;
  796. $log->change = 'The price was changed from '.$timeshare->price.' to '.Input::get('price');
  797. $log->save();
  798. DB::table('timeshares')
  799. ->where('id','=', $id)
  800. ->update(array(
  801. 'price' => Input::get('price')
  802. )
  803. );
  804. }
  805. if(Input::get('bedrooms')!=$timeshare->bedrooms)
  806. {
  807. $log = new TimeshareLog;
  808. $log->user_id = Auth::user()->id;
  809. $log->timeshare_id = $timeshare->id;
  810. $log->name = Auth::user()->name;
  811. $log->resort = $timeshare->resort;
  812. $log->module = $timeshare->module;
  813. $log->unit = $timeshare->unit;
  814. $log->change = 'The number of bedrooms was changed from '.$timeshare->bedrooms.' to '.Input::get('bedrooms');
  815. $log->save();
  816. DB::table('timeshares')
  817. ->where('id','=', $id)
  818. ->update(array(
  819. 'bedrooms' => Input::get('bedrooms')
  820. )
  821. );
  822. }
  823. if(Input::get('sleeps')!=$timeshare->sleeps)
  824. {
  825. $log = new TimeshareLog;
  826. $log->user_id = Auth::user()->id;
  827. $log->timeshare_id = $timeshare->id;
  828. $log->name = Auth::user()->name;
  829. $log->resort = $timeshare->resort;
  830. $log->module = $timeshare->module;
  831. $log->unit = $timeshare->unit;
  832. $log->change = 'The maximum occupation per unit was changed from '.$timeshare->sleeps.' to '.Input::get('sleeps');
  833. $log->save();
  834. DB::table('timeshares')
  835. ->where('id','=', $id)
  836. ->update(array(
  837. 'sleeps' => Input::get('sleeps')
  838. )
  839. );
  840. }
  841. if(Input::get('unit')!=$timeshare->unit)
  842. {
  843. $log = new TimeshareLog;
  844. $log->user_id = Auth::user()->id;
  845. $log->timeshare_id = $timeshare->id;
  846. $log->name = Auth::user()->name;
  847. $log->resort = $timeshare->resort;
  848. $log->module = $timeshare->module;
  849. $log->unit = $timeshare->unit;
  850. $log->change = 'The unit number was changed from '.$timeshare->unit.' to '.Input::get('unit');
  851. $log->save();
  852. DB::table('timeshares')
  853. ->where('id','=', $id)
  854. ->update(array(
  855. 'unit' => Input::get('unit')
  856. )
  857. );
  858. }
  859. if(Input::get('owner')!=$timeshare->owner)
  860. {
  861. $log = new TimeshareLog;
  862. $log->user_id = Auth::user()->id;
  863. $log->timeshare_id = $timeshare->id;
  864. $log->name = Auth::user()->name;
  865. $log->resort = $timeshare->resort;
  866. $log->module = $timeshare->module;
  867. $log->unit = $timeshare->unit;
  868. $log->change = 'The owner was changed from '.$timeshare->owner.' to '.Input::get('owner');
  869. $log->save();
  870. DB::table('timeshares')
  871. ->where('id','=', $id)
  872. ->update(array(
  873. 'owner' => Input::get('owner')
  874. )
  875. );
  876. }
  877. if(Input::get('spacebankedyear')!=$timeshare->spacebankedyear)
  878. {
  879. $log = new TimeshareLog;
  880. $log->user_id = Auth::user()->id;
  881. $log->timeshare_id = $timeshare->id;
  882. $log->name = Auth::user()->name;
  883. $log->resort = $timeshare->resort;
  884. $log->module = $timeshare->module;
  885. $log->unit = $timeshare->unit;
  886. $log->change = 'The space banked year was changed from '.$timeshare->spacebankedyear.' to '.Input::get('spacebankedyear');
  887. $log->save();
  888. DB::table('timeshares')
  889. ->where('id','=', $id)
  890. ->update(array(
  891. 'spacebankedyear' => Input::get('spacebankedyear')
  892. )
  893. );
  894. }
  895. if(Input::get('spacebankOwner')!=$timeshare->spacebankOwner)
  896. {
  897. $log = new TimeshareLog;
  898. $log->user_id = Auth::user()->id;
  899. $log->timeshare_id = $timeshare->id;
  900. $log->name = Auth::user()->name;
  901. $log->resort = $timeshare->resort;
  902. $log->module = $timeshare->module;
  903. $log->unit = $timeshare->unit;
  904. $log->change = 'The space bank owner was changed from '.$timeshare->spacebankOwner.' to '.Input::get('spacebankOwner');
  905. $log->save();
  906. DB::table('timeshares')
  907. ->where('id','=', $id)
  908. ->update(array(
  909. 'spacebankOwner' => Input::get('spacebankOwner')
  910. )
  911. );
  912. }
  913. if(Input::get('status')!='NULL')
  914. {
  915. $log = new TimeshareLog;
  916. $log->user_id = Auth::user()->id;
  917. $log->timeshare_id = $timeshare->id;
  918. $log->name = Auth::user()->name;
  919. $log->resort = $timeshare->resort;
  920. $log->module = $timeshare->module;
  921. $log->unit = $timeshare->unit;
  922. $log->change = 'The status was changed from '.$timeshare->status.' to '.Input::get('status');
  923. $log->save();
  924. DB::table('timeshares')
  925. ->where('id','=', $id)
  926. ->update(array(
  927. 'status' => Input::get('status')
  928. )
  929. );
  930. }
  931. if(Input::get('publish')!='NULL')
  932. {
  933. $log = new TimeshareLog;
  934. $log->user_id = Auth::user()->id;
  935. $log->timeshare_id = $timeshare->id;
  936. $log->name = Auth::user()->name;
  937. $log->resort = $timeshare->resort;
  938. $log->module = $timeshare->module;
  939. $log->unit = $timeshare->unit;
  940. $log->change = 'The publish status was changed from '.$timeshare->published.' to '.Input::get('published');
  941. $log->save();
  942. DB::table('timeshares')
  943. ->where('id','=', $id)
  944. ->update(array(
  945. 'published' => Input::get('publish')
  946. )
  947. );
  948. }
  949. if(Input::get('statusDate')!=$timeshare->statusDate)
  950. {
  951. $log = new TimeshareLog;
  952. $log->user_id = Auth::user()->id;
  953. $log->timeshare_id = $timeshare->id;
  954. $log->name = Auth::user()->name;
  955. $log->resort = $timeshare->resort;
  956. $log->module = $timeshare->module;
  957. $log->unit = $timeshare->unit;
  958. $log->change = 'The status date was changed from '.$timeshare->statusDate.' to '.Input::get('statusDate');
  959. $log->save();
  960. DB::table('timeshares')
  961. ->where('id','=', $id)
  962. ->update(array(
  963. 'statusDate' => Input::get('statusDate')
  964. )
  965. );
  966. }
  967. return Redirect::to('admin')->with('view-success',' Timeshare successfully updated');
  968. }
  969. public function serveEditAgencyTimeshare($id)
  970. {
  971. $timeshare = DB::table('timeshares')
  972. ->where('id','=',$id)
  973. ->first();
  974. return View::make('edit-agency-timeshare')
  975. ->with('timeshare',$timeshare);
  976. }
  977. public function handleEditAgencyTimeshare($id)
  978. {
  979. $validator = Validator::make(Input::all(),
  980. [
  981. 'resort' => 'required',
  982. 'module' => 'required',
  983. 'week' => 'required',
  984. 'bedrooms' => 'required'
  985. ]);
  986. if($validator->fails())
  987. {
  988. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  989. }
  990. $timeshare = DB::table('timeshares')
  991. ->where('id','=',$id)
  992. ->first();
  993. if(Input::get('resort')!=$timeshare->resort)
  994. {
  995. $log = new TimeshareLog;
  996. $log->user_id = Auth::user()->id;
  997. $log->timeshare_id = $timeshare->id;
  998. $log->name = Auth::user()->name;
  999. $log->resort = $timeshare->resort;
  1000. $log->module = $timeshare->module;
  1001. $log->unit = $timeshare->unit;
  1002. $log->change = 'Resort name changed from '.$timeshare->resort.' to '.Input::get('resort');
  1003. $log->save();
  1004. DB::table('timeshares')
  1005. ->where('id','=', $id)
  1006. ->update(array(
  1007. 'resort' => Input::get('resort')
  1008. )
  1009. );
  1010. }
  1011. if(Input::get('module')!=$timeshare->module)
  1012. {
  1013. $log = new TimeshareLog;
  1014. $log->user_id = Auth::user()->id;
  1015. $log->timeshare_id = $timeshare->id;
  1016. $log->name = Auth::user()->name;
  1017. $log->resort = $timeshare->resort;
  1018. $log->module = $timeshare->module;
  1019. $log->unit = $timeshare->unit;
  1020. $log->change = 'Module changed from '.$timeshare->module.' to '.Input::get('module');
  1021. $log->save();
  1022. DB::table('timeshares')
  1023. ->where('id','=', $id)
  1024. ->update(array(
  1025. 'module' => Input::get('module')
  1026. )
  1027. );
  1028. }
  1029. if(Input::get('week')!=$timeshare->week)
  1030. {
  1031. $log = new TimeshareLog;
  1032. $log->user_id = Auth::user()->id;
  1033. $log->timeshare_id = $timeshare->id;
  1034. $log->name = Auth::user()->name;
  1035. $log->resort = $timeshare->resort;
  1036. $log->module = $timeshare->module;
  1037. $log->unit = $timeshare->unit;
  1038. $log->change = 'Week changed from '.$timeshare->week.' to '.Input::get('week');
  1039. $log->save();
  1040. DB::table('timeshares')
  1041. ->where('id','=', $id)
  1042. ->update(array(
  1043. 'week' => Input::get('week')
  1044. )
  1045. );
  1046. }
  1047. if(Input::get('levy')!=$timeshare->levy)
  1048. {
  1049. $log = new TimeshareLog;
  1050. $log->user_id = Auth::user()->id;
  1051. $log->timeshare_id = $timeshare->id;
  1052. $log->name = Auth::user()->name;
  1053. $log->resort = $timeshare->resort;
  1054. $log->module = $timeshare->module;
  1055. $log->unit = $timeshare->unit;
  1056. $log->change = 'Levy changed from '.$timeshare->levy.' to '.Input::get('levy');
  1057. $log->save();
  1058. DB::table('timeshares')
  1059. ->where('id','=', $id)
  1060. ->update(array(
  1061. 'levy' => Input::get('levy')
  1062. )
  1063. );
  1064. }
  1065. if(Input::get('fromDate')!=$timeshare->fromDate)
  1066. {
  1067. $log = new TimeshareLog;
  1068. $log->user_id = Auth::user()->id;
  1069. $log->timeshare_id = $timeshare->id;
  1070. $log->name = Auth::user()->name;
  1071. $log->resort = $timeshare->resort;
  1072. $log->module = $timeshare->module;
  1073. $log->unit = $timeshare->unit;
  1074. $log->change = 'Departure date changed from '.$timeshare->fromDate.' to '.Input::get('fromDate');
  1075. $log->save();
  1076. DB::table('timeshares')
  1077. ->where('id','=', $id)
  1078. ->update(array(
  1079. 'fromDate' => Input::get('fromDate')
  1080. )
  1081. );
  1082. }
  1083. if(Input::get('toDate')!=$timeshare->toDate)
  1084. {
  1085. $log = new TimeshareLog;
  1086. $log->user_id = Auth::user()->id;
  1087. $log->timeshare_id = $timeshare->id;
  1088. $log->name = Auth::user()->name;
  1089. $log->resort = $timeshare->resort;
  1090. $log->module = $timeshare->module;
  1091. $log->unit = $timeshare->unit;
  1092. $log->change = 'Arrival date changed from '.$timeshare->toDate.' to '.Input::get('toDate');
  1093. $log->save();
  1094. DB::table('timeshares')
  1095. ->where('id','=', $id)
  1096. ->update(array(
  1097. 'toDate' => Input::get('toDate')
  1098. )
  1099. );
  1100. }
  1101. if(Input::get('season')!=$timeshare->season)
  1102. {
  1103. $log = new TimeshareLog;
  1104. $log->user_id = Auth::user()->id;
  1105. $log->timeshare_id = $timeshare->id;
  1106. $log->name = Auth::user()->name;
  1107. $log->resort = $timeshare->resort;
  1108. $log->module = $timeshare->module;
  1109. $log->unit = $timeshare->unit;
  1110. $log->change = 'The season was changed from '.$timeshare->season.' to '.Input::get('season');
  1111. $log->save();
  1112. DB::table('timeshares')
  1113. ->where('id','=', $id)
  1114. ->update(array(
  1115. 'season' => Input::get('season')
  1116. )
  1117. );
  1118. }
  1119. if(Input::get('region')!=$timeshare->region)
  1120. {
  1121. $log = new TimeshareLog;
  1122. $log->user_id = Auth::user()->id;
  1123. $log->timeshare_id = $timeshare->id;
  1124. $log->name = Auth::user()->name;
  1125. $log->resort = $timeshare->resort;
  1126. $log->module = $timeshare->module;
  1127. $log->unit = $timeshare->unit;
  1128. $log->change = 'The region was changed from '.$timeshare->region.' to '.Input::get('region');
  1129. $log->save();
  1130. DB::table('timeshares')
  1131. ->where('id','=', $id)
  1132. ->update(array(
  1133. 'region' => Input::get('region')
  1134. )
  1135. );
  1136. }
  1137. if(Input::get('setPrice')!=$timeshare->setPrice)
  1138. {
  1139. $log = new TimeshareLog;
  1140. $log->user_id = Auth::user()->id;
  1141. $log->timeshare_id = $timeshare->id;
  1142. $log->name = Auth::user()->name;
  1143. $log->resort = $timeshare->resort;
  1144. $log->module = $timeshare->module;
  1145. $log->unit = $timeshare->unit;
  1146. $log->change = 'The set price was changed from '.$timeshare->setPrice.' to '.Input::get('setPrice');
  1147. $log->save();
  1148. DB::table('timeshares')
  1149. ->where('id','=', $id)
  1150. ->update(array(
  1151. 'setPrice' => Input::get('setPrice')
  1152. )
  1153. );
  1154. }
  1155. if(Input::get('price')!=$timeshare->price)
  1156. {
  1157. $log = new TimeshareLog;
  1158. $log->user_id = Auth::user()->id;
  1159. $log->timeshare_id = $timeshare->id;
  1160. $log->name = Auth::user()->name;
  1161. $log->resort = $timeshare->resort;
  1162. $log->module = $timeshare->module;
  1163. $log->unit = $timeshare->unit;
  1164. $log->change = 'The price was changed from '.$timeshare->price.' to '.Input::get('price');
  1165. $log->save();
  1166. DB::table('timeshares')
  1167. ->where('id','=', $id)
  1168. ->update(array(
  1169. 'price' => Input::get('price')
  1170. )
  1171. );
  1172. }
  1173. if(Input::get('bedrooms')!=$timeshare->bedrooms)
  1174. {
  1175. $log = new TimeshareLog;
  1176. $log->user_id = Auth::user()->id;
  1177. $log->timeshare_id = $timeshare->id;
  1178. $log->name = Auth::user()->name;
  1179. $log->resort = $timeshare->resort;
  1180. $log->module = $timeshare->module;
  1181. $log->unit = $timeshare->unit;
  1182. $log->change = 'The number of bedrooms was changed from '.$timeshare->bedrooms.' to '.Input::get('bedrooms');
  1183. $log->save();
  1184. DB::table('timeshares')
  1185. ->where('id','=', $id)
  1186. ->update(array(
  1187. 'bedrooms' => Input::get('bedrooms')
  1188. )
  1189. );
  1190. }
  1191. if(Input::get('sleeps')!=$timeshare->sleeps)
  1192. {
  1193. $log = new TimeshareLog;
  1194. $log->user_id = Auth::user()->id;
  1195. $log->timeshare_id = $timeshare->id;
  1196. $log->name = Auth::user()->name;
  1197. $log->resort = $timeshare->resort;
  1198. $log->module = $timeshare->module;
  1199. $log->unit = $timeshare->unit;
  1200. $log->change = 'The maximum occupation per unit was changed from '.$timeshare->sleeps.' to '.Input::get('sleeps');
  1201. $log->save();
  1202. DB::table('timeshares')
  1203. ->where('id','=', $id)
  1204. ->update(array(
  1205. 'sleeps' => Input::get('sleeps')
  1206. )
  1207. );
  1208. }
  1209. if(Input::get('unit')!=$timeshare->unit)
  1210. {
  1211. $log = new TimeshareLog;
  1212. $log->user_id = Auth::user()->id;
  1213. $log->timeshare_id = $timeshare->id;
  1214. $log->name = Auth::user()->name;
  1215. $log->resort = $timeshare->resort;
  1216. $log->module = $timeshare->module;
  1217. $log->unit = $timeshare->unit;
  1218. $log->change = 'The unit number was changed from '.$timeshare->unit.' to '.Input::get('unit');
  1219. $log->save();
  1220. DB::table('timeshares')
  1221. ->where('id','=', $id)
  1222. ->update(array(
  1223. 'unit' => Input::get('unit')
  1224. )
  1225. );
  1226. }
  1227. if(Input::get('owner')!=$timeshare->owner)
  1228. {
  1229. $log = new TimeshareLog;
  1230. $log->user_id = Auth::user()->id;
  1231. $log->timeshare_id = $timeshare->id;
  1232. $log->name = Auth::user()->name;
  1233. $log->resort = $timeshare->resort;
  1234. $log->module = $timeshare->module;
  1235. $log->unit = $timeshare->unit;
  1236. $log->change = 'The owner was changed from '.$timeshare->owner.' to '.Input::get('owner');
  1237. $log->save();
  1238. DB::table('timeshares')
  1239. ->where('id','=', $id)
  1240. ->update(array(
  1241. 'owner' => Input::get('owner')
  1242. )
  1243. );
  1244. }
  1245. if(Input::get('spacebankedyear')!=$timeshare->spacebankedyear)
  1246. {
  1247. $log = new TimeshareLog;
  1248. $log->user_id = Auth::user()->id;
  1249. $log->timeshare_id = $timeshare->id;
  1250. $log->name = Auth::user()->name;
  1251. $log->resort = $timeshare->resort;
  1252. $log->module = $timeshare->module;
  1253. $log->unit = $timeshare->unit;
  1254. $log->change = 'The space banked year was changed from '.$timeshare->spacebankedyear.' to '.Input::get('spacebankedyear');
  1255. $log->save();
  1256. DB::table('timeshares')
  1257. ->where('id','=', $id)
  1258. ->update(array(
  1259. 'spacebankedyear' => Input::get('spacebankedyear')
  1260. )
  1261. );
  1262. }
  1263. if(Input::get('spacebankOwner')!=$timeshare->spacebankOwner)
  1264. {
  1265. $log = new TimeshareLog;
  1266. $log->user_id = Auth::user()->id;
  1267. $log->timeshare_id = $timeshare->id;
  1268. $log->name = Auth::user()->name;
  1269. $log->resort = $timeshare->resort;
  1270. $log->module = $timeshare->module;
  1271. $log->unit = $timeshare->unit;
  1272. $log->change = 'The space bank owner was changed from '.$timeshare->spacebankOwner.' to '.Input::get('spacebankOwner');
  1273. $log->save();
  1274. DB::table('timeshares')
  1275. ->where('id','=', $id)
  1276. ->update(array(
  1277. 'spacebankOwner' => Input::get('spacebankOwner')
  1278. )
  1279. );
  1280. }
  1281. if(Input::get('status')!='NULL')
  1282. {
  1283. $log = new TimeshareLog;
  1284. $log->user_id = Auth::user()->id;
  1285. $log->timeshare_id = $timeshare->id;
  1286. $log->name = Auth::user()->name;
  1287. $log->resort = $timeshare->resort;
  1288. $log->module = $timeshare->module;
  1289. $log->unit = $timeshare->unit;
  1290. $log->change = 'The status was changed from '.$timeshare->status.' to '.Input::get('status');
  1291. $log->save();
  1292. DB::table('timeshares')
  1293. ->where('id','=', $id)
  1294. ->update(array(
  1295. 'status' => Input::get('status')
  1296. )
  1297. );
  1298. }
  1299. if(Input::get('publish')!='NULL')
  1300. {
  1301. $log = new TimeshareLog;
  1302. $log->user_id = Auth::user()->id;
  1303. $log->timeshare_id = $timeshare->id;
  1304. $log->name = Auth::user()->name;
  1305. $log->resort = $timeshare->resort;
  1306. $log->module = $timeshare->module;
  1307. $log->unit = $timeshare->unit;
  1308. $log->change = 'The publish status was changed from '.$timeshare->published.' to '.Input::get('published');
  1309. $log->save();
  1310. DB::table('timeshares')
  1311. ->where('id','=', $id)
  1312. ->update(array(
  1313. 'published' => Input::get('publish')
  1314. )
  1315. );
  1316. }
  1317. if(Input::get('statusDate')!=$timeshare->statusDate)
  1318. {
  1319. $log = new TimeshareLog;
  1320. $log->user_id = Auth::user()->id;
  1321. $log->timeshare_id = $timeshare->id;
  1322. $log->name = Auth::user()->name;
  1323. $log->resort = $timeshare->resort;
  1324. $log->module = $timeshare->module;
  1325. $log->unit = $timeshare->unit;
  1326. $log->change = 'The status date was changed from '.$timeshare->statusDate.' to '.Input::get('statusDate');
  1327. $log->save();
  1328. DB::table('timeshares')
  1329. ->where('id','=', $id)
  1330. ->update(array(
  1331. 'statusDate' => Input::get('statusDate')
  1332. )
  1333. );
  1334. }
  1335. return Redirect::to('manage-agency-timeshares')->with('view-success',' Timeshare successfully updated');
  1336. }
  1337. public function serveEditTimeshareAgent($id)
  1338. {
  1339. $user = DB::table('users')
  1340. ->where('id','=',$id)
  1341. ->first();
  1342. return View::make('edit-timeshare-agent')
  1343. ->with('user',$user);
  1344. }
  1345. public function handleEditTimeshareAgent($id)
  1346. {
  1347. $validator = Validator::make(Input::all(),
  1348. [
  1349. 'name' => 'required'
  1350. ]);
  1351. if($validator->fails())
  1352. {
  1353. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1354. }
  1355. DB::table('users')
  1356. ->where('id','=', $id)
  1357. ->update(array(
  1358. 'name' => Input::get('name')
  1359. )
  1360. );
  1361. DB::table('users')
  1362. ->where('id','=', $id)
  1363. ->update(array(
  1364. 'email' => Input::get('email')
  1365. )
  1366. );
  1367. DB::table('users')
  1368. ->where('id','=', $id)
  1369. ->update(array(
  1370. 'phone' => Input::get('phone')
  1371. )
  1372. );
  1373. DB::table('users')
  1374. ->where('id','=', $id)
  1375. ->update(array(
  1376. 'mobile' => Input::get('mobile')
  1377. )
  1378. );
  1379. DB::table('users')
  1380. ->where('id','=', $id)
  1381. ->update(array(
  1382. 'username' => Input::get('username')
  1383. )
  1384. );
  1385. if(Input::get('timeshare_publish')!='NULL') {
  1386. DB::table('users')
  1387. ->where('id','=', $id)
  1388. ->update(array(
  1389. 'timeshare_publish' => Input::get('timeshare_publish')
  1390. )
  1391. );
  1392. }
  1393. return Redirect::to('timeshare-agents')->with('view-success',' Agent details successfully updated');
  1394. }
  1395. public function serveEditCommercial($id)
  1396. {
  1397. $commercial = DB::table('commercials')
  1398. ->where('id','=',$id)
  1399. ->first();
  1400. return View::make('admin.edit-commercial')
  1401. ->with('commercial',$commercial);
  1402. }
  1403. public function handleEditCommercial($id)
  1404. {
  1405. $validator = Validator::make(Input::all(),
  1406. [
  1407. 'name' => 'required'
  1408. ]);
  1409. if($validator->fails())
  1410. {
  1411. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1412. }
  1413. DB::table('commercials')
  1414. ->where('id','=', $id)
  1415. ->update(array(
  1416. 'name' => Input::get('name')
  1417. )
  1418. );
  1419. DB::table('commercials')
  1420. ->where('id','=', $id)
  1421. ->update(array(
  1422. 'address' => Input::get('address')
  1423. )
  1424. );
  1425. DB::table('commercials')
  1426. ->where('id','=', $id)
  1427. ->update(array(
  1428. 'region' => Input::get('region')
  1429. )
  1430. );
  1431. DB::table('commercials')
  1432. ->where('id','=', $id)
  1433. ->update(array(
  1434. 'town' => Input::get('town')
  1435. )
  1436. );
  1437. DB::table('commercials')
  1438. ->where('id','=', $id)
  1439. ->update(array(
  1440. 'status2' => Input::get('status2')
  1441. )
  1442. );
  1443. DB::table('commercials')
  1444. ->where('id','=', $id)
  1445. ->update(array(
  1446. 'surburb' => Input::get('surburb')
  1447. )
  1448. );
  1449. DB::table('commercials')
  1450. ->where('id','=', $id)
  1451. ->update(array(
  1452. 'unit' => Input::get('unit')
  1453. )
  1454. );
  1455. DB::table('commercials')
  1456. ->where('id','=', $id)
  1457. ->update(array(
  1458. 'size' => Input::get('size')
  1459. )
  1460. );
  1461. DB::table('commercials')
  1462. ->where('id','=', $id)
  1463. ->update(array(
  1464. 'price' => Input::get('price')
  1465. )
  1466. );
  1467. DB::table('commercials')
  1468. ->where('id','=', $id)
  1469. ->update(array(
  1470. 'description' => Input::get('description')
  1471. )
  1472. );
  1473. DB::table('commercials')
  1474. ->where('id','=', $id)
  1475. ->update(array(
  1476. 'contact_person' => Input::get('contact_person')
  1477. )
  1478. );
  1479. DB::table('commercials')
  1480. ->where('id','=', $id)
  1481. ->update(array(
  1482. 'contact_email' => Input::get('contact_email')
  1483. )
  1484. );
  1485. DB::table('commercials')
  1486. ->where('id','=', $id)
  1487. ->update(array(
  1488. 'contact_mobile' => Input::get('contact_mobile')
  1489. )
  1490. );
  1491. DB::table('commercials')
  1492. ->where('id','=', $id)
  1493. ->update(array(
  1494. 'propertType' => Input::get('propertType')
  1495. )
  1496. );
  1497. return Redirect::to('commercial-admin')->with('view-success',' Commercial property successfully updated');
  1498. }
  1499. public function serveEditResidential($id)
  1500. {
  1501. $residential = DB::table('residentials')
  1502. ->where('id','=',$id)
  1503. ->first();
  1504. return View::make('admin.edit-residential')
  1505. ->with('residential',$residential);
  1506. }
  1507. public function handleEditResidential($id)
  1508. {
  1509. $validator = Validator::make(Input::all(),
  1510. [
  1511. 'name' => 'required'
  1512. ]);
  1513. if($validator->fails())
  1514. {
  1515. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1516. }
  1517. DB::table('residentials')
  1518. ->where('id','=', $id)
  1519. ->update(array(
  1520. 'name' => Input::get('name')
  1521. )
  1522. );
  1523. DB::table('residentials')
  1524. ->where('id','=', $id)
  1525. ->update(array(
  1526. 'address' => Input::get('address')
  1527. )
  1528. );
  1529. if(Input::get('region')!='') {
  1530. DB::table('residentials')
  1531. ->where('id','=', $id)
  1532. ->update(array(
  1533. 'region' => Input::get('region')
  1534. )
  1535. );
  1536. }
  1537. if(Input::get('town')!='') {
  1538. DB::table('residentials')
  1539. ->where('id','=', $id)
  1540. ->update(array(
  1541. 'town' => Input::get('town')
  1542. )
  1543. );
  1544. }
  1545. if(Input::get('status2')!='') {
  1546. DB::table('residentials')
  1547. ->where('id','=', $id)
  1548. ->update(array(
  1549. 'status2' => Input::get('status2')
  1550. )
  1551. );
  1552. }
  1553. if(Input::get('status')!='') {
  1554. DB::table('residentials')
  1555. ->where('id','=', $id)
  1556. ->update(array(
  1557. 'status' => Input::get('status')
  1558. )
  1559. );
  1560. }
  1561. if(Input::get('surburb')!='') {
  1562. DB::table('residentials')
  1563. ->where('id','=', $id)
  1564. ->update(array(
  1565. 'surburb' => Input::get('surburb')
  1566. )
  1567. );
  1568. }
  1569. DB::table('residentials')
  1570. ->where('id','=', $id)
  1571. ->update(array(
  1572. 'unit' => Input::get('unit')
  1573. )
  1574. );
  1575. DB::table('residentials')
  1576. ->where('id','=', $id)
  1577. ->update(array(
  1578. 'size' => Input::get('size')
  1579. )
  1580. );
  1581. DB::table('residentials')
  1582. ->where('id','=', $id)
  1583. ->update(array(
  1584. 'price' => Input::get('price')
  1585. )
  1586. );
  1587. DB::table('residentials')
  1588. ->where('id','=', $id)
  1589. ->update(array(
  1590. 'description' => Input::get('description')
  1591. )
  1592. );
  1593. DB::table('residentials')
  1594. ->where('id','=', $id)
  1595. ->update(array(
  1596. 'contact_person' => Input::get('contact_person')
  1597. )
  1598. );
  1599. DB::table('residentials')
  1600. ->where('id','=', $id)
  1601. ->update(array(
  1602. 'contact_email' => Input::get('contact_email')
  1603. )
  1604. );
  1605. DB::table('residentials')
  1606. ->where('id','=', $id)
  1607. ->update(array(
  1608. 'contact_mobile' => Input::get('contact_mobile')
  1609. )
  1610. );
  1611. DB::table('residentials')
  1612. ->where('id','=', $id)
  1613. ->update(array(
  1614. 'bedrooms' => Input::get('bedrooms')
  1615. )
  1616. );
  1617. DB::table('residentials')
  1618. ->where('id','=', $id)
  1619. ->update(array(
  1620. 'bathrooms' => Input::get('bathrooms')
  1621. )
  1622. );
  1623. if(Input::get('propertType')!='') {
  1624. DB::table('residentials')
  1625. ->where('id','=', $id)
  1626. ->update(array(
  1627. 'propertType' => Input::get('propertType')
  1628. )
  1629. );
  1630. }
  1631. return Redirect::to('residential-admin')->with('view-success',' Residential property successfully updated');
  1632. }
  1633. public function serveTermsConditions()
  1634. {
  1635. return View::make('terms-and-conditions');
  1636. }
  1637. public function deleteTimeshare($id)
  1638. {
  1639. DB::table('timeshares')
  1640. ->where('id','=',$id)
  1641. ->delete();
  1642. return Redirect::to('admin')->with('view-success', ' SUCCESS: Timeshare Deleted');
  1643. }
  1644. public function deleteTimeshareAgent($id)
  1645. {
  1646. DB::table('users')
  1647. ->where('id','=',$id)
  1648. ->delete();
  1649. return Redirect::to('timeshare-agents')->with('view-success', ' SUCCESS: Agent Deleted');
  1650. }
  1651. public function deleteResidential($id)
  1652. {
  1653. DB::table('residentials')
  1654. ->where('id','=',$id)
  1655. ->delete();
  1656. return Redirect::to('residential-admin')->with('view-success', ' SUCCESS: Residential listing Deleted');
  1657. }
  1658. public function deleteCommercial($id)
  1659. {
  1660. DB::table('commercials')
  1661. ->where('id','=',$id)
  1662. ->delete();
  1663. return Redirect::to('commercial-admin')->with('view-success', ' SUCCESS: Commercial listing Deleted');
  1664. }
  1665. public function handleContacts()
  1666. {
  1667. $validator = Validator::make(Input::all(),
  1668. [
  1669. 'name' => 'required',
  1670. 'message' => 'required'
  1671. ]);
  1672. if($validator->fails())
  1673. {
  1674. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1675. }
  1676. $contact = new Contact;
  1677. $contact->name = Input::get('name');
  1678. $contact->surname = Input::get('surname');
  1679. $contact->cell = Input::get('cell');
  1680. $contact->telephone = Input::get('telephone');
  1681. $contact->email = Input::get('email');
  1682. $contact->message = Input::get('message');
  1683. $contact->save();
  1684. $data = ['contact' => $contact];
  1685. Mail::send('emails.contact', $data, function($message)
  1686. {
  1687. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Message from the Uni-vate Properties Contact Page');
  1688. $message->from('info@univateproperties.co.za');
  1689. });
  1690. return Redirect::back()->with('view-success', 'Your message is submitted');
  1691. }
  1692. public function handleContactsResortPage($id)
  1693. {
  1694. $validator = Validator::make(Input::all(),
  1695. [
  1696. 'name' => 'required',
  1697. 'email' => 'required',
  1698. 'message' => 'required'
  1699. ]);
  1700. if($validator->fails())
  1701. {
  1702. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1703. }
  1704. $resort = DB::table('resorts')
  1705. ->where('id','=',$id)
  1706. ->first();
  1707. $contact = new ContactResort;
  1708. $contact->name = Input::get('name');
  1709. $contact->surname = Input::get('surname');
  1710. $contact->cell = Input::get('cell');
  1711. $contact->email = Input::get('email');
  1712. $contact->message = Input::get('message');
  1713. $contact->save();
  1714. $data = ['contact' => $contact, 'resort' => $resort];
  1715. Mail::send('emails.contactResort', $data, function($message) use ($resort)
  1716. {
  1717. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Message from the '.$resort->resort.' page.');
  1718. $message->from('info@univateproperties.co.za');
  1719. });
  1720. return Redirect::back()->with('view-success', 'Your message is submitted');
  1721. }
  1722. public function handleContactCommercial($id)
  1723. {
  1724. $validator = Validator::make(Input::all(),
  1725. [
  1726. 'name' => 'required',
  1727. 'email' => 'required',
  1728. 'message' => 'required',
  1729. 'property' => 'required'
  1730. ]);
  1731. if($validator->fails())
  1732. {
  1733. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1734. }
  1735. $contact = new Contact;
  1736. $contact->name = Input::get('name');
  1737. $contact->cell = Input::get('cell');
  1738. $contact->email = Input::get('email');
  1739. $contact->property = Input::get('property');
  1740. $contact->message = Input::get('message');
  1741. $contact->save();
  1742. $data = ['contact' => $contact];
  1743. Mail::send('emails.contactCommercial', $data, function($message) use ($contact)
  1744. {
  1745. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Message from the commercial properties page.');
  1746. $message->from('info@univateproperties.co.za');
  1747. });
  1748. return Redirect::back()->with('view-success', 'Your message is submitted');
  1749. }
  1750. public function serveSearch()
  1751. {
  1752. $validator = Validator::make(Input::all(),
  1753. [
  1754. 'search' => 'required',
  1755. ]);
  1756. if($validator->fails())
  1757. {
  1758. return Redirect::back()->with('view-error', 'No search entered, please try again')->withInput()->withErrors($validator);
  1759. }
  1760. $query = Input::get('search');
  1761. $timeshares = DB::table('timeshares')
  1762. ->where('resort', 'LIKE', '%' . $query . '%')//resort name
  1763. ->get();
  1764. if($timeshares->isEmpty())
  1765. {
  1766. return Redirect::back()->with('view-search-error', 'There were no results found, please try searching by resort name.');
  1767. }
  1768. else
  1769. {
  1770. // multiple resorts search results
  1771. return View::make('search-results')
  1772. ->with('timeshares', $timeshares);
  1773. }
  1774. }
  1775. public function serveCommercialSearch()
  1776. {
  1777. $validator = Validator::make(Input::all(),
  1778. [
  1779. 'search' => 'required',
  1780. ]);
  1781. if($validator->fails())
  1782. {
  1783. return Redirect::back()->with('view-error', 'No search entered, please try again')->withInput()->withErrors($validator);
  1784. }
  1785. $query = Input::get('search');
  1786. $commercials = DB::table('commercials')
  1787. ->where('name', 'LIKE', '%' . $query . '%')// property name
  1788. ->where('published','=',1)
  1789. ->paginate(10);
  1790. if($commercials->isEmpty())
  1791. {
  1792. return Redirect::back()->with('view-search-error', 'There were no results found, please try searching by property name.');
  1793. }
  1794. else
  1795. {
  1796. // multiple resorts search results
  1797. return View::make('commercial-search-results')
  1798. ->with('commercials', $commercials);
  1799. }
  1800. }
  1801. public function serveResidentialSearch()
  1802. {
  1803. $validator = Validator::make(Input::all(),
  1804. [
  1805. 'search' => 'required',
  1806. ]);
  1807. if($validator->fails())
  1808. {
  1809. return Redirect::back()->with('view-error', 'No search entered, please try again')->withInput()->withErrors($validator);
  1810. }
  1811. $query = Input::get('search');
  1812. $residentials = DB::table('residentials')
  1813. ->where('name', 'LIKE', '%' . $query . '%')// property name
  1814. ->where('published','=',1)
  1815. ->paginate(10);
  1816. if($residentials->isEmpty())
  1817. {
  1818. return Redirect::back()->with('view-search-error', 'There were no results found, please try searching by property name.');
  1819. }
  1820. else
  1821. {
  1822. // multiple resorts search results
  1823. return View::make('residential-search-result')
  1824. ->with('residentials', $residentials);
  1825. }
  1826. }
  1827. public function serveRegister()
  1828. {
  1829. return View::make('register');
  1830. }
  1831. public function handleRegister()
  1832. {
  1833. $validator = Validator::make(Input::all(),
  1834. [
  1835. 'name' => 'required',
  1836. 'surname' => 'required',
  1837. 'username' => 'required',
  1838. 'email' => 'required|email',
  1839. 'password' => 'required',
  1840. 'password1' => 'required'
  1841. ]);
  1842. $users = DB::table('users')
  1843. ->get();
  1844. foreach($users as $user){
  1845. if($user->username == Input::get('username'))
  1846. return Redirect::back()->with('view-error', ' This username already exists, please try a different username.')->withInput()->withErrors($validator);
  1847. }
  1848. foreach($users as $user){
  1849. if($user->email == Input::get('email'))
  1850. return Redirect::back()->with('view-error', ' This email account already exists, please login.')->withInput()->withErrors($validator);
  1851. }
  1852. if($validator->fails())
  1853. {
  1854. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1855. }
  1856. if((Input::get('password'))!=(Input::get('password1')))
  1857. {
  1858. return Redirect::back()->with('view-error', ' Passwords do not match')->withInput()->withErrors($validator);
  1859. }
  1860. $user = new User;
  1861. $user->name = Input::get('name');
  1862. $user->email = Input::get('email');
  1863. $user->phone = Input::get('phone');
  1864. $user->mobile = Input::get('mobile');
  1865. $user->surname = Input::get('surname');
  1866. $user->username = Input::get('username');
  1867. $user->password = Hash::make(Input::get('password'));
  1868. $user->role = 'user';
  1869. $user->save();
  1870. $data = ['user' => $user];
  1871. Mail::send('emails.register', $data, function($message) use ($user)
  1872. {
  1873. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New registration on www.univateproperties.co.za');
  1874. $message->from('info@univateproperties.co.za');
  1875. });
  1876. return Redirect::back()->with('view-success','You have successfully registered, your confirmation email will be in your inbox shortly.');
  1877. }
  1878. public function confirmationButton($email)
  1879. {
  1880. $user = DB::table('users')
  1881. ->where('email','=',$email)
  1882. ->first();
  1883. DB::table('users')
  1884. ->where('email','=', $email)
  1885. ->update(array(
  1886. 'verified' => 'yes'
  1887. )
  1888. );
  1889. return Redirect::to('login')->withInput()->with('view-success', 'Your email has been successfully verified. Please proceed to log in.');
  1890. }
  1891. public function LittleEden()
  1892. {
  1893. //$options = array('trace' => 1, 'exceptions' => 1);
  1894. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/LE";
  1895. $details = json_decode(file_get_contents($wsdl), true);
  1896. //dd($details['prName']);
  1897. $timeshares = DB::table('timeshares')
  1898. ->where('resort','=','little eden')
  1899. ->where('published','=',1)
  1900. ->paginate(5);
  1901. $resort = DB::table('resorts')
  1902. ->where('resort','=','little eden')
  1903. ->first();
  1904. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/LE/layout';
  1905. $details2 = base64_decode(file_get_contents($layout), true);
  1906. $awards = explode(',',$resort->awards);
  1907. return View::make('resorts.little-eden')
  1908. ->with('awards',$awards)
  1909. ->with('resort',$resort)
  1910. ->with('timeshares',$timeshares)
  1911. ->with('details',$details);
  1912. }
  1913. public function KaggaKamma()
  1914. {
  1915. //$options = array('trace' => 1, 'exceptions' => 1);
  1916. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/KK";
  1917. $details = json_decode(file_get_contents($wsdl), true);
  1918. //dd($details['prName']);
  1919. $timeshares = DB::table('timeshares')
  1920. ->where('resort','=','kagga kamma')
  1921. ->where('published','=',1)
  1922. ->paginate(5);
  1923. $resort = DB::table('resorts')
  1924. ->where('resort','=','kagga kamma')
  1925. ->first();
  1926. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/KK/layout';
  1927. $details2 = base64_decode(file_get_contents($layout), true);
  1928. $awards = explode(',',$resort->awards);
  1929. return View::make('resorts.kagga-kamma')
  1930. ->with('awards',$awards)
  1931. ->with('resort',$resort)
  1932. ->with('timeshares',$timeshares)
  1933. ->with('details',$details);
  1934. }
  1935. public function Mabalingwe()
  1936. {
  1937. return Redirect::to('/resort/mabalingwe');
  1938. }
  1939. public function Kridzil()
  1940. {
  1941. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/KRIDZ";
  1942. $details = json_decode(file_get_contents($wsdl), true);
  1943. $timeshares = DB::table('timeshares')
  1944. ->where('resort','=','KRIDZIL')
  1945. ->where('published','=',1)
  1946. ->paginate(5);
  1947. $resort = DB::table('resorts')
  1948. ->where('resort','=','KRIDZIL')
  1949. ->first();
  1950. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/KRIDZ/layout';
  1951. $details2 = base64_decode(file_get_contents($layout), true);
  1952. return View::make('resorts.kritzel')
  1953. ->with('resort',$resort)
  1954. ->with('timeshares',$timeshares)
  1955. ->with('details',$details);
  1956. }
  1957. public function SandyPlace()
  1958. {
  1959. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/SANDY";
  1960. $details = json_decode(file_get_contents($wsdl), true);
  1961. $timeshares = DB::table('timeshares')
  1962. ->where('resort','=','sandy place')
  1963. ->where('published','=',1)
  1964. ->paginate(5);
  1965. $resort = DB::table('resorts')
  1966. ->where('resort','=','sandy place')
  1967. ->first();
  1968. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/SANDY/layout';
  1969. $details2 = base64_decode(file_get_contents($layout), true);
  1970. $awards = explode(',',$resort->awards);
  1971. return View::make('resorts.sandy-place')
  1972. ->with('awards',$awards)
  1973. ->with('resort',$resort)
  1974. ->with('timeshares',$timeshares)
  1975. ->with('details',$details);
  1976. }
  1977. public function Uvongo()
  1978. {
  1979. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/URR";
  1980. $details = json_decode(file_get_contents($wsdl), true);
  1981. $timeshares = DB::table('timeshares')
  1982. ->where('resort','=','UVONGO RIVER RESORT')
  1983. ->where('published','=',1)
  1984. ->paginate(5);
  1985. $resort = DB::table('resorts')
  1986. ->where('resort','=','UVONGO RIVER RESORT')
  1987. ->first();
  1988. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/URR/layout';
  1989. $details2 = base64_decode(file_get_contents($layout), true);
  1990. $awards = explode(',',$resort->awards);
  1991. return View::make('resorts.uvongo')
  1992. ->with('awards',$awards)
  1993. ->with('resort',$resort)
  1994. ->with('timeshares',$timeshares)
  1995. ->with('details',$details);
  1996. }
  1997. public function Ngwenya()
  1998. {
  1999. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/NL";
  2000. $details = json_decode(file_get_contents($wsdl), true);
  2001. $timeshares = DB::table('timeshares')
  2002. ->where('resort','=','NGWENYA LODGE')
  2003. ->where('published','=',1)
  2004. ->paginate(5);
  2005. $resort = DB::table('resorts')
  2006. ->where('resort','=','NGWENYA LODGE')
  2007. ->first();
  2008. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/NL/layout';
  2009. $details2 = base64_decode(file_get_contents($layout), true);
  2010. $awards = explode(',',$resort->awards);
  2011. return View::make('resorts.ngwenya')
  2012. ->with('awards',$awards)
  2013. ->with('resort',$resort)
  2014. ->with('timeshares',$timeshares)
  2015. ->with('details',$details);
  2016. }
  2017. public function Margate()
  2018. {
  2019. $timeshares = DB::table('timeshares')
  2020. ->where('resort','=','MARGATE BEACH CLUB')
  2021. ->where('published','=',1)
  2022. ->paginate(5);
  2023. return View::make('resorts.margate-beach-club')
  2024. ->with('timeshares',$timeshares);
  2025. }
  2026. public function Sudwala()
  2027. {
  2028. return Redirect::to('/resort/sudwala-lodge');
  2029. }
  2030. public function Verlorenkloof()
  2031. {
  2032. $timeshares = DB::table('timeshares')
  2033. ->where('resort','=','Verlorenkloof')
  2034. ->where('published','=',1)
  2035. ->paginate(5);
  2036. $resort = DB::table('resorts')
  2037. ->where('resort','=','Verlorenkloof')
  2038. ->first();
  2039. return View::make('resorts.verlorenkloof')
  2040. ->with('resort',$resort)
  2041. ->with('timeshares',$timeshares);
  2042. }
  2043. public function jackalberryRidge()
  2044. {
  2045. $timeshares = DB::table('timeshares')
  2046. ->where('resort','=','JACKALBERRY RIDGE')
  2047. ->where('published','=',1)
  2048. ->paginate(5);
  2049. $resort = DB::table('resorts')
  2050. ->where('resort','=','JACKALBERRY RIDGE')
  2051. ->first();
  2052. return View::make('resorts.jackalberry-ridge')
  2053. ->with('resort',$resort)
  2054. ->with('timeshares',$timeshares);
  2055. }
  2056. public function serveCommercialSales()
  2057. {
  2058. return View::make('commercial-sales');
  2059. }
  2060. public function serveCommercialRentals()
  2061. {
  2062. $rentals = DB::table('commercial_rentals')
  2063. ->where('published','=',1)
  2064. ->get();
  2065. return View::make('commercial-rentals')
  2066. ->with('rentals',$rentals);
  2067. }
  2068. public function serveResidentialSales()
  2069. {
  2070. $rentals = DB::table('residential_sales')
  2071. ->where('published','=',1)
  2072. ->get();
  2073. return View::make('residential-sales')
  2074. ->with('rentals',$rentals);
  2075. }
  2076. public function serveResidentialRentals()
  2077. {
  2078. $rentals = DB::table('residential_rentals')
  2079. ->where('published','=',1)
  2080. ->get();
  2081. return View::make('residential-rentals')
  2082. ->with('rentals',$rentals);
  2083. }
  2084. public function serveCommercialRental($name)
  2085. {
  2086. $rental = DB::table('commercial_rentals')
  2087. ->where('name','=',$name)
  2088. ->first();
  2089. return View::make('commercial-rental')
  2090. ->with('rental',$rental);
  2091. }
  2092. public function serveResidentialRental($name)
  2093. {
  2094. $rental = DB::table('residential_rentals')
  2095. ->where('name','=',$name)
  2096. ->first();
  2097. return View::make('residential-rental')
  2098. ->with('rental',$rental);
  2099. }
  2100. public function serveCommercial()
  2101. {
  2102. return View::make('commercial');
  2103. }
  2104. public function serveResidential()
  2105. {
  2106. return View::make('residential');
  2107. }
  2108. public function handleCommercial()
  2109. {
  2110. $for = Input::get('for');
  2111. $region = Input::get('region');
  2112. $town = Input::get('town');
  2113. $surburb = Input::get('surburb');
  2114. $propertType = Input::get('propertType');
  2115. $validator = Validator::make(Input::all(),
  2116. [
  2117. 'for' => 'required',
  2118. ]);
  2119. if($validator->fails())
  2120. {
  2121. return Redirect::back()->with('view-error', 'Please select For Sale or For Rent')->withInput()->withErrors($validator);
  2122. }
  2123. $commercials = DB::table('commercials')
  2124. ->where(function($query) use ($for, $region, $town, $surburb, $propertType) {
  2125. if ($for)
  2126. $query->where('for','=', $for);
  2127. if ($region)
  2128. $query->where('region','=', $region);
  2129. if ($town)
  2130. $query->where('town','=', $town);
  2131. if ($surburb)
  2132. $query->where('surburb','=', $surburb);
  2133. if ($propertType)
  2134. $query->where('propertType','=', $propertType); })
  2135. ->groupBy('name')
  2136. ->where('published','=',1)
  2137. ->get();
  2138. /*
  2139. $commercials = DB::table('commercials')
  2140. ->where(function($query) use ($for, $region, $town, $surburb, $propertType) {
  2141. if ($for)
  2142. $query->where('for','=', $for);
  2143. if ($region)
  2144. $query->where('region','=', $region);
  2145. if ($town)
  2146. $query->where('town','=', $town);
  2147. if ($surburb)
  2148. $query->where('surburb','=', $surburb);
  2149. if ($propertType)
  2150. $query->where('propertType','=', $propertType); })
  2151. ->where('published','=',1)
  2152. ->get(); */
  2153. /*
  2154. $commercials = DB::table('properties')
  2155. ->where(function($query) use ($for, $region, $town, $surburb, $propertType) {
  2156. if ($for)
  2157. $query->where('for','=', $for);
  2158. if ($region)
  2159. $query->where('region','=', $region);
  2160. if ($town)
  2161. $query->where('town','=', $town);
  2162. if ($surburb)
  2163. $query->where('surburb','=', $surburb);
  2164. if ($propertType)
  2165. $query->where('propertType','=', $propertType); })
  2166. ->where('published','=',1)
  2167. ->get();*/
  2168. if($commercials->isEmpty())
  2169. {
  2170. return Redirect::back()->with('view-search-error', 'There were no results found.');
  2171. }
  2172. else
  2173. {
  2174. return View::make('commercial-results')
  2175. ->with('for',$for)
  2176. ->with('commercials',$commercials);
  2177. }
  2178. }
  2179. public function serveTimeshareResults()
  2180. {
  2181. return View::make('timeshare-results');
  2182. }
  2183. public function handleResidential()
  2184. {
  2185. $validator = Validator::make(Input::all(),
  2186. [
  2187. 'for' => 'required'
  2188. ]);
  2189. if($validator->fails())
  2190. {
  2191. return Redirect::back()->with('view-error', 'Please select For Sale or For Rent')->withInput()->withErrors($validator);
  2192. }
  2193. $for = Input::get('for');
  2194. $region = Input::get('region');
  2195. $town = Input::get('town');
  2196. $surburb = Input::get('surburb');
  2197. $propertType = Input::get('propertType');
  2198. $residentials = DB::table('residentials')
  2199. ->where(function($query) use ($for, $region, $town, $surburb, $propertType) {
  2200. if ($for)
  2201. $query->where('for','=', $for);
  2202. if ($region)
  2203. $query->where('region','=', $region);
  2204. if ($town)
  2205. $query->where('town','=', $town);
  2206. if ($surburb)
  2207. $query->where('surburb','=', $surburb);
  2208. if ($propertType)
  2209. $query->where('propertType','=', $propertType); })
  2210. ->where('published','=',1)
  2211. ->get();
  2212. if($residentials->isEmpty())
  2213. {
  2214. return Redirect::back()->with('view-search-error', 'There were no results found.');
  2215. }
  2216. else
  2217. {
  2218. return View::make('residential-results')
  2219. ->with('for',$for)
  2220. ->with('residentials',$residentials);
  2221. }
  2222. }
  2223. public function serveCommercialResults()
  2224. {
  2225. return View::make('commercial-results');
  2226. }
  2227. public function serveCommercialProperty($id)
  2228. {
  2229. $property = DB::table('commercials')
  2230. ->where('id','=',$id)
  2231. ->first();
  2232. return View::make('commercial-property')
  2233. ->with('property',$property);
  2234. }
  2235. public function serveResidentialProperty($id)
  2236. {
  2237. $property = DB::table('residentials')
  2238. ->where('id','=',$id)
  2239. ->first();
  2240. $facilities = explode(',',$property->facilities);
  2241. return View::make('residential-property')
  2242. ->with('facilities',$facilities)
  2243. ->with('property',$property);
  2244. }
  2245. public function serveListCommercialRental()
  2246. {
  2247. return View::make('list-commercial-rental');
  2248. }
  2249. public function handleListCommercialRental()
  2250. {
  2251. $validator = Validator::make(Input::all(),
  2252. [
  2253. 'region' => 'required',
  2254. 'address' => 'required',
  2255. 'image1' => 'required',
  2256. 'image2' => 'required'
  2257. ]);
  2258. if($validator->fails())
  2259. {
  2260. return Redirect::back()->with('view-error', ' Some information is incomplete in your submission please review below')->withInput()->withErrors($validator);
  2261. }
  2262. $commercial = new Commercial;
  2263. $commercial->name = Input::get('name');
  2264. $commercial->unit = Input::get('unit');
  2265. $commercial->address = Input::get('address');
  2266. $commercial->size = Input::get('size');
  2267. $commercial->region = Input::get('region');
  2268. $commercial->town = Input::get('town');
  2269. $commercial->opCost = Input::get('opCost');
  2270. $commercial->for = 'rental';
  2271. $commercial->description = Input::get('description');
  2272. $commercial->contact_person = Input::get('contact_person');
  2273. $commercial->contact_email = Input::get('contact_email');
  2274. $commercial->contact_mobile = Input::get('contact_mobile');
  2275. $commercial->surburb = Input::get('surburb');
  2276. $commercial->propertType = Input::get('propertType');
  2277. if (Input::hasFile('image1')) {
  2278. $file = Input::file('image1');
  2279. $file->move('img/', $file->getClientOriginalName());
  2280. $commercial->image2 = 'img/' . $file->getClientOriginalName();
  2281. }
  2282. if (Input::hasFile('image2')) {
  2283. $file = Input::file('image2');
  2284. $file->move('img/', $file->getClientOriginalName());
  2285. $commercial->image2 = 'img/' . $file->getClientOriginalName();
  2286. }
  2287. $commercial->save();
  2288. $data = ['commercial' => $commercial];
  2289. Mail::send('emails.commercial-rental-listing', $data, function($message)
  2290. {
  2291. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New Commercial Property Listing');
  2292. $message->from('info@univateproperties.co.za');
  2293. });
  2294. return Redirect::back()->with('view-success',' You have successfully submitted your property listing, an agent will contact you soon.');
  2295. }
  2296. public function serveListResidentialRental()
  2297. {
  2298. return View::make('list-residential-rental');
  2299. }
  2300. public function handleListResidentialRental()
  2301. {
  2302. $validator = Validator::make(Input::all(),
  2303. [
  2304. 'name' => 'required',
  2305. 'region' => 'required',
  2306. 'price' => 'required',
  2307. 'image1' => 'required',
  2308. 'image2' => 'required'
  2309. ]);
  2310. if($validator->fails())
  2311. {
  2312. return Redirect::back()->with('view-error', ' Some information is incomplete in your submission please review below')->withInput()->withErrors($validator);
  2313. }
  2314. $residential = new Residential;
  2315. $residential->name = Input::get('name');
  2316. $residential->ref = Input::get('ref');
  2317. $residential->size = Input::get('size');
  2318. $residential->region = Input::get('region');
  2319. $residential->town = Input::get('town');
  2320. $residential->bedrooms = Input::get('bedrooms');
  2321. $residential->bathrooms = Input::get('bathrooms');
  2322. $residential->contact_person = Input::get('contact_person');
  2323. $residential->contact_email = Input::get('contact_email');
  2324. $residential->contact_mobile = Input::get('contact_mobile');
  2325. $residential->for = 'rental';
  2326. $residential->description = Input::get('description');
  2327. $residential->surburb = Input::get('surburb');
  2328. $residential->propertType = Input::get('propertType');
  2329. if (Input::hasFile('image1')) {
  2330. $file = Input::file('image1');
  2331. $file->move('img/', $file->getClientOriginalName());
  2332. $residential->image1 = 'img/' . $file->getClientOriginalName();
  2333. }
  2334. if (Input::hasFile('image2')) {
  2335. $file = Input::file('image2');
  2336. $file->move('img/', $file->getClientOriginalName());
  2337. $residential->image2 = 'img/' . $file->getClientOriginalName();
  2338. }
  2339. $residential->save();
  2340. $data = ['residential' => $residential];
  2341. Mail::send('emails.residential-rental-listing', $data, function($message)
  2342. {
  2343. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New Residential Property Listing');
  2344. $message->from('info@univateproperties.co.za');
  2345. });
  2346. return Redirect::back()->with('view-success',' You have successfully submitted your property listing.');
  2347. }
  2348. public function serveListResidentialSale()
  2349. {
  2350. return View::make('list-residential-sale');
  2351. }
  2352. public function handleListResidentialSale()
  2353. {
  2354. $validator = Validator::make(Input::all(),
  2355. [
  2356. 'name' => 'required',
  2357. 'region' => 'required',
  2358. 'price' => 'required',
  2359. 'image1' => 'required',
  2360. 'image2' => 'required'
  2361. ]);
  2362. if($validator->fails())
  2363. {
  2364. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2365. }
  2366. $residential = new Residential;
  2367. $residential->name = Input::get('name');
  2368. $residential->ref = Input::get('ref');
  2369. $residential->size = Input::get('size');
  2370. $residential->region = Input::get('region');
  2371. $residential->town = Input::get('town');
  2372. $residential->bedrooms = Input::get('bedrooms');
  2373. $residential->bathrooms = Input::get('bathrooms');
  2374. $residential->contact_person = Input::get('contact_person');
  2375. $residential->contact_email = Input::get('contact_email');
  2376. $residential->contact_mobile = Input::get('contact_mobile');
  2377. $residential->for = 'Sale';
  2378. $residential->description = Input::get('description');
  2379. $residential->surburb = Input::get('surburb');
  2380. $residential->propertType = Input::get('propertType');
  2381. if (Input::hasFile('image1')) {
  2382. $file = Input::file('image1');
  2383. $file->move('img/', $file->getClientOriginalName());
  2384. $residential->image1 = 'img/' . $file->getClientOriginalName();
  2385. }
  2386. if (Input::hasFile('image2')) {
  2387. $file = Input::file('image2');
  2388. $file->move('img/', $file->getClientOriginalName());
  2389. $residential->image2 = 'img/' . $file->getClientOriginalName();
  2390. }
  2391. $residential->save();
  2392. $data = ['residential' => $residential];
  2393. Mail::send('emails.residential-sale-listing', $data, function($message)
  2394. {
  2395. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New Residential Property for sale Listing');
  2396. $message->from('info@univateproperties.co.za');
  2397. });
  2398. return Redirect::back()->with('view-success',' You have successfully submitted your property listing.');
  2399. }
  2400. public function serveListCommercialSale()
  2401. {
  2402. return View::make('list-commercial-sale');
  2403. }
  2404. public function handleListCommercialSale()
  2405. {
  2406. $validator = Validator::make(Input::all(),
  2407. [
  2408. 'name' => 'required',
  2409. 'region' => 'required',
  2410. 'price' => 'required',
  2411. 'image1' => 'required',
  2412. 'image2' => 'required'
  2413. ]);
  2414. if($validator->fails())
  2415. {
  2416. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2417. }
  2418. $commercial = new Commercial;
  2419. $commercial->name = Input::get('name');
  2420. $commercial->ref = Input::get('ref');
  2421. $commercial->size = Input::get('size');
  2422. $commercial->region = Input::get('region');
  2423. $commercial->town = Input::get('town');
  2424. $commercial->contact_person = Input::get('contact_person');
  2425. $commercial->contact_email = Input::get('contact_email');
  2426. $commercial->contact_mobile = Input::get('contact_mobile');
  2427. $commercial->opCost = Input::get('opCost');
  2428. $commercial->for = 'Sale';
  2429. $commercial->description = Input::get('description');
  2430. $commercial->surburb = Input::get('surburb');
  2431. $commercial->propertType = Input::get('propertType');
  2432. if (Input::hasFile('image1')) {
  2433. $file = Input::file('image1');
  2434. $file->move('img/', $file->getClientOriginalName());
  2435. $commercial->image1 = 'img/' . $file->getClientOriginalName();
  2436. }
  2437. if (Input::hasFile('image2')) {
  2438. $file = Input::file('image2');
  2439. $file->move('img/', $file->getClientOriginalName());
  2440. $commercial->image2 = 'img/' . $file->getClientOriginalName();
  2441. }
  2442. $commercial->save();
  2443. $data = ['commercial' => $commercial];
  2444. Mail::send('emails.commercial-sale-listing', $data, function($message)
  2445. {
  2446. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New Commercial Property for sale Listing');
  2447. $message->from('info@univateproperties.co.za');
  2448. });
  2449. return Redirect::back()->with('view-success',' You have successfully submitted your property listing.');
  2450. }
  2451. public function backButtonCommercial($for)
  2452. {
  2453. $commercials = DB::table('commercials')
  2454. ->where('for','=',$for)
  2455. ->get();
  2456. return View::make('commercial-results')
  2457. ->with('commercials',$commercials)
  2458. ->with('for',$for);
  2459. }
  2460. public function backButtonResidential($for)
  2461. {
  2462. $residentials = DB::table('residentials')
  2463. ->where('for','=',$for)
  2464. ->get();
  2465. return View::make('residential-results')
  2466. ->with('residentials',$residentials)
  2467. ->with('for',$for);
  2468. }
  2469. public function serveCSI()
  2470. {
  2471. return View::make('csi');
  2472. }
  2473. public function back()
  2474. {
  2475. return redirect()->back();
  2476. }
  2477. public function officeParks()
  2478. {
  2479. $mooikloof = DB::table('commercials')
  2480. ->where('surburb','=','Mooikloof')
  2481. ->orderBy('created_at','asc')
  2482. ->get();
  2483. $query = 'Lombardy Business Park';
  2484. $lombardy = DB::table('commercials')
  2485. ->where('name', 'LIKE', '%' . $query . '%')
  2486. ->orderBy('created_at','asc')
  2487. ->get();
  2488. return View::make('office-parks')
  2489. ->with('mooikloof',$mooikloof)
  2490. ->with('lombardy',$lombardy);
  2491. }
  2492. public function Lombardy()
  2493. {
  2494. $lombardy = DB::table('commercials')
  2495. ->where('name','=','Lombardy Business Park')
  2496. ->where('for','=','rental')
  2497. ->orderBy('created_at','desc')
  2498. ->paginate(6);
  2499. $property = DB::table('commercials')
  2500. ->where('name','=','Lombardy Business Park')
  2501. ->orderBy('created_at','asc')
  2502. ->first();
  2503. $facilities = explode(',',$property->facilities);
  2504. return View::make('lombardy')
  2505. ->with('property',$property)
  2506. ->with('facilities',$facilities)
  2507. ->with('lombardy',$lombardy);
  2508. }
  2509. public function handleInterestedLombardy($id)
  2510. {
  2511. $unit = DB::table('commercials')
  2512. ->where('id','=',$id)
  2513. ->first();
  2514. $validator = Validator::make(Input::all(),
  2515. [
  2516. 'name' => 'required',
  2517. 'email' => 'required'
  2518. ]);
  2519. if($validator->fails())
  2520. {
  2521. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2522. }
  2523. $interested = new Interest;
  2524. $interested->name = Input::get('name');
  2525. $interested->email = Input::get('email');
  2526. $interested->phone = Input::get('phone');
  2527. $interested->mobile = Input::get('mobile');
  2528. $interested->save();
  2529. $data = ['interested' => $interested, 'unit' => $unit];
  2530. Mail::send('emails.interestedLombardy', $data, function($message)
  2531. {
  2532. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this unit at Lombardy Business Park');
  2533. $message->from('info@univateproperties.co.za');
  2534. });
  2535. return Redirect::back()->with('view-success','Enquiry submitted.');
  2536. }
  2537. public function Mooikloof()
  2538. {
  2539. $mooikloof = DB::table('commercials')
  2540. ->where('name','=','Mooikloof Office Park')
  2541. ->paginate(6);
  2542. $property = DB::table('commercials')
  2543. ->where('name','=','Mooikloof Office Park')
  2544. ->first();
  2545. $facilities = explode(',',$property->facilities);
  2546. return View::make('mooikloof')
  2547. ->with('property',$property)
  2548. ->with('facilities',$facilities)
  2549. ->with('mooikloof',$mooikloof);
  2550. }
  2551. public function handleInterestedMooikloof($id)
  2552. {
  2553. $unit = DB::table('commercials')
  2554. ->where('id','=',$id)
  2555. ->first();
  2556. $validator = Validator::make(Input::all(),
  2557. [
  2558. 'name' => 'required',
  2559. 'email' => 'required'
  2560. ]);
  2561. if($validator->fails())
  2562. {
  2563. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2564. }
  2565. $interested = new Interest;
  2566. $interested->name = Input::get('name');
  2567. $interested->email = Input::get('email');
  2568. $interested->phone = Input::get('phone');
  2569. $interested->mobile = Input::get('mobile');
  2570. $interested->save();
  2571. $data = ['interested' => $interested, 'unit' => $unit];
  2572. Mail::send('emails.interestedMooikloof', $data, function($message)
  2573. {
  2574. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this unit at Lombardy Business Park');
  2575. $message->from('info@univateproperties.co.za');
  2576. });
  2577. return Redirect::back()->with('view-success','Enquiry submitted.');
  2578. }
  2579. public function handleInterestProperty($id)
  2580. {
  2581. $unit = DB::table('commercials')
  2582. ->where('id','=',$id)
  2583. ->first();
  2584. $validator = Validator::make(Input::all(),
  2585. [
  2586. 'name' => 'required',
  2587. 'email' => 'required'
  2588. ]);
  2589. if($validator->fails())
  2590. {
  2591. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2592. }
  2593. $interested = new Interest;
  2594. $interested->name = Input::get('name');
  2595. $interested->email = Input::get('email');
  2596. $interested->phone = Input::get('phone');
  2597. $interested->mobile = Input::get('mobile');
  2598. $interested->save();
  2599. $data = ['interested' => $interested, 'unit' => $unit];
  2600. Mail::send('emails.interestedProperty', $data, function($message)
  2601. {
  2602. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this unit at Lombardy Business Park');
  2603. $message->from('info@univateproperties.co.za');
  2604. });
  2605. return Redirect::back()->with('view-success','Enquiry submitted.');
  2606. }
  2607. public function handleInterestProperty2($id)
  2608. {
  2609. $unit = DB::table('residentials')
  2610. ->where('id','=',$id)
  2611. ->first();
  2612. $validator = Validator::make(Input::all(),
  2613. [
  2614. 'name' => 'required',
  2615. 'email' => 'required'
  2616. ]);
  2617. if($validator->fails())
  2618. {
  2619. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2620. }
  2621. $interested = new Interest;
  2622. $interested->name = Input::get('name');
  2623. $interested->email = Input::get('email');
  2624. $interested->phone = Input::get('phone');
  2625. $interested->mobile = Input::get('mobile');
  2626. $interested->save();
  2627. $data = ['interested' => $interested, 'unit' => $unit];
  2628. Mail::send('emails.interestedProperty', $data, function($message)
  2629. {
  2630. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this unit at Lombardy Business Park');
  2631. $message->from('info@univateproperties.co.za');
  2632. });
  2633. return Redirect::back()->with('view-success','Enquiry submitted.');
  2634. }
  2635. public function serveTimeshareEnquiry($id)
  2636. {
  2637. $timeshare = DB::table('timeshares')
  2638. ->where('id','=',$id)
  2639. ->first();
  2640. $resort = DB::table('resorts')
  2641. ->where('resort','=',$timeshare->resort)
  2642. ->first();
  2643. return View::make('timeshare-enquiry')
  2644. ->with('resort',$resort)
  2645. ->with('timeshare',$timeshare);
  2646. }
  2647. public function handleTimeshareEnquiry($id)
  2648. {
  2649. $timeshare = DB::table('timeshares')
  2650. ->where('id','=',$id)
  2651. ->first();
  2652. $validator = Validator::make(Input::all(),
  2653. [
  2654. 'name' => 'required',
  2655. 'email' => 'required'
  2656. ]);
  2657. if($validator->fails())
  2658. {
  2659. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2660. }
  2661. $interested = new Interest;
  2662. $interested->name = Input::get('name');
  2663. $interested->email = Input::get('email');
  2664. $interested->mobile = Input::get('mobile');
  2665. $interested->save();
  2666. $data = ['interested' => $interested, 'timeshare' => $timeshare];
  2667. Mail::send('emails.interestedTimeshare', $data, function($message)
  2668. {
  2669. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this timeshare');
  2670. $message->from('info@univateproperties.co.za');
  2671. });
  2672. return Redirect::back()->with('view-success','Enquiry submitted.');
  2673. }
  2674. public function serveShareTransferInitiation()
  2675. {
  2676. return View::make('share-transfer-initiation-for-seller');
  2677. }
  2678. public function handleShareTransferIntiation()
  2679. {
  2680. $validator = Validator::make(Input::all(),
  2681. [
  2682. 'paid' => 'required',
  2683. 'spaceBanked' => 'required',
  2684. 'date' => 'required',
  2685. 'purchasePrice' => 'required',
  2686. 'sellingPrice' => 'required',
  2687. 'estateAgency' => 'required',
  2688. 'commission' => 'required'
  2689. ]);
  2690. if($validator->fails())
  2691. {
  2692. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2693. }
  2694. $seller = new Seller;
  2695. $seller->paid = Input::get('paid');
  2696. $seller->rental = Input::get('rental');
  2697. $seller->spaceBanked = Input::get('spaceBanked');
  2698. $seller->date = Input::get('date');
  2699. $seller->purchasePrice = Input::get('purchasePrice');
  2700. $seller->sellingPrice = Input::get('sellingPrice');
  2701. $seller->estateAgency = Input::get('estateAgency');
  2702. $seller->commission = Input::get('commission');
  2703. $seller->save();
  2704. $data = ['seller' => $seller];
  2705. Mail::send('emails.seller', $data, function($message)
  2706. {
  2707. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Share Transfer Intiation for Seller');
  2708. $message->from('info@univateproperties.co.za');
  2709. });
  2710. return Redirect::back()->with('view-success','Your information has been successfully been submitted.');
  2711. }
  2712. public function serveShareTransferInitiationForPurchaser($id)
  2713. {
  2714. $timeshare = DB::table('timeshares')
  2715. ->where('id','=',$id)
  2716. ->first();
  2717. $name = Auth::user()->name;
  2718. $surname = Auth::user()->surname;
  2719. $phone = Auth::user()->phone;
  2720. $cell = Auth::user()->mobile;
  2721. $email = Auth::user()->email;
  2722. return View::make('share-transfer-initiation-for-purchaser')
  2723. ->with('surname',$surname)
  2724. ->with('email',$email)
  2725. ->with('phone',$phone)
  2726. ->with('cell',$cell)
  2727. ->with('name',$name)
  2728. ->with('timeshare',$timeshare);
  2729. }
  2730. public function handleShareTransferInitiationForPurchaser($id)
  2731. {
  2732. $validator = Validator::make(Input::all(),
  2733. [
  2734. 'name' => 'required',
  2735. 'maritalStatus' => 'required',
  2736. 'physicalAddress' => 'required',
  2737. 'postalAddress' => 'required'
  2738. ]);
  2739. if($validator->fails())
  2740. {
  2741. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2742. }
  2743. $timeshare = DB::table('timeshares')
  2744. ->where('id','=',$id)
  2745. ->first();
  2746. $transfer = new Transfer;
  2747. $transfer->name = Auth::user()->name;
  2748. $transfer->IDNumber = Input::get('IDNumber');
  2749. $transfer->PassportNumber = Input::get('PassportNumber');
  2750. $transfer->maritalStatus = Input::get('maritalStatus');
  2751. $transfer->marriedIn = Input::get('marriedIn');
  2752. $transfer->otherMeans = Input::get('otherMeans');
  2753. $transfer->tax = Input::get('tax');
  2754. $transfer->annualIncome = Input::get('annualIncome');
  2755. $transfer->physicalAddress = Input::get('physicalAddress');
  2756. $transfer->postalAddress = Input::get('postalAddress');
  2757. $transfer->telephone1 = Auth::user()->phone;
  2758. $transfer->telephone2 = Input::get('telephone2');
  2759. $transfer->phone1 = Auth::user()->mobile;
  2760. $transfer->phone2 = Input::get('phone2');
  2761. $transfer->fax1 = Input::get('fax1');
  2762. $transfer->fax2 = Input::get('fax2');
  2763. $transfer->email1 = Auth::user()->email;
  2764. $transfer->email2 = Input::get('email2');
  2765. $transfer->resort = Input::get('resort');
  2766. $transfer->unit = Input::get('unit');
  2767. $transfer->module = Input::get('module');
  2768. $transfer->price = Input::get('price');
  2769. $transfer->year = Input::get('year');
  2770. $transfer->confirmInfo = Input::get('confirmInfo');
  2771. $transfer->sign = Input::get('sign');
  2772. $transfer->save();
  2773. DB::table('timeshares')
  2774. ->where('id','=', $id)
  2775. ->update(array(
  2776. 'status' => 'Offer Pending'
  2777. )
  2778. );
  2779. $data = ['transfer' => $transfer];
  2780. Mail::send('emails.transfer', $data, function($message)
  2781. {
  2782. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Share Transfer Intiation for Purchaser');
  2783. $message->from('info@univateproperties.co.za');
  2784. });
  2785. return Redirect::back()->with('view-success','Your information has been successfully been submitted.');
  2786. }
  2787. public function import()
  2788. {
  2789. config(['excel.import.startRow' => 1 ]);
  2790. Excel::import(new TimesharesImport, Input::file('ex_file'));
  2791. return Redirect::back()->with('view-success', 'Your import is successful!');
  2792. }
  2793. public function serveLombardyEnquiry($id)
  2794. {
  2795. $unit = DB::table('commercials')
  2796. ->where('id','=',$id)
  2797. ->first();
  2798. return View::make('lombardy-enquiry')
  2799. ->with('unit',$unit);
  2800. }
  2801. public function handleLombardyEnquiry($id)
  2802. {
  2803. $unit = DB::table('commercials')
  2804. ->where('id','=',$id)
  2805. ->first();
  2806. $validator = Validator::make(Input::all(),
  2807. [
  2808. 'name' => 'required',
  2809. 'email' => 'required'
  2810. ]);
  2811. if($validator->fails())
  2812. {
  2813. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2814. }
  2815. $interested = new Interest;
  2816. $interested->name = Input::get('name');
  2817. $interested->email = Input::get('email');
  2818. $interested->mobile = Input::get('mobile');
  2819. $interested->save();
  2820. $data = ['interested' => $interested, 'unit' => $unit];
  2821. Mail::send('emails.interestedLombardy', $data, function($message)
  2822. {
  2823. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in Lombardy Unit');
  2824. $message->from('info@univateproperties.co.za');
  2825. });
  2826. return Redirect::back()->with('view-success','Enquiry submitted.');
  2827. }
  2828. public function serveMooikloofEnquiry($id)
  2829. {
  2830. $unit = DB::table('commercials')
  2831. ->where('id','=',$id)
  2832. ->first();
  2833. return View::make('mooikloof-enquiry')
  2834. ->with('unit',$unit);
  2835. }
  2836. public function handleMooikloofEnquiry($id)
  2837. {
  2838. $unit = DB::table('commercials')
  2839. ->where('id','=',$id)
  2840. ->first();
  2841. $validator = Validator::make(Input::all(),
  2842. [
  2843. 'name' => 'required',
  2844. 'email' => 'required'
  2845. ]);
  2846. if($validator->fails())
  2847. {
  2848. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2849. }
  2850. $interested = new Interest;
  2851. $interested->name = Input::get('name');
  2852. $interested->email = Input::get('email');
  2853. $interested->mobile = Input::get('mobile');
  2854. $interested->save();
  2855. $data = ['interested' => $interested, 'unit' => $unit];
  2856. Mail::send('emails.interestedMooikloof', $data, function($message)
  2857. {
  2858. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in Mooikloof Unit');
  2859. $message->from('info@univateproperties.co.za');
  2860. });
  2861. return Redirect::back()->with('view-success','Enquiry submitted.');
  2862. }
  2863. public function makeOffer()
  2864. {
  2865. return View::make('share-transfer-initiation-for-purchaser');
  2866. }
  2867. public function serveSuccessfulPayment()
  2868. {
  2869. $bulk = DB::table('timeshare_bulk_uploads')
  2870. ->where('email','=',Auth::user()->email)
  2871. ->orderBy('id', 'desc')->first();
  2872. $user = DB::table('users')
  2873. ->where('id','=',Auth::user()->id)
  2874. ->first();
  2875. //dd($bulk);
  2876. if($bulk)
  2877. {
  2878. $timeshare = DB::table('timeshares')
  2879. ->where('email','=',$user->email)
  2880. ->orderBy('id', 'desc')->first();
  2881. $data = ['user' => $user, 'timeshare' => $timeshare];
  2882. Mail::send('emails.paymentReference', $data, function($message)
  2883. {
  2884. $message->to('info@univateproperties.co.za','Uni-vate')->to('brucel@uni-vision.co.za','Bruce Lynwood')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Successful Payment');
  2885. $message->from('info@univateproperties.co.za');
  2886. });
  2887. }
  2888. else{
  2889. $data = ['bulk' => $bulk, 'user' => $user];
  2890. DB::table('timeshare_bulk_uploads')
  2891. ->where('id','=', $bulk->id)
  2892. ->update(array(
  2893. 'listingFee' => 'Paid'
  2894. )
  2895. );
  2896. Mail::send('emails.paymentBulkReference', $data, function($message)
  2897. {
  2898. $message->to('info@univateproperties.co.za','Uni-vate')->to('brucel@uni-vision.co.za','Bruce Lynwood')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Successful Payment');
  2899. $message->from('info@univateproperties.co.za');
  2900. });
  2901. }
  2902. return View::make('successful-payment');
  2903. }
  2904. public function serveRegisterAgent()
  2905. {
  2906. return View::make('register-agent');
  2907. }
  2908. public function handleAgentRegister()
  2909. {
  2910. }
  2911. public function serveMyTimeshares()
  2912. {
  2913. $timeshares = DB::table('timeshares')
  2914. ->where('names','=',Auth::user()->name)
  2915. ->paginate(10);
  2916. return View::make('my-timeshares')
  2917. ->with('timeshares',$timeshares);
  2918. }
  2919. public function serveMyResidentialProperties()
  2920. {
  2921. $residentials = DB::table('residentials')
  2922. ->where('contact_person','=',Auth::user()->name)
  2923. ->paginate(10);
  2924. return View::make('my-residential-properties')
  2925. ->with('residentials',$residentials);
  2926. }
  2927. public function serveMyCommercialProperties()
  2928. {
  2929. $commercials = DB::table('commercials')
  2930. ->where('contact_person','=',Auth::user()->name)
  2931. ->paginate(10);
  2932. return View::make('my-commercial-properties')
  2933. ->with('commercials',$commercials);
  2934. }
  2935. public function serveRegisterTimeshareAgent()
  2936. {
  2937. $agencies = DB::table('agencies')
  2938. ->get();
  2939. return View::make('register-timeshare-agent')
  2940. ->with('agencies',$agencies);
  2941. }
  2942. public function handleRegisterTimeshareAgent()
  2943. {
  2944. $validator = Validator::make(Input::all(),
  2945. [
  2946. 'name' => 'required',
  2947. 'surname' => 'required',
  2948. 'email' => 'required',
  2949. 'username' => 'required'
  2950. ]);
  2951. if($validator->fails())
  2952. {
  2953. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2954. }
  2955. if((Input::get('password'))!=(Input::get('password1')))
  2956. {
  2957. return Redirect::back()->with('view-error', ' Passwords do not match')->withInput()->withErrors($validator);
  2958. }
  2959. $user = new User;
  2960. $user->name = Input::get('name');
  2961. $user->surname = Input::get('surname');
  2962. $user->email = Input::get('email');
  2963. $user->phone = Input::get('phone');
  2964. $user->mobile = Input::get('mobile');
  2965. $user->username = Input::get('username');
  2966. $user->password = Hash::make(Input::get('password'));
  2967. $user->agency = Auth::user()->agency;
  2968. $user->role = 'user';
  2969. $user->timeshare = '1';
  2970. $user->role = 'user';
  2971. $user->save();
  2972. $data = ['user' => $user];
  2973. Mail::send('emails.register', $data, function($message) use ($user)
  2974. {
  2975. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New registration on www.univateproperties.co.za');
  2976. $message->from('info@univateproperties.co.za');
  2977. });
  2978. return Redirect::to('timeshare-agents')->with('view-success','You have successfully registered an agent.');
  2979. }
  2980. public function serveTimeshareAgents()
  2981. {
  2982. $myAgency = Auth::user()->agency;
  2983. $agents = DB::table('users')
  2984. ->where('agency','=',$myAgency)
  2985. ->paginate(10);
  2986. return View::make('timeshare-agents')
  2987. ->with('agents',$agents);
  2988. }
  2989. public function serveRegisterCommercialAgent()
  2990. {
  2991. return View::make('register-commercial-agent');
  2992. }
  2993. public function handleRegisterCommercialAgent()
  2994. {
  2995. $validator = Validator::make(Input::all(),
  2996. [
  2997. 'EAAB-FFC-Number' => 'required',
  2998. 'agency' => 'required',
  2999. 'registrationNum' => 'required'
  3000. ]);
  3001. if($validator->fails())
  3002. {
  3003. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  3004. }
  3005. if((Input::get('password'))!=(Input::get('password1')))
  3006. {
  3007. return Redirect::back()->with('view-error', ' Passwords do not match')->withInput()->withErrors($validator);
  3008. }
  3009. if(!Auth::check())
  3010. {
  3011. $user = new User;
  3012. $user->name = Input::get('name');
  3013. $user->surname = Input::get('surname');
  3014. $user->email = Input::get('email');
  3015. $user->phone = Input::get('phone');
  3016. $user->mobile = Input::get('mobile');
  3017. $user->username = Input::get('username');
  3018. $user->password = Hash::make(Input::get('password'));
  3019. $user->EAAB_FFC_Number = Input::get('EAAB-FFC-Number');
  3020. $user->agency = Input::get('agency');
  3021. $user->registrationNum = Input::get('registrationNum');
  3022. $user->commercial = '1';
  3023. $user->role = 'user';
  3024. $user->save();
  3025. $data = ['user' => $user];
  3026. Mail::send('emails.register', $data, function($message) use ($user)
  3027. {
  3028. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New registration on www.univateproperties.co.za');
  3029. $message->from('info@univateproperties.co.za');
  3030. });
  3031. }
  3032. else{
  3033. $users = DB::table('users')
  3034. ->get();
  3035. /*
  3036. foreach($users as $user){
  3037. if($user->username == Input::get('username'))
  3038. return Redirect::back()->with('view-error', ' This username already exists, please try a different username.')->withInput()->withErrors($validator);
  3039. }
  3040. foreach($users as $user){
  3041. if($user->email == Input::get('email'))
  3042. return Redirect::back()->with('view-error', ' This email account already exists, please login.')->withInput()->withErrors($validator);
  3043. } */
  3044. $user = DB::table('users')
  3045. ->where('id','=',Auth::user()->id)
  3046. ->first();
  3047. DB::table('users')
  3048. ->where('id','=', Auth::user()->id)
  3049. ->update(array(
  3050. 'EAAB_FFC_Number' => Input::get('EAAB-FFC-Number')
  3051. )
  3052. );
  3053. DB::table('users')
  3054. ->where('id','=', Auth::user()->id)
  3055. ->update(array(
  3056. 'agency' => Input::get('agency')
  3057. )
  3058. );
  3059. DB::table('users')
  3060. ->where('id','=', Auth::user()->id)
  3061. ->update(array(
  3062. 'registrationNum' => Input::get('registrationNum')
  3063. )
  3064. );
  3065. }
  3066. return Redirect::back()->with('view-success','You have successfully registered.');
  3067. }
  3068. public function serveCommercialAgents()
  3069. {
  3070. $agents = DB::table('users')
  3071. ->where('commercial','=','1')
  3072. ->paginate(10);
  3073. if (Auth::check() && Auth::user()->role == "admin") {
  3074. return View::make('commercial-agents')
  3075. ->with('agents',$agents);
  3076. }else{
  3077. return Redirect::to('/');
  3078. }
  3079. }
  3080. public function serveRegisterResidentialAgent()
  3081. {/*
  3082. $user = new User;
  3083. $user->name = 'Arlene';
  3084. $user->email = 'admin1@univateproperties.co.za';
  3085. $user->phone ='+27 (0) 12 492 1238';
  3086. $user->mobile = '+27 (0) 12 492 1238';
  3087. $user->surname = '';
  3088. $user->username = 'Admin1';
  3089. $user->password = Hash::make('Admin1');
  3090. $user->role = 'admin';
  3091. $user->save();
  3092. $user1 = new User;
  3093. $user1->name = 'Caitlinf';
  3094. $user1->email = 'admin2@univateproperties.co.za';
  3095. $user1->phone = '+27 (0) 12 492 1238';
  3096. $user1->mobile = '+27 (0) 12 492 1238';
  3097. $user1->surname = '';
  3098. $user1->username = 'Admin2';
  3099. $user1->password = Hash::make('Admin2');
  3100. $user1->role = 'admin';
  3101. $user1->save(); */
  3102. return View::make('register-residential-agent');
  3103. }
  3104. public function handleRegisterResidentialAgent()
  3105. {
  3106. $validator = Validator::make(Input::all(),
  3107. [
  3108. 'EAAB-FFC-Number' => 'required',
  3109. 'agency' => 'required',
  3110. 'registrationNum' => 'required'
  3111. ]);
  3112. if($validator->fails())
  3113. {
  3114. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  3115. }
  3116. if((Input::get('password'))!=(Input::get('password1')))
  3117. {
  3118. return Redirect::back()->with('view-error', ' Passwords do not match')->withInput()->withErrors($validator);
  3119. }
  3120. if(!Auth::check())
  3121. {
  3122. $user = new User;
  3123. $user->name = Input::get('name');
  3124. $user->email = Input::get('email');
  3125. $user->phone = Input::get('phone');
  3126. $user->mobile = Input::get('mobile');
  3127. $user->username = Input::get('username');
  3128. $user->password = Hash::make(Input::get('password'));
  3129. $user->EAAB_FFC_Number = Input::get('EAAB-FFC-Number');
  3130. $user->agency = Input::get('agency');
  3131. $user->registrationNum = Input::get('registrationNum');
  3132. $user->residential = '1';
  3133. $user->role = 'user';
  3134. $user->save();
  3135. $data = ['user' => $user];
  3136. Mail::send('emails.register', $data, function($message) use ($user)
  3137. {
  3138. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New registration on www.univateproperties.co.za');
  3139. $message->from('info@univateproperties.co.za');
  3140. });
  3141. }
  3142. else{
  3143. $users = DB::table('users')
  3144. ->get();
  3145. /*
  3146. foreach($users as $user){
  3147. if($user->username == Input::get('username'))
  3148. return Redirect::back()->with('view-error', ' This username already exists, please try a different username.')->withInput()->withErrors($validator);
  3149. }
  3150. foreach($users as $user){
  3151. if($user->email == Input::get('email'))
  3152. return Redirect::back()->with('view-error', ' This email account already exists, please login.')->withInput()->withErrors($validator);
  3153. } */
  3154. $user = DB::table('users')
  3155. ->where('id','=',Auth::user()->id)
  3156. ->first();
  3157. DB::table('users')
  3158. ->where('id','=', Auth::user()->id)
  3159. ->update(array(
  3160. 'EAAB_FFC_Number' => Input::get('EAAB-FFC-Number')
  3161. )
  3162. );
  3163. DB::table('users')
  3164. ->where('id','=', Auth::user()->id)
  3165. ->update(array(
  3166. 'agency' => Input::get('agency')
  3167. )
  3168. );
  3169. DB::table('users')
  3170. ->where('id','=', Auth::user()->id)
  3171. ->update(array(
  3172. 'registrationNum' => Input::get('registrationNum')
  3173. )
  3174. );
  3175. }
  3176. return Redirect::back()->with('view-success','You have successfully registered.');
  3177. }
  3178. public function serveResidentialAgents()
  3179. {
  3180. $agents = DB::table('users')
  3181. ->where('residential','=','1')
  3182. ->paginate(10);
  3183. if (Auth::check() && Auth::user()->role == "admin") {
  3184. return View::make('residential-agents')
  3185. ->with('agents',$agents);
  3186. }else{
  3187. return Redirect::to('/');
  3188. }
  3189. }
  3190. public function serveRegisterAgency()
  3191. {
  3192. return View::make('register-agency');
  3193. }
  3194. public function handleRegisterAgency()
  3195. {
  3196. $validator = Validator::make(Input::all(),
  3197. [
  3198. 'EAAB-FFC-Number' => 'required',
  3199. 'agency' => 'required',
  3200. 'registrationNum' => 'required',
  3201. 'name' => 'required',
  3202. 'surname' => 'required',
  3203. 'email' => 'required',
  3204. 'phone' => 'required',
  3205. 'mobile' => 'required',
  3206. 'username' => 'required'
  3207. ]);
  3208. if($validator->fails())
  3209. {
  3210. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  3211. }
  3212. if((Input::get('password'))!=(Input::get('password1')))
  3213. {
  3214. return Redirect::back()->with('view-error', ' Passwords do not match')->withInput()->withErrors($validator);
  3215. }
  3216. $user = new User;
  3217. $user->name = Input::get('name');
  3218. $user->email = Input::get('email');
  3219. $user->phone = Input::get('phone');
  3220. $user->mobile = Input::get('mobile');
  3221. $user->surname = Input::get('surname');
  3222. $user->username = Input::get('username');
  3223. $user->password = Hash::make(Input::get('password'));
  3224. $user->agencyAdmin = 'YES';
  3225. $user->agency = Input::get('agency');
  3226. $user->role = 'agency admin';
  3227. $user->save();
  3228. $agency = new Agency;
  3229. $agency->EAAB_FFC_Number = Input::get('EAAB-FFC-Number');
  3230. $agency->agency = Input::get('agency');
  3231. $agency->registrationNum = Input::get('registrationNum');
  3232. $agency->save();
  3233. $data = ['agency' => $agency, 'user' => $user];
  3234. Mail::send('emails.register-agency', $data, function($message) use ($user)
  3235. {
  3236. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New agency registration');
  3237. $message->from('info@univateproperties.co.za');
  3238. });
  3239. return Redirect::to('/')->with('view-success','You have successfully registered your agency. Proceed to login and add agents under your agency');
  3240. }
  3241. public function serveAllAgents()
  3242. {
  3243. $agents = DB::table('users')
  3244. ->where('agency','!=',NULL)
  3245. ->paginate(10);
  3246. if (Auth::check() && Auth::user()->role == "admin") {
  3247. return View::make('admin.all-agents')
  3248. ->with('agents',$agents);
  3249. }else{
  3250. return Redirect::to('/');
  3251. }
  3252. }
  3253. public function serveAllAgencies()
  3254. {
  3255. $agencies = DB::table('agencies')
  3256. ->paginate(10);
  3257. if (Auth::check() && Auth::user()->role == "admin") {
  3258. return View::make('admin.all-agencies')
  3259. ->with('agencies',$agencies);
  3260. }else{
  3261. return Redirect::to('/');
  3262. }
  3263. }
  3264. public function serveAllCommercialProperties()
  3265. {
  3266. $commercials = DB::table('commercials')
  3267. ->paginate(10);
  3268. if (Auth::check() && Auth::user()->role == "admin") {
  3269. return View::make('admin.all-commercial-properties')
  3270. ->with('commercials',$commercials);
  3271. }else{
  3272. return Redirect::to('/');
  3273. }
  3274. }
  3275. public function serveAllResidentialProperties()
  3276. {
  3277. $residentials = DB::table('residentials')
  3278. ->paginate(10);
  3279. if (Auth::check() && Auth::user()->role == "admin") {
  3280. return View::make('admin.all-residential-properties')
  3281. ->with('residentials',$residentials);
  3282. }else{
  3283. return Redirect::to('/');
  3284. }
  3285. }
  3286. public function editAgent($id)
  3287. {
  3288. $user = DB::table('users')
  3289. ->where('id','=',$id)
  3290. ->first();
  3291. return View::make('admin.edit-agent')
  3292. ->with('user',$user);
  3293. }
  3294. public function publishAgent($id)
  3295. {
  3296. DB::table('users')
  3297. ->where('id','=', $id)
  3298. ->update(array(
  3299. 'agent_publish' => 1
  3300. )
  3301. );
  3302. return Redirect::back()->withInput()->with('view-success', 'Agent is successfully verified.');
  3303. }
  3304. public function deleteAgent($id)
  3305. {
  3306. DB::table('users')
  3307. ->where('id','=',$id)
  3308. ->delete();
  3309. return Redirect::back()->with('view-success', ' SUCCESS: Agent Deleted');
  3310. }
  3311. public function deleteAgency($id)
  3312. {
  3313. DB::table('agencies')
  3314. ->where('id','=',$id)
  3315. ->delete();
  3316. return Redirect::back()->with('view-success', ' SUCCESS: Agency Deleted');
  3317. }
  3318. public function handleEditAgent($id)
  3319. {
  3320. $validator = Validator::make(Input::all(),
  3321. [
  3322. 'name' => 'required',
  3323. 'email' => 'required'
  3324. ]);
  3325. if($validator->fails())
  3326. {
  3327. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  3328. }
  3329. DB::table('users')
  3330. ->where('id','=', $id)
  3331. ->update(array(
  3332. 'name' => Input::get('name')
  3333. )
  3334. );
  3335. DB::table('users')
  3336. ->where('id','=', $id)
  3337. ->update(array(
  3338. 'surname' => Input::get('surname')
  3339. )
  3340. );
  3341. DB::table('users')
  3342. ->where('id','=', $id)
  3343. ->update(array(
  3344. 'email' => Input::get('email')
  3345. )
  3346. );
  3347. DB::table('users')
  3348. ->where('id','=', $id)
  3349. ->update(array(
  3350. 'phone' => Input::get('tel')
  3351. )
  3352. );
  3353. DB::table('users')
  3354. ->where('id','=', $id)
  3355. ->update(array(
  3356. 'mobile' => Input::get('cell')
  3357. )
  3358. );
  3359. return Redirect::to('all-agents')->with('view-success',"You have successfully updated agent's details");
  3360. }
  3361. public function serveEditAgency($id)
  3362. {
  3363. $agency = DB::table('agencies')
  3364. ->where('id','=',$id)
  3365. ->first();
  3366. $user = DB::table('users')
  3367. ->where('agency','=',$agency->agency)
  3368. ->first();
  3369. return View::make('admin.edit-agency')
  3370. ->with('user',$user)
  3371. ->with('agency',$agency);
  3372. }
  3373. public function handleEditAgency($id)
  3374. {
  3375. $agency = DB::table('agencies')
  3376. ->where('id','=',$id)
  3377. ->first();
  3378. $user = DB::table('users')
  3379. ->where('agency','=',$agency->agency)
  3380. ->first();
  3381. $validator = Validator::make(Input::all(),
  3382. [
  3383. 'name' => 'required',
  3384. 'agency' => 'required'
  3385. ]);
  3386. if($validator->fails())
  3387. {
  3388. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  3389. }
  3390. DB::table('users')
  3391. ->where('id','=', $id)
  3392. ->update(array(
  3393. 'name' => Input::get('name')
  3394. )
  3395. );
  3396. DB::table('users')
  3397. ->where('id','=', $id)
  3398. ->update(array(
  3399. 'surname' => Input::get('surname')
  3400. )
  3401. );
  3402. DB::table('users')
  3403. ->where('id','=', $id)
  3404. ->update(array(
  3405. 'email' => Input::get('email')
  3406. )
  3407. );
  3408. DB::table('users')
  3409. ->where('id','=', $id)
  3410. ->update(array(
  3411. 'phone' => Input::get('phone')
  3412. )
  3413. );
  3414. DB::table('users')
  3415. ->where('id','=', $id)
  3416. ->update(array(
  3417. 'mobile' => Input::get('mobile')
  3418. )
  3419. );
  3420. DB::table('agencies')
  3421. ->where('id','=', $agency->id)
  3422. ->update(array(
  3423. 'EAAB_FFC_Number' => Input::get('EAAB-FFC-Number')
  3424. )
  3425. );
  3426. DB::table('agencies')
  3427. ->where('id','=', $agency->id)
  3428. ->update(array(
  3429. 'registrationNum' => Input::get('registrationNum')
  3430. )
  3431. );
  3432. DB::table('agencies')
  3433. ->where('id','=', $agency->id)
  3434. ->update(array(
  3435. 'agency' => Input::get('agency')
  3436. )
  3437. );
  3438. return Redirect::to('all-agencies')->with('view-success',"You have successfully updated your agency details");
  3439. }
  3440. public function contract()
  3441. {
  3442. return View::make('contract');
  3443. }
  3444. public function serveEditMyTimeshare($id)
  3445. {
  3446. $timeshare = DB::table('timeshares')
  3447. ->where('id','=',$id)
  3448. ->first();
  3449. return View::make('edit-my-timeshare')
  3450. ->with('timeshare',$timeshare);
  3451. }
  3452. public function handleEditMyTimeshare($id)
  3453. {
  3454. $timeshare = DB::table('timeshares')
  3455. ->where('id','=',$id)
  3456. ->first();
  3457. $validator = Validator::make(Input::all(),
  3458. [
  3459. 'resort' => 'required',
  3460. 'module' => 'required',
  3461. 'week' => 'required',
  3462. 'bedrooms' => 'required'
  3463. ]);
  3464. if($validator->fails())
  3465. {
  3466. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  3467. }
  3468. /*
  3469. DB::table('timeshares')
  3470. ->where('id','=', $id)
  3471. ->update(array(
  3472. 'resort' => Input::get('resort')
  3473. )
  3474. );
  3475. DB::table('timeshares')
  3476. ->where('id','=', $id)
  3477. ->update(array(
  3478. 'module' => Input::get('module')
  3479. )
  3480. );
  3481. DB::table('timeshares')
  3482. ->where('id','=', $id)
  3483. ->update(array(
  3484. 'week' => Input::get('week')
  3485. )
  3486. );
  3487. DB::table('timeshares')
  3488. ->where('id','=', $id)
  3489. ->update(array(
  3490. 'season' => Input::get('season')
  3491. )
  3492. );
  3493. DB::table('timeshares')
  3494. ->where('id','=', $id)
  3495. ->update(array(
  3496. 'region' => Input::get('region')
  3497. )
  3498. );
  3499. DB::table('timeshares')
  3500. ->where('id','=', $id)
  3501. ->update(array(
  3502. 'setPrice' => Input::get('setPrice')
  3503. )
  3504. );
  3505. DB::table('timeshares')
  3506. ->where('id','=', $id)
  3507. ->update(array(
  3508. 'bedrooms' => Input::get('bedrooms')
  3509. )
  3510. );
  3511. DB::table('timeshares')
  3512. ->where('id','=', $id)
  3513. ->update(array(
  3514. 'sleeps' => Input::get('sleeps')
  3515. )
  3516. );
  3517. DB::table('timeshares')
  3518. ->where('id','=', $id)
  3519. ->update(array(
  3520. 'unit' => Input::get('unit')
  3521. )
  3522. );
  3523. DB::table('timeshares')
  3524. ->where('id','=', $id)
  3525. ->update(array(
  3526. 'owner' => Input::get('owner')
  3527. )
  3528. );
  3529. DB::table('timeshares')
  3530. ->where('id','=', $id)
  3531. ->update(array(
  3532. 'spacebankedyear' => Input::get('spacebankedyear')
  3533. )
  3534. );
  3535. DB::table('timeshares')
  3536. ->where('id','=', $id)
  3537. ->update(array(
  3538. 'spacebankOwner' => Input::get('spacebankOwner')
  3539. )
  3540. );
  3541. if(Input::get('publish')!='NULL') {
  3542. DB::table('timeshares')
  3543. ->where('id','=', $id)
  3544. ->update(array(
  3545. 'published' => Input::get('publish')
  3546. )
  3547. );
  3548. }
  3549. if(Input::has('statusDate')) {
  3550. DB::table('timeshares')
  3551. ->where('id','=', $id)
  3552. ->update(array(
  3553. 'statusDate' => Input::get('statusDate')
  3554. )
  3555. );
  3556. } */
  3557. if(Input::get('price')!=$timeshare->price)
  3558. {
  3559. DB::table('timeshares')
  3560. ->where('id','=', $id)
  3561. ->update(array(
  3562. 'price' => Input::get('price')
  3563. )
  3564. );
  3565. $log = new TimeshareLog;
  3566. $log->user_id = Auth::user()->id;
  3567. $log->timeshare_id = $timeshare->id;
  3568. $log->change = 'The asking price was changed from '.$timeshare->price.' to '.Input::get('price');
  3569. $log->save();
  3570. }
  3571. return Redirect::to('my-timeshares')->with('view-success',' Timeshare successfully updated');
  3572. }
  3573. public function serveEditMyCommercialProperty($id)
  3574. {
  3575. $commercial = DB::table('commercials')
  3576. ->where('id','=',$id)
  3577. ->first();
  3578. return View::make('edit-my-commercial-property')
  3579. ->with('commercial',$commercial);
  3580. }
  3581. public function handleEditMyCommercialProperty($id)
  3582. {
  3583. $validator = Validator::make(Input::all(),
  3584. [
  3585. 'name' => 'required'
  3586. ]);
  3587. if($validator->fails())
  3588. {
  3589. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  3590. }
  3591. DB::table('commercials')
  3592. ->where('id','=', $id)
  3593. ->update(array(
  3594. 'name' => Input::get('name')
  3595. )
  3596. );
  3597. DB::table('commercials')
  3598. ->where('id','=', $id)
  3599. ->update(array(
  3600. 'address' => Input::get('address')
  3601. )
  3602. );
  3603. DB::table('commercials')
  3604. ->where('id','=', $id)
  3605. ->update(array(
  3606. 'region' => Input::get('region')
  3607. )
  3608. );
  3609. DB::table('commercials')
  3610. ->where('id','=', $id)
  3611. ->update(array(
  3612. 'town' => Input::get('town')
  3613. )
  3614. );
  3615. DB::table('commercials')
  3616. ->where('id','=', $id)
  3617. ->update(array(
  3618. 'status2' => Input::get('status2')
  3619. )
  3620. );
  3621. DB::table('commercials')
  3622. ->where('id','=', $id)
  3623. ->update(array(
  3624. 'surburb' => Input::get('surburb')
  3625. )
  3626. );
  3627. DB::table('commercials')
  3628. ->where('id','=', $id)
  3629. ->update(array(
  3630. 'unit' => Input::get('unit')
  3631. )
  3632. );
  3633. DB::table('commercials')
  3634. ->where('id','=', $id)
  3635. ->update(array(
  3636. 'size' => Input::get('size')
  3637. )
  3638. );
  3639. DB::table('commercials')
  3640. ->where('id','=', $id)
  3641. ->update(array(
  3642. 'price' => Input::get('price')
  3643. )
  3644. );
  3645. DB::table('commercials')
  3646. ->where('id','=', $id)
  3647. ->update(array(
  3648. 'description' => Input::get('description')
  3649. )
  3650. );
  3651. DB::table('commercials')
  3652. ->where('id','=', $id)
  3653. ->update(array(
  3654. 'contact_person' => Input::get('contact_person')
  3655. )
  3656. );
  3657. DB::table('commercials')
  3658. ->where('id','=', $id)
  3659. ->update(array(
  3660. 'contact_email' => Input::get('contact_email')
  3661. )
  3662. );
  3663. DB::table('commercials')
  3664. ->where('id','=', $id)
  3665. ->update(array(
  3666. 'contact_mobile' => Input::get('contact_mobile')
  3667. )
  3668. );
  3669. DB::table('commercials')
  3670. ->where('id','=', $id)
  3671. ->update(array(
  3672. 'propertType' => Input::get('propertType')
  3673. )
  3674. );
  3675. return Redirect::to('my-commercial-properties')->with('view-success',' Commercial property successfully updated');
  3676. }
  3677. public function serveEditMyResidentialProperty($id)
  3678. {
  3679. $residential = DB::table('residentials')
  3680. ->where('id','=',$id)
  3681. ->first();
  3682. return View::make('edit-my-residential-property')
  3683. ->with('residential',$residential);
  3684. }
  3685. public function handleEditMyResidentialProperty($id)
  3686. {
  3687. $validator = Validator::make(Input::all(),
  3688. [
  3689. 'name' => 'required'
  3690. ]);
  3691. if($validator->fails())
  3692. {
  3693. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  3694. }
  3695. DB::table('residentials')
  3696. ->where('id','=', $id)
  3697. ->update(array(
  3698. 'name' => Input::get('name')
  3699. )
  3700. );
  3701. DB::table('residentials')
  3702. ->where('id','=', $id)
  3703. ->update(array(
  3704. 'address' => Input::get('address')
  3705. )
  3706. );
  3707. if(Input::get('region')!='') {
  3708. DB::table('residentials')
  3709. ->where('id','=', $id)
  3710. ->update(array(
  3711. 'region' => Input::get('region')
  3712. )
  3713. );
  3714. }
  3715. if(Input::get('town')!='') {
  3716. DB::table('residentials')
  3717. ->where('id','=', $id)
  3718. ->update(array(
  3719. 'town' => Input::get('town')
  3720. )
  3721. );
  3722. }
  3723. if(Input::get('status2')!='') {
  3724. DB::table('residentials')
  3725. ->where('id','=', $id)
  3726. ->update(array(
  3727. 'status2' => Input::get('status2')
  3728. )
  3729. );
  3730. }
  3731. if(Input::get('status')!='') {
  3732. DB::table('residentials')
  3733. ->where('id','=', $id)
  3734. ->update(array(
  3735. 'status' => Input::get('status')
  3736. )
  3737. );
  3738. }
  3739. if(Input::get('surburb')!='') {
  3740. DB::table('residentials')
  3741. ->where('id','=', $id)
  3742. ->update(array(
  3743. 'surburb' => Input::get('surburb')
  3744. )
  3745. );
  3746. }
  3747. DB::table('residentials')
  3748. ->where('id','=', $id)
  3749. ->update(array(
  3750. 'unit' => Input::get('unit')
  3751. )
  3752. );
  3753. DB::table('residentials')
  3754. ->where('id','=', $id)
  3755. ->update(array(
  3756. 'size' => Input::get('size')
  3757. )
  3758. );
  3759. DB::table('residentials')
  3760. ->where('id','=', $id)
  3761. ->update(array(
  3762. 'price' => Input::get('price')
  3763. )
  3764. );
  3765. DB::table('residentials')
  3766. ->where('id','=', $id)
  3767. ->update(array(
  3768. 'description' => Input::get('description')
  3769. )
  3770. );
  3771. DB::table('residentials')
  3772. ->where('id','=', $id)
  3773. ->update(array(
  3774. 'contact_person' => Input::get('contact_person')
  3775. )
  3776. );
  3777. DB::table('residentials')
  3778. ->where('id','=', $id)
  3779. ->update(array(
  3780. 'contact_email' => Input::get('contact_email')
  3781. )
  3782. );
  3783. DB::table('residentials')
  3784. ->where('id','=', $id)
  3785. ->update(array(
  3786. 'contact_mobile' => Input::get('contact_mobile')
  3787. )
  3788. );
  3789. DB::table('residentials')
  3790. ->where('id','=', $id)
  3791. ->update(array(
  3792. 'bedrooms' => Input::get('bedrooms')
  3793. )
  3794. );
  3795. DB::table('residentials')
  3796. ->where('id','=', $id)
  3797. ->update(array(
  3798. 'bathrooms' => Input::get('bathrooms')
  3799. )
  3800. );
  3801. if(Input::get('propertType')!='') {
  3802. DB::table('residentials')
  3803. ->where('id','=', $id)
  3804. ->update(array(
  3805. 'propertType' => Input::get('propertType')
  3806. )
  3807. );
  3808. }
  3809. return Redirect::to('my-residential-properties')->with('view-success',' Residential property successfully updated');
  3810. }
  3811. public function serveManageAgencyTimeshares()
  3812. {
  3813. $timeshares = DB::table('timeshares')
  3814. ->where('agency','=',Auth::user()->agency)
  3815. ->orderBy('resort','asc')
  3816. ->paginate(10);
  3817. if (Auth::check() && Auth::user()->role == "agency admin") {
  3818. return View::make('manage-agency-timeshares')
  3819. ->with('timeshares',$timeshares);
  3820. }else{
  3821. return Redirect::to('/');
  3822. }
  3823. }
  3824. public function serveAllAgencyListings()
  3825. {
  3826. $timeshares = DB::table('timeshares')
  3827. ->where('agency','=',Auth::user()->agency)
  3828. ->orderBy('resort','asc')
  3829. ->paginate(10);
  3830. if (Auth::check()) {
  3831. return View::make('view-all-timeshares')
  3832. ->with('timeshares',$timeshares);
  3833. }else{
  3834. return Redirect::to('/');
  3835. }
  3836. }
  3837. public function servePreListedWeeks()
  3838. {
  3839. $timeshares = DB::table('timeshares')
  3840. ->where('owner','=','UB')
  3841. ->where('pre_selected','=',0)
  3842. ->where('chosen','=',NULL)
  3843. ->paginate(10);
  3844. return View::make('pre-listed-weeks')
  3845. ->with('timeshares',$timeshares);
  3846. }
  3847. public function handlePreListedWeeks()
  3848. {
  3849. $selected = Input::get('selected');
  3850. foreach($selected as $id)
  3851. {
  3852. DB::table('timeshares')
  3853. ->where('id','=', $id)
  3854. ->update(array(
  3855. 'chosen' => Auth::user()->agency
  3856. )
  3857. );
  3858. DB::table('timeshares')
  3859. ->where('id','=', $id)
  3860. ->update(array(
  3861. 'pre_selected' => 1
  3862. )
  3863. );
  3864. }
  3865. $selectedWeeks = NULL;
  3866. foreach($selected as $id)
  3867. {
  3868. $selectedWeeks = DB::table('timeshares')
  3869. ->where('id','=',$id)
  3870. ->get();
  3871. }
  3872. $agency = Auth::user()->agency;
  3873. $data = ['selectedWeeks' => $selectedWeeks, 'agency' => $agency];
  3874. Mail::send('emails.pre-select', $data, function($message)
  3875. {
  3876. $message->to('brucel@uni-vision.co.za','Bruce Lynwood')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Tender weeks selected');
  3877. $message->from('info@univateproperties.co.za');
  3878. });
  3879. return Redirect::to('pre-listed-weeks')->with('view-success','Your selection of timeshares has now been sent for authorisation.');
  3880. }
  3881. public function prelistAcessList()
  3882. {
  3883. $agencies = DB::table('users')
  3884. ->where('agencyAdmin','=','YES')
  3885. ->where('agency','!=',NULL)
  3886. ->paginate(10);
  3887. return View::make('admin.pre-list-access')
  3888. ->with('agencies',$agencies);
  3889. }
  3890. public function givePrelistAccess($id)
  3891. {
  3892. DB::table('users')
  3893. ->where('id','=', $id)
  3894. ->update(array(
  3895. 'access_prelist' => 1
  3896. )
  3897. );
  3898. //testers
  3899. return Redirect::back()->with('view-success','Access Granted.');
  3900. }
  3901. public function revokePrelistAccess($id)
  3902. {
  3903. DB::table('users')
  3904. ->where('id','=', $id)
  3905. ->update(array(
  3906. 'access_prelist' => 0
  3907. )
  3908. );
  3909. return Redirect::back()->with('view-success','Access Revoked.');
  3910. }
  3911. public function verifyTimeshare($id)
  3912. {
  3913. DB::table('timeshares')
  3914. ->where('id','=', $id)
  3915. ->update(array(
  3916. 'verified' => 1
  3917. )
  3918. );
  3919. return Redirect::back()->withInput()->with('view-success', 'Timeshare has been successfully verified.');
  3920. }
  3921. public function serveSelctedPreListedWeeks()
  3922. {
  3923. $timeshares = DB::table('timeshares')
  3924. ->where('owner','=','Lengen')
  3925. ->where('pre_selected','=',0)
  3926. ->paginate(10);
  3927. return View::make('authorise-pre-listed-weeks')
  3928. ->with('timeshares',$timeshares);
  3929. }
  3930. public function handleAuthorisePreselectedWeeks()
  3931. {
  3932. }
  3933. public function serveNewResort()
  3934. {
  3935. return View::make('new-resort');
  3936. }
  3937. public function filterWeeks($slug)
  3938. {
  3939. $resort = DB::table('resorts')
  3940. ->where('slug','=',$slug)
  3941. ->first();
  3942. $awards = explode(',',$resort->awards);
  3943. $facilities = explode(',',$resort->facilities);
  3944. //$start = \DateTime::createFromFormat('m-d-Y', Input::get('from'))->format('Y-m-d');
  3945. // $end = \DateTime::createFromFormat('m-d-Y', Input::get('to'))->format('Y-m-d');
  3946. // Timeshare::whereDate('exam_date', '>=', Carbon::now()->toDateString());
  3947. $timeshares = Timeshare::whereBetween(DB::raw('DATE(fromDate)'), array(Input::get('from'), Input::get('to')))->paginate(10);
  3948. return View::make('filtered-weeks')
  3949. ->with('resort',$resort)
  3950. ->with('awards',$awards)
  3951. ->with('facilities',$facilities)
  3952. ->with('timeshares',$timeshares);
  3953. }
  3954. public function serveEditProfile($id)
  3955. {
  3956. $user = DB::table('users')
  3957. ->where('id','=',$id)
  3958. ->first();
  3959. return View::make('update-profile')
  3960. ->with('user',$user);
  3961. }
  3962. public function handleEditProfile($id)
  3963. {
  3964. $validator = Validator::make(Input::all(),
  3965. [
  3966. 'name' => 'required',
  3967. 'email' => 'required'
  3968. ]);
  3969. if($validator->fails())
  3970. {
  3971. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  3972. }
  3973. DB::table('users')
  3974. ->where('id','=', $id)
  3975. ->update(array(
  3976. 'name' => Input::get('name')
  3977. )
  3978. );
  3979. DB::table('users')
  3980. ->where('id','=', $id)
  3981. ->update(array(
  3982. 'surname' => Input::get('surname')
  3983. )
  3984. );
  3985. DB::table('users')
  3986. ->where('id','=', $id)
  3987. ->update(array(
  3988. 'email' => Input::get('email')
  3989. )
  3990. );
  3991. DB::table('users')
  3992. ->where('id','=', $id)
  3993. ->update(array(
  3994. 'phone' => Input::get('tel')
  3995. )
  3996. );
  3997. DB::table('users')
  3998. ->where('id','=', $id)
  3999. ->update(array(
  4000. 'mobile' => Input::get('cell')
  4001. )
  4002. );
  4003. return Redirect::back()->with('view-success',"You have successfully updated your details");
  4004. }
  4005. public function serveUploadTenderWeeks()
  4006. {
  4007. return View::make('admin.upload-tender-weeks');
  4008. }
  4009. public function handleExcelUpload()
  4010. {
  4011. config(['excel.import.startRow' => 1 ]);
  4012. Excel::import(new TimesharesImport, Input::file('ex_file'));
  4013. return Redirect::back()->with('view-success', 'Your import is successful!');
  4014. }
  4015. public function reviewPrelistedWeeks()
  4016. {
  4017. $agencies = DB::table('agencies')
  4018. ->paginate(10);
  4019. return View::make('admin.review-prelisted-weeks')
  4020. ->with('agencies',$agencies);
  4021. }
  4022. public function selectedWeeks($id)
  4023. {
  4024. $agency = DB::table('agencies')
  4025. ->where('id','=',$id)
  4026. ->first();
  4027. $timeshares = DB::table('timeshares')
  4028. ->where('chosen','=',$agency->agency)
  4029. ->paginate(10);
  4030. return View::make('admin.selected-weeks')
  4031. ->with('agency',$agency)
  4032. ->with('timeshares',$timeshares);
  4033. }
  4034. public function handleReviewPrelistedWeeks($id)
  4035. {
  4036. $agency = DB::table('agencies')
  4037. ->where('id','=',$id)
  4038. ->first();
  4039. $selected = Input::get('selected');
  4040. foreach($selected as $id)
  4041. {
  4042. DB::table('timeshares')
  4043. ->where('id','=', $id)
  4044. ->update(array(
  4045. 'agency' => $agency->agency
  4046. )
  4047. );
  4048. DB::table('timeshares')
  4049. ->where('id','=', $id)
  4050. ->update(array(
  4051. 'pre_selected' => 1
  4052. )
  4053. );
  4054. }
  4055. $data = ['agency' => $agency];
  4056. Mail::send('emails.pre-list-authorised', $data, function($message)
  4057. {
  4058. $message->to('brucel@uni-vision.co.za','Bruce Lynwood')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Tender weeks preselection approved.');
  4059. $message->from('info@univateproperties.co.za');
  4060. });
  4061. return Redirect::to('review-prelisted-weeks')->with('view-success','Tender weeks have been successfully assigned to agency.');
  4062. }
  4063. public function publishTheRest()
  4064. {
  4065. $timeshares = DB::table('timeshares')
  4066. ->where('owner','=','UB')
  4067. ->get();
  4068. foreach($timeshares as $timeshare)
  4069. {
  4070. DB::table('timeshares')
  4071. ->where('id','=', $id)
  4072. ->update(array(
  4073. 'id' => $timeshare->id
  4074. )
  4075. );
  4076. }
  4077. return Redirect::to('review-prelisted-weeks')->with('view-success','The remaining timeshares have been successfully published.');
  4078. }
  4079. public function serveLogs()
  4080. {
  4081. $logs = DB::table('timeshare_change_logs')
  4082. ->paginate(10);
  4083. return View::make('admin.timeshare-change-logs')
  4084. ->with('logs',$logs);
  4085. }
  4086. public function serveUser($id)
  4087. {
  4088. $user = DB::table('users')
  4089. ->where('id','=',$id)
  4090. ->first();
  4091. return View::make('admin.view-user')
  4092. ->with('user',$user);
  4093. }
  4094. public function serveTimeshareDetails($id)
  4095. {
  4096. $timeshare = DB::table('timeshares')
  4097. ->where('id','=',$id)
  4098. ->first();
  4099. return View::make('admin.view-timeshare')
  4100. ->with('timeshare',$timeshare);
  4101. }
  4102. public function serveSearchTimeshareFilter($id)
  4103. {
  4104. if(!(Input::has('bedrooms')=="") and !(Input::has('season')=="") and !(Input::has('maxPrice')) and !(Input::has('minPrice')))
  4105. {
  4106. return Redirect::back()->with('view-error', 'No filter entered, please try again')->withInput()->withErrors($validator);
  4107. }
  4108. $resort = DB::table('resorts')
  4109. ->where('id','=',$id)
  4110. ->first();
  4111. $awards = explode(',',$resort->awards);
  4112. $facilities = explode(',',$resort->facilities);
  4113. $bedrooms = Input::get('bedrooms');
  4114. $minPrice = (float) (Input::get('minPrice'));
  4115. $maxPrice = (float) (Input::get('maxPrice'));
  4116. $season = Input::get('season');
  4117. $module = Input::get('module');
  4118. $fromDate = Input::get('fromDate');
  4119. $toDate = Input::get('toDate');
  4120. $timeshares = DB::table('timeshares')
  4121. ->where(function($query) use ($bedrooms, $season, $minPrice, $maxPrice, $module, $fromDate, $toDate) {
  4122. if ($bedrooms)
  4123. $query->where('bedrooms','=', $bedrooms);
  4124. if ($module)
  4125. $query->where('module','=', $module);
  4126. if ($fromDate)
  4127. $query->where('fromDate','>=',$fromDate);
  4128. if ($toDate)
  4129. $query->where('fromDate','<=',$toDate);
  4130. if ($season)
  4131. $query->where('season','=', $season);
  4132. if ($maxPrice)
  4133. $query->where('setPrice','<=', $maxPrice);
  4134. if ($minPrice)
  4135. $query->where('setPrice','>=', $minPrice); })
  4136. ->where('resort','=',$resort->resort)
  4137. ->where('published','=',1)
  4138. ->get();
  4139. if($timeshares->isEmpty())
  4140. {
  4141. return Redirect::back()->with('view-search-error', 'There were no results found, please try searching by week, unit, number of bedrooms or price.');
  4142. }
  4143. else
  4144. {
  4145. // multiple resorts search results
  4146. return View::make('timeshare-filter-results')
  4147. ->with('awards',$awards)
  4148. ->with('facilities',$facilities)
  4149. ->with('resort',$resort)
  4150. ->with('timeshares', $timeshares);
  4151. }
  4152. }
  4153. public function serveAddNewResort()
  4154. {
  4155. return View::make('admin.new-resort');
  4156. }
  4157. public function handleAddNewResort()
  4158. {
  4159. $validator = Validator::make(Input::all(),
  4160. [
  4161. 'resort' => 'required',
  4162. 'region' => 'required',
  4163. 'information' => 'required',
  4164. 'image1' => 'required',
  4165. 'image2' => 'required',
  4166. 'image3' => 'required'
  4167. ]);
  4168. if($validator->fails())
  4169. {
  4170. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  4171. }
  4172. $resort = new Resort;
  4173. $resort->resort = Input::get('resort');
  4174. $resort->information = Input::get('information');
  4175. $resort->region = Input::get('region');
  4176. $resort->meta_Description = Input::get('information');
  4177. $resort->meta_Keywords = Input::get('information');
  4178. if(Input::has('advisor'))
  4179. {
  4180. $resort->advisor = Input::get('advisor');
  4181. }
  4182. if(Input::has('url'))
  4183. {
  4184. $resort->url = Input::get('url');
  4185. }
  4186. if(Input::has('awards'))
  4187. {
  4188. $resort->awards = implode(',',Input::get('awards'));
  4189. }
  4190. $file = Input::file('image1');
  4191. $file->move('images/resorts/', $file->getClientOriginalName());
  4192. $resort->image1 = '/images/resorts/'.$file->getClientOriginalName();
  4193. $file2 = Input::file('image2');
  4194. $file2->move('images/resorts/', $file2->getClientOriginalName());
  4195. $resort->image2 = '/images/resorts/'.$file2->getClientOriginalName();
  4196. $file3 = Input::file('image3');
  4197. $file3->move('images/resorts/', $file3->getClientOriginalName());
  4198. $resort->image3 = '/images/resorts/'.$file3->getClientOriginalName();
  4199. $file4 = Input::file('layout');
  4200. $file4->move('images/resort/', $file4->getClientOriginalName());
  4201. $resort->layout = '/images/resort/'.$file4->getClientOriginalName();
  4202. $str = Input::get('resort');
  4203. $delimiter = '-';
  4204. $slug = strtolower(trim(preg_replace('/[\s-]+/', $delimiter, preg_replace('/[^A-Za-z0-9-]+/', $delimiter, preg_replace('/[&]/', 'and', preg_replace('/[\']/', '', iconv('UTF-8', 'ASCII//TRANSLIT', $str))))), $delimiter));
  4205. $resort->slug = $slug;
  4206. //$facilities = [];
  4207. $facilities = array();
  4208. $arrContextOptions=array(
  4209. "ssl"=>array(
  4210. "verify_peer"=>false,
  4211. "verify_peer_name"=>false,
  4212. ),
  4213. );
  4214. $data = file_get_contents("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/", false, stream_context_create($arrContextOptions));
  4215. $details = json_decode($data, true);
  4216. foreach($details as $obj)
  4217. {
  4218. if($obj['resortName']==Input::get('resort'))
  4219. {
  4220. $resortCode = $obj['resortCode'];
  4221. $arrContextOptions=array(
  4222. "ssl"=>array(
  4223. "verify_peer"=>false,
  4224. "verify_peer_name"=>false,
  4225. ),
  4226. );
  4227. $data2 = file_get_contents("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/facilities/".$resortCode, false, stream_context_create($arrContextOptions));
  4228. $details2 = json_decode($data2, true);
  4229. foreach($details2 as $facility){
  4230. if($facility['prSite']=='On')
  4231. {
  4232. array_push($facilities, $facility['prCategory']);
  4233. }
  4234. }
  4235. }
  4236. }
  4237. $resort->facilities = implode(",",$facilities);
  4238. $resort->map = Input::get('map');
  4239. $resort->save();
  4240. return Redirect::back()->with('view-success',' Resort has been successfully uploaded');
  4241. }
  4242. public function serveBulkExcelUpload()
  4243. {
  4244. return View::make('bulk-weeks-upload');
  4245. }
  4246. public function handleBulkExcelUpload()
  4247. {
  4248. $validator = Validator::make(Input::all(),
  4249. [
  4250. 'ex_file' => 'required'
  4251. ]);
  4252. if($validator->fails())
  4253. {
  4254. return Redirect::back()->with('view-error', ' No file uploaded.')->withInput()->withErrors($validator);
  4255. }
  4256. config(['excel.import.startRow' => 1 ]);
  4257. $import = new TimesharesImport;
  4258. Excel::import($import, Input::file('ex_file'));
  4259. $bulk = new TimeshareBulk;
  4260. $bulk->username = Auth::user()->username;
  4261. $bulk->user_id = Auth::user()->id;
  4262. $bulk->email = Auth::user()->email;
  4263. $bulk->number_of_timeshares = $import->count;
  4264. $bulk->amount = $import->count*380;
  4265. $bulk->save();
  4266. // dd($import->count);
  4267. return Redirect::to('/pay-bulk-listing-fee/'.$import->count)->with('view-success','Your import is successful!');
  4268. }
  4269. function fetch(Request $request)
  4270. {
  4271. if($request->get('query'))
  4272. {
  4273. $query = $request->get('query');
  4274. $data = DB::table('agencies')
  4275. ->where('agency', 'LIKE', "%{$query}%")
  4276. ->get();
  4277. $output = '<ul class="navbar-nav w-100 justify-content-center" style="display:block; position: absolute; z-index: 9; background-color: #33689b;">';
  4278. foreach($data as $row)
  4279. {
  4280. $output .= '
  4281. <li class="nav-item choose"><a style="color:white; text-decoration:none;" class="nav-link choose" href="#">' .$row->agency.'</a></li>
  4282. ';
  4283. }
  4284. $output .= '</ul>';
  4285. echo $output;
  4286. }
  4287. }
  4288. function fetchAgent(Request $request)
  4289. {
  4290. if($request->get('query') && $request->get('estateAgency'))
  4291. {
  4292. $agency = $request->get('estateAgency');
  4293. $query = $request->get('query');
  4294. $data = DB::table('users')
  4295. ->where('agency','=',$agency)
  4296. ->get();
  4297. $output = '<ul class="navbar-nav w-100 justify-content-center" style="display:block; position: absolute; z-index: 9; background-color: #33689b;">';
  4298. foreach($data as $row)
  4299. {
  4300. $output .= '
  4301. <span class="nav-item choose"><a style="color:white; text-decoration:none;" class="nav-link choose" href="#">' .$row->name.' '.$row->surname.'</a></span>
  4302. ';
  4303. }
  4304. $output .= '</ul>';
  4305. echo $output;
  4306. }
  4307. }
  4308. public function serveLogSearch()
  4309. {
  4310. $validator = Validator::make(Input::all(),
  4311. [
  4312. 'search' => 'required',
  4313. ]);
  4314. if($validator->fails())
  4315. {
  4316. return Redirect::back()->with('view-error', 'No search entered, please try again')->withInput()->withErrors($validator);
  4317. }
  4318. $query = Input::get('search');
  4319. $logs = DB::table('timeshare_change_logs')
  4320. ->where('resort', 'LIKE', '%' . $query . '%')//resort name
  4321. ->orWhere('module', 'LIKE', '%' . $query . '%')
  4322. ->orWhere('unit', 'LIKE', '%' . $query . '%')
  4323. ->orWhere('name', 'LIKE', '%' . $query . '%')
  4324. ->get();
  4325. if($logs->isEmpty())
  4326. {
  4327. return Redirect::back()->with('view-search-error', 'There were no results found, please try searching by resort name.');
  4328. }
  4329. else
  4330. {
  4331. // multiple resorts search results
  4332. return View::make('admin.log-search-results')
  4333. ->with('logs', $logs);
  4334. }
  4335. }
  4336. public function serveSearchResorts()
  4337. {
  4338. $validator = Validator::make(Input::all(),
  4339. [
  4340. 'search' => 'required',
  4341. ]);
  4342. if($validator->fails())
  4343. {
  4344. return Redirect::back()->with('view-error', 'No search entered, please try again')->withInput()->withErrors($validator);
  4345. }
  4346. $query = Input::get('search');
  4347. $logs = DB::table('timeshare_change_logs')
  4348. ->where('resort', 'LIKE', '%' . $query . '%')//resort name
  4349. ->orWhere('module', 'LIKE', '%' . $query . '%')
  4350. ->orWhere('unit', 'LIKE', '%' . $query . '%')
  4351. ->orWhere('name', 'LIKE', '%' . $query . '%')
  4352. ->get();
  4353. $timeshares = DB::table('timeshares')
  4354. ->get();
  4355. foreach($timeshares as $timeshare)
  4356. {
  4357. if($timeshare->region=='gauteng' and $timeshare->published=1)
  4358. {
  4359. $gauteng = DB::table('resorts')
  4360. ->where('region','=','gauteng')
  4361. ->groupBy('resort')
  4362. ->get();
  4363. }
  4364. }
  4365. if($logs->isEmpty())
  4366. {
  4367. return Redirect::back()->with('view-search-error', 'There were no results found, please try searching by resort name.');
  4368. }
  4369. else
  4370. {
  4371. // multiple resorts search results
  4372. return View::make('admin.log-search-results')
  4373. ->with('logs', $logs);
  4374. }
  4375. }
  4376. public function serveSearchResortFilter()
  4377. {
  4378. $resort = Input::get('resort');
  4379. $bedrooms = Input::get('bedrooms');
  4380. $season = Input::get('season');
  4381. $region = Input::get('region');
  4382. $minPrice = (float) (Input::get('minPrice'));
  4383. $maxPrice = (float) (Input::get('maxPrice'));
  4384. $fromDate = Input::get('fromDate');
  4385. $toDate = Input::get('toDate');
  4386. $resorts = DB::table('resorts')
  4387. ->orderBy('resort','asc')
  4388. ->get();
  4389. $timeshares = DB::table('timeshares')
  4390. ->where(function($query) use ($region, $season, $bedrooms, $resort, $minPrice, $maxPrice, $fromDate, $toDate) {
  4391. if ($resort!=null)
  4392. $query->where('resort', '=',$resort)->where('published','=',1);
  4393. if ($season!=null)
  4394. $query->where('season','=',$season)->where('published','=',1);
  4395. if ($region!=null)
  4396. $query->where('region','=',$region)->where('published','=',1);
  4397. if ($bedrooms!=null)
  4398. $query->where('bedrooms','=',$bedrooms)->where('published','=',1);
  4399. if ($fromDate!=null)
  4400. $query->where('fromDate','>=',$fromDate)->where('published','=',1);
  4401. if ($toDate!=null)
  4402. $query->where('fromDate','<=',$toDate)->where('published','=',1);
  4403. if ($maxPrice!=0.0)
  4404. $query->where('setPrice','<=', $maxPrice)->where('published','=',1);
  4405. if ($minPrice!=0.0)
  4406. $query->where('setPrice','>=', $minPrice)->where('published','=',1); })
  4407. ->get();
  4408. if($timeshares->isEmpty())
  4409. {
  4410. if( !(Auth::check()) )
  4411. {
  4412. $timeshares = DB::table('timeshares')
  4413. ->get();
  4414. $resorts = DB::table('resorts')
  4415. ->orderBy('resort','asc')
  4416. ->get();
  4417. $gauteng = NULL;
  4418. $limpopo = NULL;
  4419. $mpumalanga = NULL;
  4420. $kwazulunatal = NULL;
  4421. $freestate = NULL;
  4422. $northwest = NULL;
  4423. $northerncape = NULL;
  4424. $westerncape = NULL;
  4425. $easterncape = NULL;
  4426. foreach($timeshares as $timeshare)
  4427. {
  4428. if($timeshare->region=='gauteng' and $timeshare->published=1)
  4429. {
  4430. $gauteng = DB::table('resorts')
  4431. ->where('region','=','gauteng')
  4432. ->groupBy('resort')
  4433. ->get();
  4434. }
  4435. }
  4436. foreach($timeshares as $timeshare)
  4437. {
  4438. if($timeshare->region=='limpopo' && $timeshare->published=1)
  4439. {
  4440. $limpopo = DB::table('resorts')
  4441. ->where('region','=','limpopo')
  4442. ->groupBy('resort')
  4443. ->get();
  4444. }
  4445. }
  4446. foreach($timeshares as $timeshare)
  4447. {
  4448. if($timeshare->region=='mpumalanga' && $timeshare->published=1)
  4449. {
  4450. $mpumalanga = DB::table('resorts')
  4451. ->where('region','=','mpumalanga')
  4452. ->groupBy('resort')
  4453. ->get();
  4454. }
  4455. }
  4456. foreach($timeshares as $timeshare)
  4457. {
  4458. if($timeshare->region=='Kwazulu Natal' && $timeshare->published=1)
  4459. {
  4460. $kwazulunatal = DB::table('resorts')
  4461. ->where('region','=','Kwazulu Natal')
  4462. ->groupBy('resort')
  4463. ->get();
  4464. }
  4465. }
  4466. foreach($timeshares as $timeshare)
  4467. {
  4468. if($timeshare->region=='free state' && $timeshare->published=1)
  4469. {
  4470. $freestate = DB::table('resorts')
  4471. ->where('region','=','free state')
  4472. ->groupBy('resort')
  4473. ->get();
  4474. }
  4475. }
  4476. foreach($timeshares as $timeshare)
  4477. {
  4478. if($timeshare->region=='north west' && $timeshare->published=1)
  4479. {
  4480. $northwest = DB::table('resorts')
  4481. ->where('region','=','north west')
  4482. ->groupBy('resort')
  4483. ->get();
  4484. }
  4485. }
  4486. foreach($timeshares as $timeshare)
  4487. {
  4488. if($timeshare->region=='northern cape' && $timeshare->published=1)
  4489. {
  4490. $northerncape = DB::table('resorts')
  4491. ->where('region','=','northern cape')
  4492. ->groupBy('resort')
  4493. ->get();
  4494. }
  4495. }
  4496. foreach($timeshares as $timeshare)
  4497. {
  4498. if($timeshare->region=='western cape' && $timeshare->published=1)
  4499. {
  4500. $westerncape = DB::table('resorts')
  4501. ->where('region','=','western cape')
  4502. ->groupBy('resort')
  4503. ->get();
  4504. }
  4505. }
  4506. foreach($timeshares as $timeshare)
  4507. {
  4508. if($timeshare->region=='eastern cape' && $timeshare->published=1)
  4509. {
  4510. $easterncape = DB::table('resorts')
  4511. ->where('region','=','eastern cape')
  4512. ->groupBy('resort')
  4513. ->get();
  4514. }
  4515. }
  4516. $resorts = DB::table('resorts')
  4517. ->get();
  4518. return View::make('no-results-found2')
  4519. ->with('resorts',$resorts)
  4520. ->with('easterncape',$easterncape)
  4521. ->with('westerncape',$westerncape)
  4522. ->with('northerncape',$northerncape)
  4523. ->with('northwest',$northwest)
  4524. ->with('freestate',$freestate)
  4525. ->with('kwazulunatal',$kwazulunatal)
  4526. ->with('mpumalanga',$mpumalanga)
  4527. ->with('limpopo',$limpopo)
  4528. ->with('gauteng',$gauteng)
  4529. ->with('view-search-error', 'There were no results found. Login or register so that we can assist you to source out exactly what you are looking for.');
  4530. }
  4531. elseif(Auth::check()) {
  4532. return View::make('no-results-found2')
  4533. ->with('resort',$resort)
  4534. ->with('region',$region)
  4535. ->with('minPrice',$minPrice)
  4536. ->with('maxPrice',$maxPrice)
  4537. ->with('fromDate',$fromDate)
  4538. ->with('toDate',$toDate)
  4539. ->with('view-search-error', 'There were no results found. Login or register so that we can assist you to source out exactly what you are looking for.');
  4540. }
  4541. }
  4542. else if(($resort==null) && $region==null && $bedrooms==null && $season==null && $minPrice==0.0 && $maxPrice==0.0){
  4543. $timeshares = DB::table('timeshares')
  4544. ->get();
  4545. $resorts = DB::table('resorts')
  4546. ->orderBy('resort','asc')
  4547. ->get();
  4548. $gauteng = NULL;
  4549. $limpopo = NULL;
  4550. $mpumalanga = NULL;
  4551. $kwazulunatal = NULL;
  4552. $freestate = NULL;
  4553. $northwest = NULL;
  4554. $northerncape = NULL;
  4555. $westerncape = NULL;
  4556. $easterncape = NULL;
  4557. foreach($timeshares as $timeshare)
  4558. {
  4559. if($timeshare->region=='gauteng' and $timeshare->published=1)
  4560. {
  4561. $gauteng = DB::table('resorts')
  4562. ->where('region','=','gauteng')
  4563. ->groupBy('resort')
  4564. ->get();
  4565. }
  4566. }
  4567. foreach($timeshares as $timeshare)
  4568. {
  4569. if($timeshare->region=='limpopo' && $timeshare->published=1)
  4570. {
  4571. $limpopo = DB::table('resorts')
  4572. ->where('region','=','limpopo')
  4573. ->groupBy('resort')
  4574. ->get();
  4575. }
  4576. }
  4577. foreach($timeshares as $timeshare)
  4578. {
  4579. if($timeshare->region=='mpumalanga' && $timeshare->published=1)
  4580. {
  4581. $mpumalanga = DB::table('resorts')
  4582. ->where('region','=','mpumalanga')
  4583. ->groupBy('resort')
  4584. ->get();
  4585. }
  4586. }
  4587. foreach($timeshares as $timeshare)
  4588. {
  4589. if($timeshare->region=='Kwazulu Natal' && $timeshare->published=1)
  4590. {
  4591. $kwazulunatal = DB::table('resorts')
  4592. ->where('region','=','Kwazulu Natal')
  4593. ->groupBy('resort')
  4594. ->get();
  4595. }
  4596. }
  4597. foreach($timeshares as $timeshare)
  4598. {
  4599. if($timeshare->region=='free state' && $timeshare->published=1)
  4600. {
  4601. $freestate = DB::table('resorts')
  4602. ->where('region','=','free state')
  4603. ->groupBy('resort')
  4604. ->get();
  4605. }
  4606. }
  4607. foreach($timeshares as $timeshare)
  4608. {
  4609. if($timeshare->region=='north west' && $timeshare->published=1)
  4610. {
  4611. $northwest = DB::table('resorts')
  4612. ->where('region','=','north west')
  4613. ->groupBy('resort')
  4614. ->get();
  4615. }
  4616. }
  4617. foreach($timeshares as $timeshare)
  4618. {
  4619. if($timeshare->region=='northern cape' && $timeshare->published=1)
  4620. {
  4621. $northerncape = DB::table('resorts')
  4622. ->where('region','=','northern cape')
  4623. ->groupBy('resort')
  4624. ->get();
  4625. }
  4626. }
  4627. foreach($timeshares as $timeshare)
  4628. {
  4629. if($timeshare->region=='western cape' && $timeshare->published=1)
  4630. {
  4631. $westerncape = DB::table('resorts')
  4632. ->where('region','=','western cape')
  4633. ->groupBy('resort')
  4634. ->get();
  4635. }
  4636. }
  4637. foreach($timeshares as $timeshare)
  4638. {
  4639. if($timeshare->region=='eastern cape' && $timeshare->published=1)
  4640. {
  4641. $easterncape = DB::table('resorts')
  4642. ->where('region','=','eastern cape')
  4643. ->groupBy('resort')
  4644. ->get();
  4645. }
  4646. }
  4647. return View::make('to-buy')
  4648. ->with('gauteng',$gauteng)
  4649. ->with('westerncape',$westerncape)
  4650. ->with('northwest',$northwest)
  4651. ->with('mpumalanga',$mpumalanga)
  4652. ->with('limpopo',$limpopo)
  4653. ->with('freestate',$freestate)
  4654. ->with('easterncape',$easterncape)
  4655. ->with('westerncape',$westerncape)
  4656. ->with('northerncape',$northerncape)
  4657. ->with('kwazulunatal',$kwazulunatal)
  4658. ->with('resorts',$resorts)
  4659. ->with('view-search-error', 'There were no results found.');
  4660. }
  4661. else
  4662. {
  4663. // multiple resorts search results
  4664. return View::make('to-buy-results')
  4665. ->with('resorts',$resorts)
  4666. ->with('timeshares',$timeshares);
  4667. }
  4668. }
  4669. public function serveGetUsername()
  4670. {
  4671. return View::make('get-username');
  4672. }
  4673. public function sendUsername()
  4674. {
  4675. $users = DB::table('users')
  4676. ->get();
  4677. $email = Input::get('email');
  4678. $sendTo = NULL;
  4679. foreach($users as $user)
  4680. {
  4681. if($email==$user->email)
  4682. {
  4683. $sendTo = $user->email;
  4684. }
  4685. }
  4686. $user = NULL;
  4687. if($sendTo!=NULL)
  4688. {
  4689. $user = DB::table('users')
  4690. ->where('email','=',$sendTo)
  4691. ->first();
  4692. $data = ['user' => $user];
  4693. Mail::send('emails.get-username', $data, function($message) use ($user)
  4694. {
  4695. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Username request');
  4696. $message->from('info@univateproperties.co.za');
  4697. });
  4698. return Redirect::to('get-username')->with('view-success', 'Your username has been sent to your email address.')->withInput();
  4699. }
  4700. else{
  4701. return Redirect::to('get-username')->with('view-error', 'Email does not exist.')->withInput();
  4702. }
  4703. }
  4704. public function serveAdminFilter()
  4705. {
  4706. if(Input::get('status')=="select" && Input::get('season')=="select" && Input::get('resort')=="select")
  4707. {
  4708. $timeshares = DB::table('timeshares')
  4709. ->orderBy('published','asc')
  4710. ->paginate(10);
  4711. $resorts = DB::table('resorts')
  4712. ->orderBy('resort','asc')
  4713. ->get();
  4714. return View::make('admin.admin')
  4715. ->with('resorts',$resorts)
  4716. ->with('timeshares',$timeshares)
  4717. ->with('view-search-error', 'No filter entered, please try again.');
  4718. }
  4719. $resort = Input::get('resort');
  4720. $season = Input::get('season');
  4721. $status = Input::get('status');
  4722. $timeshares = DB::table('timeshares')
  4723. ->where(function($query) use ($season, $status, $resort) {
  4724. if ($resort!="select")
  4725. $query->where('resort', '=', $resort);
  4726. if ($season!="select")
  4727. $query->where('season','=',$season);
  4728. if ($status!="select")
  4729. $query->where('published','=',$status);
  4730. })
  4731. ->get();
  4732. $resorts = DB::table('resorts')
  4733. ->orderBy('resort','asc')
  4734. ->get();
  4735. if($timeshares->isNotEmpty())
  4736. {
  4737. return View::make('search-results')
  4738. ->with('resorts',$resorts)
  4739. ->with('timeshares',$timeshares);
  4740. }
  4741. else if(Input::get('status')=="select" and Input::get('season')=="select" and Input::get('resort')=="select")
  4742. {
  4743. $timeshares = DB::table('timeshares')
  4744. ->orderBy('published','asc')
  4745. ->paginate(10);
  4746. $resorts = DB::table('resorts')
  4747. ->orderBy('resort','asc')
  4748. ->get();
  4749. return View::make('admin.admin')
  4750. ->with('resorts',$resorts)
  4751. ->with('timeshares',$timeshares)
  4752. ->with('view-search-error', 'No filter entered, please try again.');
  4753. }
  4754. else
  4755. {
  4756. $timeshares = DB::table('timeshares')
  4757. ->orderBy('published','asc')
  4758. ->paginate(10);
  4759. $resorts = DB::table('resorts')
  4760. ->orderBy('resort','asc')
  4761. ->get();
  4762. if (Auth::check() && Auth::user()->role == "admin") {
  4763. return View::make('no-results-found')
  4764. ->with('resorts',$resorts)
  4765. ->with('timeshares',$timeshares)
  4766. ->with('view-search-error', 'There were no results found.');
  4767. }
  4768. }
  4769. }
  4770. public function serveUpdateAgencyProfile($agency)
  4771. {
  4772. $agency = DB::table('agencies')
  4773. ->where('agency','=',$agency)
  4774. ->first();
  4775. return View::make('update-agency-profile')
  4776. ->with('agency',$agency);
  4777. }
  4778. public function handleUpdateAgencyProfile($agency)
  4779. {
  4780. $validator = Validator::make(Input::all(),
  4781. [
  4782. 'agency' => 'required',
  4783. 'registrationNum' => 'required',
  4784. 'EAAB_FFC_Number' => 'required'
  4785. ]);
  4786. if($validator->fails())
  4787. {
  4788. return Redirect::back()->with('view-error', ' Your information is incomplete, please review below')->withInput()->withErrors($validator);
  4789. }
  4790. $users = DB::table('users')
  4791. ->get();
  4792. foreach($users as $user)
  4793. {
  4794. DB::table('users')
  4795. ->where('agency','=',$agency)
  4796. ->update(array(
  4797. 'agency' => Input::get('agency')
  4798. )
  4799. );
  4800. }
  4801. DB::table('agencies')
  4802. ->where('agency','=', $agency)
  4803. ->update(array(
  4804. 'registrationNum' => Input::get('registrationNum')
  4805. )
  4806. );
  4807. DB::table('agencies')
  4808. ->where('agency','=', $agency)
  4809. ->update(array(
  4810. 'EAAB_FFC_Number' => Input::get('EAAB_FFC_Number')
  4811. )
  4812. );
  4813. DB::table('agencies')
  4814. ->where('agency','=', $agency)
  4815. ->update(array(
  4816. 'agency' => Input::get('agency')
  4817. )
  4818. );
  4819. return Redirect::to('/')->with('view-success',"You have successfully updated agency details");
  4820. }
  4821. public function serveLombardySales()
  4822. {
  4823. $lombardy = DB::table('commercials')
  4824. ->where('name','=','Lombardy Business Park')
  4825. ->where('for','=','Sale')
  4826. ->orWhere('for','=','Sold')
  4827. ->orderBy('created_at','asc')
  4828. ->paginate(6);
  4829. $property = DB::table('commercials')
  4830. ->where('name','=','Lombardy Business Park')
  4831. ->orderBy('created_at','asc')
  4832. ->first();
  4833. $facilities = explode(',',$property->facilities);
  4834. return View::make('lombardy-sales')
  4835. ->with('property',$property)
  4836. ->with('facilities',$facilities)
  4837. ->with('lombardy',$lombardy);
  4838. }
  4839. public function serveBulkPayment($listings)
  4840. {
  4841. $total = $listings*380;
  4842. return View::make('pay-bulk-listing-fee')
  4843. ->with('total',$total);
  4844. }
  4845. public function handleSourceWeek()
  4846. {
  4847. $resort = Input::get('resort');
  4848. $region = Input::get('region');
  4849. $minPrice = Input::get('minPrice');
  4850. $maxPrice = Input::get('maxPrice');
  4851. $fromDate = Input::get('fromDate');
  4852. $toDate = Input::get('toDate');
  4853. $user = DB::table('users')
  4854. ->where('id','=',Auth::user()->id)
  4855. ->first();
  4856. $data = ['resort' => $resort, 'region' => $region, 'minPrice' => $minPrice, 'maxPrice' => $maxPrice, 'fromDate' => $fromDate, 'toDate' => $toDate, 'user' => $user];
  4857. Mail::send('emails.source-week', $data, function($message)
  4858. {
  4859. $message->to('koketso.maphopha@gmail.com','Info')->to('brucel@uni-vision.co.za','Bruce Lynwood')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Source Week Request');
  4860. $message->from('info@univateproperties.co.za');
  4861. });
  4862. return Redirect::to('to-buy')->with('view-success', 'Your details has been sent to our consultants.');
  4863. }
  4864. public function serveAddNewCommercialProperty()
  4865. {
  4866. return View::make('admin.add-commercial-property');
  4867. }
  4868. public function handleAddNewCommercialProperty()
  4869. {
  4870. $validator = Validator::make(Input::all(),
  4871. [
  4872. 'region' => 'required',
  4873. 'description' => 'required',
  4874. 'image1' => 'required',
  4875. 'image2' => 'required',
  4876. 'image3' => 'required'
  4877. ]);
  4878. if(!(Input::hasFile('image1')) or !(Input::hasFile('image2')) or !(Input::hasFile('image3')))
  4879. {
  4880. return Redirect::back()->with('view-error', '3 images are required to upload a property.')->withInput();
  4881. }
  4882. if($validator->fails())
  4883. {
  4884. return Redirect::back()->with('view-error', ' Some information is incomplete in your submission please review below')->withInput()->withErrors($validator);
  4885. }
  4886. $commercial = new Commercial;
  4887. $commercial->name = Input::get('name');
  4888. $commercial->unit = Input::get('unit');
  4889. $commercial->address = Input::get('address');
  4890. $commercial->size = Input::get('size');
  4891. $commercial->region = Input::get('region');
  4892. $commercial->town = Input::get('town');
  4893. $commercial->opCost = Input::get('opCost');
  4894. $commercial->for = Input::get('for');
  4895. $commercial->description = Input::get('description');
  4896. $commercial->intro = Input::get('intro');
  4897. $commercial->contact_person = Input::get('contact_person');
  4898. $commercial->contact_email = Input::get('contact_email');
  4899. $commercial->contact_mobile = Input::get('contact_mobile');
  4900. $commercial->surburb = Input::get('surburb');
  4901. $commercial->propertType = Input::get('propertType');
  4902. $commercial->status = Input::get('for');
  4903. $commercial->status2 = Input::get('for');
  4904. if (Input::hasFile('image1')) {
  4905. $file = Input::file('image1');
  4906. $file->move('img/', $file->getClientOriginalName());
  4907. $commercial->image2 = 'img/' . $file->getClientOriginalName();
  4908. }
  4909. if (Input::hasFile('image2')) {
  4910. $file = Input::file('image2');
  4911. $file->move('img/', $file->getClientOriginalName());
  4912. $commercial->image2 = 'img/' . $file->getClientOriginalName();
  4913. }
  4914. if (Input::hasFile('image3')) {
  4915. $file = Input::file('image3');
  4916. $file->move('img/', $file->getClientOriginalName());
  4917. $commercial->image3 = 'img/' . $file->getClientOriginalName();
  4918. }
  4919. $commercial->save();
  4920. return Redirect::to('all-commercial-properties')->with('view-success',' You have successfully added a new property.');
  4921. }
  4922. public function serveEditAgentCommercial($id)
  4923. {
  4924. $commercial = DB::table('commercials')
  4925. ->where('id','=',$id)
  4926. ->first();
  4927. return View::make('admin.edit-agent-commercial')
  4928. ->with('commercial',$commercial);
  4929. }
  4930. public function handleEditAgentCommercial($id)
  4931. {
  4932. $validator = Validator::make(Input::all(),
  4933. [
  4934. 'name' => 'required'
  4935. ]);
  4936. if($validator->fails())
  4937. {
  4938. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  4939. }
  4940. DB::table('commercials')
  4941. ->where('id','=', $id)
  4942. ->update(array(
  4943. 'name' => Input::get('name')
  4944. )
  4945. );
  4946. DB::table('commercials')
  4947. ->where('id','=', $id)
  4948. ->update(array(
  4949. 'address' => Input::get('address')
  4950. )
  4951. );
  4952. DB::table('commercials')
  4953. ->where('id','=', $id)
  4954. ->update(array(
  4955. 'region' => Input::get('region')
  4956. )
  4957. );
  4958. DB::table('commercials')
  4959. ->where('id','=', $id)
  4960. ->update(array(
  4961. 'town' => Input::get('town')
  4962. )
  4963. );
  4964. DB::table('commercials')
  4965. ->where('id','=', $id)
  4966. ->update(array(
  4967. 'status2' => Input::get('status2')
  4968. )
  4969. );
  4970. DB::table('commercials')
  4971. ->where('id','=', $id)
  4972. ->update(array(
  4973. 'surburb' => Input::get('surburb')
  4974. )
  4975. );
  4976. DB::table('commercials')
  4977. ->where('id','=', $id)
  4978. ->update(array(
  4979. 'unit' => Input::get('unit')
  4980. )
  4981. );
  4982. DB::table('commercials')
  4983. ->where('id','=', $id)
  4984. ->update(array(
  4985. 'size' => Input::get('size')
  4986. )
  4987. );
  4988. DB::table('commercials')
  4989. ->where('id','=', $id)
  4990. ->update(array(
  4991. 'price' => Input::get('price')
  4992. )
  4993. );
  4994. DB::table('commercials')
  4995. ->where('id','=', $id)
  4996. ->update(array(
  4997. 'description' => Input::get('description')
  4998. )
  4999. );
  5000. DB::table('commercials')
  5001. ->where('id','=', $id)
  5002. ->update(array(
  5003. 'contact_person' => Input::get('contact_person')
  5004. )
  5005. );
  5006. DB::table('commercials')
  5007. ->where('id','=', $id)
  5008. ->update(array(
  5009. 'contact_email' => Input::get('contact_email')
  5010. )
  5011. );
  5012. DB::table('commercials')
  5013. ->where('id','=', $id)
  5014. ->update(array(
  5015. 'contact_mobile' => Input::get('contact_mobile')
  5016. )
  5017. );
  5018. DB::table('commercials')
  5019. ->where('id','=', $id)
  5020. ->update(array(
  5021. 'propertType' => Input::get('propertType')
  5022. )
  5023. );
  5024. return Redirect::to('commercial-admin')->with('view-success',' Commercial property successfully updated');
  5025. }
  5026. function fetchAllResorts(Request $request)
  5027. {
  5028. if($request->get('query'))
  5029. {
  5030. $query = $request->get('query');
  5031. $data = DB::table('uniresorts')
  5032. ->where('resort', 'LIKE', "%{$query}%")
  5033. ->get();
  5034. $output = '<ul class="navbar-nav w-100 justify-content-center" style="display:block; position: absolute; z-index: 9; background-color: #33689b;">';
  5035. foreach($data as $row)
  5036. {
  5037. $output .= '
  5038. <li class="nav-item choose"><a style="color:white; text-decoration:none;" class="nav-link choose" href="#">' .$row->resort.'</a></li>
  5039. ';
  5040. }
  5041. $output .= '</ul>';
  5042. echo $output;
  5043. }
  5044. }
  5045. public function listedResorts($agency)
  5046. {
  5047. $resorts = DB::table('timeshares')
  5048. ->where('agency','=',$agency)
  5049. ->where('published','=',1)
  5050. ->groupBy('resort')
  5051. ->paginate(10);
  5052. return View::make('my-timeshares-links')
  5053. ->with('resorts',$resorts);
  5054. }
  5055. public function serveAgencyTimeshares($agency,$resortName)
  5056. {
  5057. $resort = DB::table('resorts')
  5058. ->where('resort','=',$resortName)
  5059. ->first();
  5060. $timeshares = DB::table('timeshares')
  5061. ->where('resort','=',$resort->resort)
  5062. ->where('agency','=',$agency)
  5063. ->where('published','=',1)
  5064. ->paginate(5);
  5065. $awards = explode(',',$resort->awards);
  5066. $facilities = explode(',',$resort->facilities);
  5067. return View::make('agency-timeshares')
  5068. ->with('resort',$resort)
  5069. ->with('timeshares',$timeshares)
  5070. ->with('awards',$awards)
  5071. ->with('facilities',$facilities);
  5072. }
  5073. }