Old UniVate Website
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

PagesController.php 88KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267
  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. class PagesController extends Controller {
  32. protected static $rules = [
  33. 'username' => 'required',
  34. 'password' => 'required'
  35. ];
  36. public function serveHome()
  37. {
  38. return View::make('home');
  39. }
  40. public function serveAbout()
  41. {
  42. return View::make('about');
  43. }
  44. public function serveContact()
  45. {
  46. return View::make('contact-us');
  47. }
  48. public function serveFAQs()
  49. {
  50. return View::make('faqs');
  51. }
  52. public function servePrivacyPolicy()
  53. {
  54. return View::make('privacy-policy');
  55. }
  56. public function serveTimeshare()
  57. {
  58. return View::make('timeshare');
  59. }
  60. public function serveAdmin()
  61. {
  62. $timeshares = DB::table('timeshares')
  63. ->orderBy('resort','asc')
  64. ->paginate(10);
  65. if (Auth::check() && Auth::user()->role == "admin") {
  66. return View::make('admin.admin')
  67. ->with('timeshares',$timeshares);
  68. }else{
  69. return Redirect::to('/');
  70. }
  71. }
  72. public function serveCommercialAdmin()
  73. {
  74. $commercials = DB::table('commercials')
  75. ->orderBy('name','asc')
  76. ->paginate(15);
  77. if (Auth::check() && Auth::user()->role == "admin") {
  78. return View::make('admin.commercial-admin')
  79. ->with('commercials',$commercials);
  80. }else{
  81. return Redirect::to('/');
  82. }
  83. }
  84. public function serveResidentialAdmin()
  85. {
  86. $residentials = DB::table('residentials')
  87. ->orderBy('name','asc')
  88. ->paginate(15);
  89. if (Auth::check() && Auth::user()->role == "admin") {
  90. return View::make('admin.residential-admin')
  91. ->with('residentials',$residentials);
  92. }else{
  93. return Redirect::to('/');
  94. }
  95. }
  96. public function serveToSell()
  97. {
  98. $resorts = DB::table('resorts')
  99. ->orderBy('resort','asc')
  100. ->get();
  101. return View::make('to-sell')
  102. ->with('resorts',$resorts);
  103. }
  104. public function handleToSell()
  105. {
  106. $validator = Validator::make(Input::all(),
  107. [
  108. 'resort' => 'required',
  109. 'week' => 'required',
  110. 'module' => 'required',
  111. 'bedrooms' => 'required',
  112. 'season' => 'required',
  113. 'sleeps' => 'required',
  114. 'unit' => 'required',
  115. 'region' => 'required'
  116. ]);
  117. if(!Auth::check())
  118. {
  119. 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);
  120. }
  121. if($validator->fails())
  122. {
  123. return Redirect::back()->with('view-error', ' Some information is missing, please review and try again.')->withInput()->withErrors($validator);
  124. }
  125. //$id = Auth::user()->id;
  126. $seller = new Seller;
  127. $seller->paid = Input::get('paid');
  128. $seller->rental = Input::get('rental');
  129. $seller->spaceBanked = Input::get('spaceBanked');
  130. $seller->date = Input::get('date');
  131. $seller->purchasePrice = Input::get('purchasePrice');
  132. $seller->sellingPrice = Input::get('sellingPrice');
  133. $seller->estateAgency = Input::get('estateAgency');
  134. $seller->commission = Input::get('commission');
  135. $seller->agentName = Input::get('agentName');
  136. $seller->agencyName = Input::get('agencyName');
  137. $seller->referedBy = Input::get('referedBy');
  138. $seller->occupationDate1 = Input::get('occupationDate1');
  139. $seller->occupationDate2 = Input::get('occupationDate2');
  140. $seller->save();
  141. $timeshare = new Timeshare;
  142. $timeshare->resort = Input::get('resort');
  143. $timeshare->names = Auth::user()->name;
  144. $timeshare->email = Auth::user()->email;
  145. $timeshare->phone = Auth::user()->phone;
  146. $timeshare->mobile = Auth::user()->mobile;
  147. $timeshare->week = Input::get('week');
  148. $timeshare->season = Input::get('season');
  149. $timeshare->module = Input::get('module');
  150. $timeshare->region = Input::get('region');
  151. $timeshare->price = Input::get('sellingPrice');
  152. $timeshare->bedrooms = Input::get('bedrooms');
  153. $timeshare->other = Input::get('other');
  154. $timeshare->sleeps = Input::get('sleeps');
  155. $timeshare->unit = Input::get('unit');
  156. $timeshare->owner = Input::get('owner');
  157. $timeshare->listingFee = 'Pending';
  158. $timeshare->paid = Input::get('paid');
  159. $timeshare->spacebankedyear = Input::get('spacebankedyear');
  160. $timeshare->spacebankOwner = Input::get('spacebankOwner');
  161. $timeshare->save();
  162. $data = ['timeshare' => $timeshare, 'seller' => $seller];
  163. Mail::send('emails.timeshare', $data, function($message)
  164. {
  165. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New timeshare submission');
  166. $message->from('info@univateproperties.co.za');
  167. });
  168. return Redirect::to('/pay-listing-fee/'.$timeshare->id)->with('view-success',' Your Timeshare has been successfully submitted');
  169. }
  170. public function servePayListingFee($id)
  171. {
  172. $timeshare = DB::table('timeshares')
  173. ->where('id','=',$id)
  174. ->first();
  175. return View::make('pay-listing-fee')
  176. ->with('timeshare',$timeshare);
  177. }
  178. public function serveToBuy()
  179. {
  180. $gauteng = DB::table('resorts')
  181. ->where('region','=','gauteng')
  182. ->groupBy('resort')
  183. ->get();
  184. $limpopo = DB::table('resorts')
  185. ->where('region','=','limpopo')
  186. ->groupBy('resort')
  187. ->get();
  188. $mpumalanga = DB::table('resorts')
  189. ->where('region','=','mpumalanga')
  190. ->groupBy('resort')
  191. ->get();
  192. $kwazulunatal = DB::table('resorts')
  193. ->where('region','=','Kwazulu Natal')
  194. ->groupBy('resort')
  195. ->get();
  196. $freestate = DB::table('resorts')
  197. ->where('region','=','free state')
  198. ->groupBy('resort')
  199. ->get();
  200. $northwest = DB::table('resorts')
  201. ->where('region','=','north west')
  202. ->groupBy('resort')
  203. ->get();
  204. $northerncape = DB::table('resorts')
  205. ->where('region','=','northern cape')
  206. ->groupBy('resort')
  207. ->get();
  208. $westerncape = DB::table('resorts')
  209. ->where('region','=','western cape')
  210. ->groupBy('resort')
  211. ->get();
  212. $easterncape = DB::table('resorts')
  213. ->where('region','=','eastern cape')
  214. ->groupBy('resort')
  215. ->get();
  216. return View::make('to-buy')
  217. ->with('easterncape',$easterncape)
  218. ->with('limpopo',$limpopo)
  219. ->with('northwest',$northwest)
  220. ->with('northerncape',$northerncape)
  221. ->with('westerncape',$westerncape)
  222. ->with('kwazulunatal',$kwazulunatal)
  223. ->with('mpumalanga',$mpumalanga)
  224. ->with('freestate',$freestate)
  225. ->with('gauteng',$gauteng);
  226. }
  227. public function serveResortUpload()
  228. {
  229. return View::make('resort-upload');
  230. }
  231. public function handleResortUpload()
  232. {
  233. $validator = Validator::make(Input::all(),
  234. [
  235. 'resort' => 'required',
  236. 'region' => 'required',
  237. 'information' => 'required',
  238. 'image1' => 'required',
  239. 'image2' => 'required',
  240. 'logo' => 'required'
  241. ]);
  242. if($validator->fails())
  243. {
  244. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  245. }
  246. $resort = new Resort;
  247. $resort->resort = Input::get('resort');
  248. $resort->information = Input::get('information');
  249. $resort->region = Input::get('region');
  250. if(Input::has('advisor'))
  251. {
  252. $resort->advisor = Input::get('advisor');
  253. }
  254. if(Input::has('awards'))
  255. {
  256. $resort->awards = implode(',',Input::get('awards'));
  257. }
  258. $file = Input::file('image1');
  259. $file->move('images/resorts/', $file->getClientOriginalName());
  260. $resort->image1 = '/images/resorts/'.$file->getClientOriginalName();
  261. $file = Input::file('image2');
  262. $file->move('images/resorts/', $file->getClientOriginalName());
  263. $resort->image2 = '/images/resorts/'.$file->getClientOriginalName();
  264. $file = Input::file('logo');
  265. $file->move('images/logos/', $file->getClientOriginalName());
  266. $resort->logo = '/images/logos/'.$file->getClientOriginalName();
  267. $resort->save();
  268. return Redirect::back()->with('view-success',' Resort has been successfully uploaded');
  269. }
  270. public function serveLogin()
  271. {
  272. return View::make('login');
  273. }
  274. public function handleLogin()
  275. {
  276. $validator = Validator::make(Input::all(), static::$rules);
  277. if (Auth::attempt(['username' => Input::get('username'), 'password' => Input::get('password')]))
  278. {
  279. //$role = Auth::user()->role;
  280. return Redirect::intended('/');
  281. }
  282. elseif((Input::get('password'))==NULL and Input::get('username'))
  283. {
  284. return Redirect::back()->withInput()->withErrors($validator)->with('view-error', ' A password is required to login.');
  285. }
  286. elseif((Input::get('username'))==NULL and Input::get('password'))
  287. {
  288. return Redirect::back()->withInput()->withErrors($validator)->with('view-error', 'An username is required to login.');
  289. }
  290. elseif($validator->fails())
  291. {
  292. return Redirect::back()->withInput()->withErrors($validator)->with('view-error', '<strong>Oops!</strong> No credentials entered.');
  293. }
  294. else
  295. {
  296. return Redirect::back()->withInput()->with('view-error', 'The username and password you entered do not correspond, please try again.');
  297. }
  298. }
  299. public function handleLogout()
  300. {
  301. Auth::logout();
  302. Session::flush();
  303. return Redirect::to('/');
  304. }
  305. public function publishTimeshareAgent($id)
  306. {
  307. DB::table('users')
  308. ->where('id','=', $id)
  309. ->update(array(
  310. 'timeshare_publish' => 1
  311. )
  312. );
  313. return Redirect::back()->withInput()->with('view-success', 'This agent has been successfully verified.');
  314. }
  315. public function publishTimeshare($id)
  316. {
  317. DB::table('timeshares')
  318. ->where('id','=', $id)
  319. ->update(array(
  320. 'published' => 1
  321. )
  322. );
  323. return Redirect::back()->withInput()->with('view-success', 'Timeshare successfully published.');
  324. }
  325. public function publishCommercial($id)
  326. {
  327. DB::table('commercials')
  328. ->where('id','=', $id)
  329. ->update(array(
  330. 'published' => 1
  331. )
  332. );
  333. return Redirect::back()->withInput()->with('view-success', 'Commercial property is successfully published.');
  334. }
  335. public function publishResidential($id)
  336. {
  337. DB::table('residentials')
  338. ->where('id','=', $id)
  339. ->update(array(
  340. 'published' => 1
  341. )
  342. );
  343. return Redirect::back()->withInput()->with('view-success', 'Residential property successfully published.');
  344. }
  345. public function serveInterested($id)
  346. {
  347. $timeshare = DB::table('timeshares')
  348. ->where('id','=',$id)
  349. ->first();
  350. return View::make('interested')
  351. ->with('timeshare',$timeshare);
  352. }
  353. public function handleInterested($id)
  354. {
  355. $timeshare = DB::table('timeshares')
  356. ->where('id','=',$id)
  357. ->first();
  358. $validator = Validator::make(Input::all(),
  359. [
  360. 'name' => 'required',
  361. 'email' => 'required'
  362. ]);
  363. if($validator->fails())
  364. {
  365. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  366. }
  367. $interested = new Interest;
  368. $interested->name = Input::get('name');
  369. $interested->email = Input::get('email');
  370. $interested->phone = Input::get('phone');
  371. $interested->mobile = Input::get('mobile');
  372. $interested->save();
  373. $data = ['interested' => $interested, 'timeshare' => $timeshare];
  374. Mail::send('emails.interested', $data, function($message)
  375. {
  376. $message->to('koketso.maphopha@gmail.com','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this resort');
  377. $message->from('info@univateproperties.co.za');
  378. });
  379. return Redirect::back()->with('view-success','Enquiry submitted.');
  380. }
  381. public function serveCommercialPropertyInterested($id)
  382. {
  383. $property = DB::table('commercials')
  384. ->where('id','=',$id)
  385. ->first();
  386. return View::make('interested-in-commercial-property')
  387. ->with('property',$property);
  388. }
  389. public function handleCommercialPropertyInterested($id)
  390. {
  391. $property = DB::table('commercials')
  392. ->where('id','=',$id)
  393. ->first();
  394. $validator = Validator::make(Input::all(),
  395. [
  396. 'name' => 'required',
  397. 'email' => 'required'
  398. ]);
  399. if($validator->fails())
  400. {
  401. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  402. }
  403. $interested = new Interest;
  404. $interested->name = Input::get('name');
  405. $interested->email = Input::get('email');
  406. $interested->phone = Input::get('phone');
  407. $interested->mobile = Input::get('mobile');
  408. $interested->save();
  409. $data = ['interested' => $interested, 'property' => $property];
  410. Mail::send('emails.interestedCommercialProperty', $data, function($message)
  411. {
  412. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this property');
  413. $message->from('info@univateproperties.co.za');
  414. });
  415. return Redirect::back()->with('view-success',' Enquiry submitted.');
  416. }
  417. public function serveResidentialPropertyInterested($id)
  418. {
  419. $property = DB::table('residentials')
  420. ->where('id','=',$id)
  421. ->first();
  422. return View::make('interest-in-residential-property')
  423. ->with('property',$property);
  424. }
  425. public function handleResidentialPropertyInterested($id)
  426. {
  427. $property = DB::table('residentials')
  428. ->where('id','=',$id)
  429. ->first();
  430. $validator = Validator::make(Input::all(),
  431. [
  432. 'name' => 'required',
  433. 'email' => 'required'
  434. ]);
  435. if($validator->fails())
  436. {
  437. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  438. }
  439. $interested = new Interest;
  440. $interested->name = Input::get('name');
  441. $interested->email = Input::get('email');
  442. $interested->phone = Input::get('phone');
  443. $interested->mobile = Input::get('mobile');
  444. $interested->save();
  445. $data = ['interested' => $interested, 'property' => $property];
  446. Mail::send('emails.interestedResidentialProperty', $data, function($message)
  447. {
  448. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this property');
  449. $message->from('info@univateproperties.co.za');
  450. });
  451. return Redirect::back()->with('view-success',' Enquiry submitted.');
  452. }
  453. public function serveResorts($province)
  454. {
  455. $resorts = DB::table('timeshares')
  456. ->where('region','=',$province)
  457. ->groupBy('resort')
  458. ->get();
  459. return View::make('resorts')
  460. ->with('province',$province)
  461. ->with('resorts',$resorts);
  462. }
  463. public function serveResort($slug)
  464. {
  465. $resort = DB::table('resorts')
  466. ->where('slug','=',$slug)
  467. ->first();
  468. $timeshares = DB::table('timeshares')
  469. ->where('resort','=',$resort->resort)
  470. ->where('published','=',1)
  471. ->paginate(5);
  472. $awards = explode(',',$resort->awards);
  473. $facilities = explode(',',$resort->facilities);
  474. //$wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/LE";
  475. //$details = json_decode(file_get_contents($wsdl), true);
  476. return View::make('resort')
  477. ->with('facilities',$facilities)
  478. ->with('awards',$awards)
  479. ->with('timeshares',$timeshares)
  480. ->with('resort',$resort);
  481. }
  482. public function serveEditTimeshare($id)
  483. {
  484. $timeshare = DB::table('timeshares')
  485. ->where('id','=',$id)
  486. ->first();
  487. return View::make('edit-timeshare')
  488. ->with('timeshare',$timeshare);
  489. }
  490. public function handleEditTimeshare($id)
  491. {
  492. $validator = Validator::make(Input::all(),
  493. [
  494. 'resort' => 'required',
  495. 'module' => 'required',
  496. 'week' => 'required',
  497. 'bedrooms' => 'required'
  498. ]);
  499. if($validator->fails())
  500. {
  501. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  502. }
  503. DB::table('timeshares')
  504. ->where('id','=', $id)
  505. ->update(array(
  506. 'resort' => Input::get('resort')
  507. )
  508. );
  509. DB::table('timeshares')
  510. ->where('id','=', $id)
  511. ->update(array(
  512. 'module' => Input::get('module')
  513. )
  514. );
  515. DB::table('timeshares')
  516. ->where('id','=', $id)
  517. ->update(array(
  518. 'week' => Input::get('week')
  519. )
  520. );
  521. DB::table('timeshares')
  522. ->where('id','=', $id)
  523. ->update(array(
  524. 'season' => Input::get('season')
  525. )
  526. );
  527. DB::table('timeshares')
  528. ->where('id','=', $id)
  529. ->update(array(
  530. 'region' => Input::get('region')
  531. )
  532. );
  533. DB::table('timeshares')
  534. ->where('id','=', $id)
  535. ->update(array(
  536. 'setPrice' => Input::get('setPrice')
  537. )
  538. );
  539. DB::table('timeshares')
  540. ->where('id','=', $id)
  541. ->update(array(
  542. 'price' => Input::get('price')
  543. )
  544. );
  545. DB::table('timeshares')
  546. ->where('id','=', $id)
  547. ->update(array(
  548. 'bedrooms' => Input::get('bedrooms')
  549. )
  550. );
  551. DB::table('timeshares')
  552. ->where('id','=', $id)
  553. ->update(array(
  554. 'sleeps' => Input::get('sleeps')
  555. )
  556. );
  557. DB::table('timeshares')
  558. ->where('id','=', $id)
  559. ->update(array(
  560. 'unit' => Input::get('unit')
  561. )
  562. );
  563. DB::table('timeshares')
  564. ->where('id','=', $id)
  565. ->update(array(
  566. 'owner' => Input::get('owner')
  567. )
  568. );
  569. DB::table('timeshares')
  570. ->where('id','=', $id)
  571. ->update(array(
  572. 'spacebankedyear' => Input::get('spacebankedyear')
  573. )
  574. );
  575. DB::table('timeshares')
  576. ->where('id','=', $id)
  577. ->update(array(
  578. 'spacebankOwner' => Input::get('spacebankOwner')
  579. )
  580. );
  581. if(Input::get('status')!='NULL'){
  582. DB::table('timeshares')
  583. ->where('id','=', $id)
  584. ->update(array(
  585. 'status' => Input::get('status')
  586. )
  587. );
  588. }
  589. if(Input::get('publish')!='NULL') {
  590. DB::table('timeshares')
  591. ->where('id','=', $id)
  592. ->update(array(
  593. 'published' => Input::get('publish')
  594. )
  595. );
  596. }
  597. if(Input::has('statusDate')) {
  598. DB::table('timeshares')
  599. ->where('id','=', $id)
  600. ->update(array(
  601. 'statusDate' => Input::get('statusDate')
  602. )
  603. );
  604. }
  605. return Redirect::to('admin')->with('view-success',' Timeshare successfully updated');
  606. }
  607. public function serveEditTimeshareAgent($id)
  608. {
  609. $user = DB::table('users')
  610. ->where('id','=',$id)
  611. ->first();
  612. return View::make('edit-timeshare-agent')
  613. ->with('user',$user);
  614. }
  615. public function handleEditTimeshareAgent($id)
  616. {
  617. $validator = Validator::make(Input::all(),
  618. [
  619. 'agency' => 'required'
  620. ]);
  621. if($validator->fails())
  622. {
  623. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  624. }
  625. DB::table('users')
  626. ->where('id','=', $id)
  627. ->update(array(
  628. 'name' => Input::get('name')
  629. )
  630. );
  631. DB::table('users')
  632. ->where('id','=', $id)
  633. ->update(array(
  634. 'email' => Input::get('email')
  635. )
  636. );
  637. DB::table('users')
  638. ->where('id','=', $id)
  639. ->update(array(
  640. 'phone' => Input::get('phone')
  641. )
  642. );
  643. DB::table('users')
  644. ->where('id','=', $id)
  645. ->update(array(
  646. 'mobile' => Input::get('mobile')
  647. )
  648. );
  649. DB::table('users')
  650. ->where('id','=', $id)
  651. ->update(array(
  652. 'username' => Input::get('username')
  653. )
  654. );
  655. DB::table('users')
  656. ->where('id','=', $id)
  657. ->update(array(
  658. 'EAAB_FFC_Number' => Input::get('EAAB-FFC-Number')
  659. )
  660. );
  661. DB::table('users')
  662. ->where('id','=', $id)
  663. ->update(array(
  664. 'agency' => Input::get('agency')
  665. )
  666. );
  667. DB::table('users')
  668. ->where('id','=', $id)
  669. ->update(array(
  670. 'registrationNum' => Input::get('registrationNum')
  671. )
  672. );
  673. if(Input::get('timeshare_publish')!='NULL') {
  674. DB::table('users')
  675. ->where('id','=', $id)
  676. ->update(array(
  677. 'timeshare_publish' => Input::get('timeshare_publish')
  678. )
  679. );
  680. }
  681. return Redirect::to('timeshare-agents')->with('view-success',' Agent details successfully updated');
  682. }
  683. public function serveEditCommercial($id)
  684. {
  685. $commercial = DB::table('commercials')
  686. ->where('id','=',$id)
  687. ->first();
  688. return View::make('admin.edit-commercial')
  689. ->with('commercial',$commercial);
  690. }
  691. public function handleEditCommercial($id)
  692. {
  693. $validator = Validator::make(Input::all(),
  694. [
  695. 'name' => 'required'
  696. ]);
  697. if($validator->fails())
  698. {
  699. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  700. }
  701. DB::table('commercials')
  702. ->where('id','=', $id)
  703. ->update(array(
  704. 'name' => Input::get('name')
  705. )
  706. );
  707. DB::table('commercials')
  708. ->where('id','=', $id)
  709. ->update(array(
  710. 'address' => Input::get('address')
  711. )
  712. );
  713. DB::table('commercials')
  714. ->where('id','=', $id)
  715. ->update(array(
  716. 'region' => Input::get('region')
  717. )
  718. );
  719. DB::table('commercials')
  720. ->where('id','=', $id)
  721. ->update(array(
  722. 'town' => Input::get('town')
  723. )
  724. );
  725. DB::table('commercials')
  726. ->where('id','=', $id)
  727. ->update(array(
  728. 'status2' => Input::get('status2')
  729. )
  730. );
  731. DB::table('commercials')
  732. ->where('id','=', $id)
  733. ->update(array(
  734. 'surburb' => Input::get('surburb')
  735. )
  736. );
  737. DB::table('commercials')
  738. ->where('id','=', $id)
  739. ->update(array(
  740. 'unit' => Input::get('unit')
  741. )
  742. );
  743. DB::table('commercials')
  744. ->where('id','=', $id)
  745. ->update(array(
  746. 'size' => Input::get('size')
  747. )
  748. );
  749. DB::table('commercials')
  750. ->where('id','=', $id)
  751. ->update(array(
  752. 'price' => Input::get('price')
  753. )
  754. );
  755. DB::table('commercials')
  756. ->where('id','=', $id)
  757. ->update(array(
  758. 'description' => Input::get('description')
  759. )
  760. );
  761. DB::table('commercials')
  762. ->where('id','=', $id)
  763. ->update(array(
  764. 'contact_person' => Input::get('contact_person')
  765. )
  766. );
  767. DB::table('commercials')
  768. ->where('id','=', $id)
  769. ->update(array(
  770. 'contact_email' => Input::get('contact_email')
  771. )
  772. );
  773. DB::table('commercials')
  774. ->where('id','=', $id)
  775. ->update(array(
  776. 'contact_mobile' => Input::get('contact_mobile')
  777. )
  778. );
  779. DB::table('commercials')
  780. ->where('id','=', $id)
  781. ->update(array(
  782. 'propertType' => Input::get('propertType')
  783. )
  784. );
  785. return Redirect::to('commercial-admin')->with('view-success',' Commercial property successfully updated');
  786. }
  787. public function serveEditResidential($id)
  788. {
  789. $residential = DB::table('residentials')
  790. ->where('id','=',$id)
  791. ->first();
  792. return View::make('admin.edit-residential')
  793. ->with('residential',$residential);
  794. }
  795. public function handleEditResidential($id)
  796. {
  797. $validator = Validator::make(Input::all(),
  798. [
  799. 'name' => 'required'
  800. ]);
  801. if($validator->fails())
  802. {
  803. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  804. }
  805. DB::table('residentials')
  806. ->where('id','=', $id)
  807. ->update(array(
  808. 'name' => Input::get('name')
  809. )
  810. );
  811. DB::table('residentials')
  812. ->where('id','=', $id)
  813. ->update(array(
  814. 'address' => Input::get('address')
  815. )
  816. );
  817. if(Input::get('region')!='') {
  818. DB::table('residentials')
  819. ->where('id','=', $id)
  820. ->update(array(
  821. 'region' => Input::get('region')
  822. )
  823. );
  824. }
  825. if(Input::get('town')!='') {
  826. DB::table('residentials')
  827. ->where('id','=', $id)
  828. ->update(array(
  829. 'town' => Input::get('town')
  830. )
  831. );
  832. }
  833. if(Input::get('status2')!='') {
  834. DB::table('residentials')
  835. ->where('id','=', $id)
  836. ->update(array(
  837. 'status2' => Input::get('status2')
  838. )
  839. );
  840. }
  841. if(Input::get('status')!='') {
  842. DB::table('residentials')
  843. ->where('id','=', $id)
  844. ->update(array(
  845. 'status' => Input::get('status')
  846. )
  847. );
  848. }
  849. if(Input::get('surburb')!='') {
  850. DB::table('residentials')
  851. ->where('id','=', $id)
  852. ->update(array(
  853. 'surburb' => Input::get('surburb')
  854. )
  855. );
  856. }
  857. DB::table('residentials')
  858. ->where('id','=', $id)
  859. ->update(array(
  860. 'unit' => Input::get('unit')
  861. )
  862. );
  863. DB::table('residentials')
  864. ->where('id','=', $id)
  865. ->update(array(
  866. 'size' => Input::get('size')
  867. )
  868. );
  869. DB::table('residentials')
  870. ->where('id','=', $id)
  871. ->update(array(
  872. 'price' => Input::get('price')
  873. )
  874. );
  875. DB::table('residentials')
  876. ->where('id','=', $id)
  877. ->update(array(
  878. 'description' => Input::get('description')
  879. )
  880. );
  881. DB::table('residentials')
  882. ->where('id','=', $id)
  883. ->update(array(
  884. 'contact_person' => Input::get('contact_person')
  885. )
  886. );
  887. DB::table('residentials')
  888. ->where('id','=', $id)
  889. ->update(array(
  890. 'contact_email' => Input::get('contact_email')
  891. )
  892. );
  893. DB::table('residentials')
  894. ->where('id','=', $id)
  895. ->update(array(
  896. 'contact_mobile' => Input::get('contact_mobile')
  897. )
  898. );
  899. DB::table('residentials')
  900. ->where('id','=', $id)
  901. ->update(array(
  902. 'bedrooms' => Input::get('bedrooms')
  903. )
  904. );
  905. DB::table('residentials')
  906. ->where('id','=', $id)
  907. ->update(array(
  908. 'bathrooms' => Input::get('bathrooms')
  909. )
  910. );
  911. if(Input::get('propertType')!='') {
  912. DB::table('residentials')
  913. ->where('id','=', $id)
  914. ->update(array(
  915. 'propertType' => Input::get('propertType')
  916. )
  917. );
  918. }
  919. return Redirect::to('residential-admin')->with('view-success',' Residential property successfully updated');
  920. }
  921. public function serveTermsConditions()
  922. {
  923. return View::make('terms-and-conditions');
  924. }
  925. public function deleteTimeshare($id)
  926. {
  927. DB::table('timeshares')
  928. ->where('id','=',$id)
  929. ->delete();
  930. return Redirect::to('admin')->with('view-success', ' SUCCESS: Timeshare Deleted');
  931. }
  932. public function deleteTimeshareAgent($id)
  933. {
  934. DB::table('users')
  935. ->where('id','=',$id)
  936. ->delete();
  937. return Redirect::to('timeshare-agents')->with('view-success', ' SUCCESS: Agent Deleted');
  938. }
  939. public function deleteResidential($id)
  940. {
  941. DB::table('residentials')
  942. ->where('id','=',$id)
  943. ->delete();
  944. return Redirect::to('residential-admin')->with('view-success', ' SUCCESS: Residential listing Deleted');
  945. }
  946. public function deleteCommercial($id)
  947. {
  948. DB::table('commercials')
  949. ->where('id','=',$id)
  950. ->delete();
  951. return Redirect::to('commercial-admin')->with('view-success', ' SUCCESS: Commercial listing Deleted');
  952. }
  953. public function handleContacts()
  954. {
  955. $validator = Validator::make(Input::all(),
  956. [
  957. 'name' => 'required',
  958. 'message' => 'required'
  959. ]);
  960. if($validator->fails())
  961. {
  962. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  963. }
  964. $contact = new Contact;
  965. $contact->name = Input::get('name');
  966. $contact->surname = Input::get('surname');
  967. $contact->cell = Input::get('cell');
  968. $contact->telephone = Input::get('telephone');
  969. $contact->email = Input::get('email');
  970. $contact->message = Input::get('message');
  971. $contact->save();
  972. $data = ['contact' => $contact];
  973. Mail::send('emails.contact', $data, function($message)
  974. {
  975. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Message from the Uni-vate Properties Contact Page');
  976. $message->from('info@univateproperties.co.za');
  977. });
  978. return Redirect::back()->with('view-success', 'Your message is submitted');
  979. }
  980. public function handleContactsResortPage($id)
  981. {
  982. $validator = Validator::make(Input::all(),
  983. [
  984. 'name' => 'required',
  985. 'email' => 'required',
  986. 'message' => 'required'
  987. ]);
  988. if($validator->fails())
  989. {
  990. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  991. }
  992. $resort = DB::table('resorts')
  993. ->where('id','=',$id)
  994. ->first();
  995. $contact = new ContactResort;
  996. $contact->name = Input::get('name');
  997. $contact->surname = Input::get('surname');
  998. $contact->cell = Input::get('cell');
  999. $contact->email = Input::get('email');
  1000. $contact->message = Input::get('message');
  1001. $contact->save();
  1002. $data = ['contact' => $contact, 'resort' => $resort];
  1003. Mail::send('emails.contactResort', $data, function($message) use ($resort)
  1004. {
  1005. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Message from the '.$resort->resort.' page.');
  1006. $message->from('info@univateproperties.co.za');
  1007. });
  1008. return Redirect::back()->with('view-success', 'Your message is submitted');
  1009. }
  1010. public function handleContactCommercial($id)
  1011. {
  1012. $validator = Validator::make(Input::all(),
  1013. [
  1014. 'name' => 'required',
  1015. 'email' => 'required',
  1016. 'message' => 'required',
  1017. 'property' => 'required'
  1018. ]);
  1019. if($validator->fails())
  1020. {
  1021. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1022. }
  1023. $contact = new Contact;
  1024. $contact->name = Input::get('name');
  1025. $contact->cell = Input::get('cell');
  1026. $contact->email = Input::get('email');
  1027. $contact->property = Input::get('property');
  1028. $contact->message = Input::get('message');
  1029. $contact->save();
  1030. $data = ['contact' => $contact];
  1031. Mail::send('emails.contactCommercial', $data, function($message) use ($contact)
  1032. {
  1033. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Message from the commercial properties page.');
  1034. $message->from('info@univateproperties.co.za');
  1035. });
  1036. return Redirect::back()->with('view-success', 'Your message is submitted');
  1037. }
  1038. public function serveSearch()
  1039. {
  1040. $validator = Validator::make(Input::all(),
  1041. [
  1042. 'search' => 'required',
  1043. ]);
  1044. if($validator->fails())
  1045. {
  1046. return Redirect::back()->with('view-error', 'No search entered, please try again')->withInput()->withErrors($validator);
  1047. }
  1048. $query = Input::get('search');
  1049. $timeshares = DB::table('timeshares')
  1050. ->where('resort', 'LIKE', '%' . $query . '%')//resort name
  1051. ->paginate(10);
  1052. if($timeshares->isEmpty())
  1053. {
  1054. return Redirect::back()->with('view-search-error', 'There were no results found, please try searching by resort name.');
  1055. }
  1056. else
  1057. {
  1058. // multiple resorts search results
  1059. return View::make('search-results')
  1060. ->with('timeshares', $timeshares);
  1061. }
  1062. }
  1063. public function serveCommercialSearch()
  1064. {
  1065. $validator = Validator::make(Input::all(),
  1066. [
  1067. 'search' => 'required',
  1068. ]);
  1069. if($validator->fails())
  1070. {
  1071. return Redirect::back()->with('view-error', 'No search entered, please try again')->withInput()->withErrors($validator);
  1072. }
  1073. $query = Input::get('search');
  1074. $commercials = DB::table('commercials')
  1075. ->where('name', 'LIKE', '%' . $query . '%')// property name
  1076. ->where('published','=',1)
  1077. ->paginate(10);
  1078. if($commercials->isEmpty())
  1079. {
  1080. return Redirect::back()->with('view-search-error', 'There were no results found, please try searching by property name.');
  1081. }
  1082. else
  1083. {
  1084. // multiple resorts search results
  1085. return View::make('commercial-search-results')
  1086. ->with('commercials', $commercials);
  1087. }
  1088. }
  1089. public function serveResidentialSearch()
  1090. {
  1091. $validator = Validator::make(Input::all(),
  1092. [
  1093. 'search' => 'required',
  1094. ]);
  1095. if($validator->fails())
  1096. {
  1097. return Redirect::back()->with('view-error', 'No search entered, please try again')->withInput()->withErrors($validator);
  1098. }
  1099. $query = Input::get('search');
  1100. $residentials = DB::table('residentials')
  1101. ->where('name', 'LIKE', '%' . $query . '%')// property name
  1102. ->where('published','=',1)
  1103. ->paginate(10);
  1104. if($residentials->isEmpty())
  1105. {
  1106. return Redirect::back()->with('view-search-error', 'There were no results found, please try searching by property name.');
  1107. }
  1108. else
  1109. {
  1110. // multiple resorts search results
  1111. return View::make('residential-search-result')
  1112. ->with('residentials', $residentials);
  1113. }
  1114. }
  1115. public function serveRegister()
  1116. {
  1117. return View::make('register');
  1118. }
  1119. public function handleRegister()
  1120. {
  1121. $validator = Validator::make(Input::all(),
  1122. [
  1123. 'name' => 'required',
  1124. 'surname' => 'required',
  1125. 'username' => 'required',
  1126. 'email' => 'required|email',
  1127. 'password' => 'required',
  1128. 'password1' => 'required'
  1129. ]);
  1130. $users = DB::table('users')
  1131. ->get();
  1132. foreach($users as $user){
  1133. if($user->username == Input::get('username'))
  1134. return Redirect::back()->with('view-error', ' This username already exists, please try a different username.')->withInput()->withErrors($validator);
  1135. }
  1136. foreach($users as $user){
  1137. if($user->email == Input::get('email'))
  1138. return Redirect::back()->with('view-error', ' This email account already exists, please login.')->withInput()->withErrors($validator);
  1139. }
  1140. if($validator->fails())
  1141. {
  1142. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1143. }
  1144. if((Input::get('password'))!=(Input::get('password1')))
  1145. {
  1146. return Redirect::back()->with('view-error', ' Passwords do not match')->withInput()->withErrors($validator);
  1147. }
  1148. $user = new User;
  1149. $user->name = Input::get('name');
  1150. $user->email = Input::get('email');
  1151. $user->phone = Input::get('phone');
  1152. $user->mobile = Input::get('mobile');
  1153. $user->surname = Input::get('surname');
  1154. $user->username = Input::get('username');
  1155. $user->password = Hash::make(Input::get('password'));
  1156. $user->role = 'user';
  1157. $user->save();
  1158. $data = ['user' => $user];
  1159. Mail::send('emails.register', $data, function($message) use ($user)
  1160. {
  1161. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New registration on www.univateproperties.co.za');
  1162. $message->from('info@univateproperties.co.za');
  1163. });
  1164. return Redirect::back()->with('view-success','You have successfully registered, your confirmation email will be in your inbox shortly.');
  1165. }
  1166. public function confirmationButton($email)
  1167. {
  1168. $user = DB::table('users')
  1169. ->where('email','=',$email)
  1170. ->first();
  1171. DB::table('users')
  1172. ->where('email','=', $email)
  1173. ->update(array(
  1174. 'verified' => 'yes'
  1175. )
  1176. );
  1177. return Redirect::to('login')->withInput()->with('view-success', 'Your email has been successfully verified. Please proceed to log in.');
  1178. }
  1179. public function LittleEden()
  1180. {
  1181. //$options = array('trace' => 1, 'exceptions' => 1);
  1182. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/LE";
  1183. $details = json_decode(file_get_contents($wsdl), true);
  1184. //dd($details['prName']);
  1185. $timeshares = DB::table('timeshares')
  1186. ->where('resort','=','little eden')
  1187. ->where('published','=',1)
  1188. ->paginate(5);
  1189. $resort = DB::table('resorts')
  1190. ->where('resort','=','little eden')
  1191. ->first();
  1192. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/LE/layout';
  1193. $details2 = base64_decode(file_get_contents($layout), true);
  1194. $awards = explode(',',$resort->awards);
  1195. return View::make('resorts.little-eden')
  1196. ->with('awards',$awards)
  1197. ->with('resort',$resort)
  1198. ->with('timeshares',$timeshares)
  1199. ->with('details',$details);
  1200. }
  1201. public function KaggaKamma()
  1202. {
  1203. //$options = array('trace' => 1, 'exceptions' => 1);
  1204. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/KK";
  1205. $details = json_decode(file_get_contents($wsdl), true);
  1206. //dd($details['prName']);
  1207. $timeshares = DB::table('timeshares')
  1208. ->where('resort','=','kagga kamma')
  1209. ->where('published','=',1)
  1210. ->paginate(5);
  1211. $resort = DB::table('resorts')
  1212. ->where('resort','=','kagga kamma')
  1213. ->first();
  1214. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/KK/layout';
  1215. $details2 = base64_decode(file_get_contents($layout), true);
  1216. $awards = explode(',',$resort->awards);
  1217. return View::make('resorts.kagga-kamma')
  1218. ->with('awards',$awards)
  1219. ->with('resort',$resort)
  1220. ->with('timeshares',$timeshares)
  1221. ->with('details',$details);
  1222. }
  1223. public function Mabalingwe()
  1224. {
  1225. return Redirect::to('/resort/mabalingwe');
  1226. }
  1227. public function Kridzil()
  1228. {
  1229. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/KRIDZ";
  1230. $details = json_decode(file_get_contents($wsdl), true);
  1231. $timeshares = DB::table('timeshares')
  1232. ->where('resort','=','KRIDZIL')
  1233. ->where('published','=',1)
  1234. ->paginate(5);
  1235. $resort = DB::table('resorts')
  1236. ->where('resort','=','KRIDZIL')
  1237. ->first();
  1238. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/KRIDZ/layout';
  1239. $details2 = base64_decode(file_get_contents($layout), true);
  1240. return View::make('resorts.kritzel')
  1241. ->with('resort',$resort)
  1242. ->with('timeshares',$timeshares)
  1243. ->with('details',$details);
  1244. }
  1245. public function SandyPlace()
  1246. {
  1247. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/SANDY";
  1248. $details = json_decode(file_get_contents($wsdl), true);
  1249. $timeshares = DB::table('timeshares')
  1250. ->where('resort','=','sandy place')
  1251. ->where('published','=',1)
  1252. ->paginate(5);
  1253. $resort = DB::table('resorts')
  1254. ->where('resort','=','sandy place')
  1255. ->first();
  1256. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/SANDY/layout';
  1257. $details2 = base64_decode(file_get_contents($layout), true);
  1258. $awards = explode(',',$resort->awards);
  1259. return View::make('resorts.sandy-place')
  1260. ->with('awards',$awards)
  1261. ->with('resort',$resort)
  1262. ->with('timeshares',$timeshares)
  1263. ->with('details',$details);
  1264. }
  1265. public function Uvongo()
  1266. {
  1267. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/URR";
  1268. $details = json_decode(file_get_contents($wsdl), true);
  1269. $timeshares = DB::table('timeshares')
  1270. ->where('resort','=','UVONGO RIVER RESORT')
  1271. ->where('published','=',1)
  1272. ->paginate(5);
  1273. $resort = DB::table('resorts')
  1274. ->where('resort','=','UVONGO RIVER RESORT')
  1275. ->first();
  1276. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/URR/layout';
  1277. $details2 = base64_decode(file_get_contents($layout), true);
  1278. $awards = explode(',',$resort->awards);
  1279. return View::make('resorts.uvongo')
  1280. ->with('awards',$awards)
  1281. ->with('resort',$resort)
  1282. ->with('timeshares',$timeshares)
  1283. ->with('details',$details);
  1284. }
  1285. public function Ngwenya()
  1286. {
  1287. $wsdl = "https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/NL";
  1288. $details = json_decode(file_get_contents($wsdl), true);
  1289. $timeshares = DB::table('timeshares')
  1290. ->where('resort','=','NGWENYA LODGE')
  1291. ->where('published','=',1)
  1292. ->paginate(5);
  1293. $resort = DB::table('resorts')
  1294. ->where('resort','=','NGWENYA LODGE')
  1295. ->first();
  1296. $layout = 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/NL/layout';
  1297. $details2 = base64_decode(file_get_contents($layout), true);
  1298. $awards = explode(',',$resort->awards);
  1299. return View::make('resorts.ngwenya')
  1300. ->with('awards',$awards)
  1301. ->with('resort',$resort)
  1302. ->with('timeshares',$timeshares)
  1303. ->with('details',$details);
  1304. }
  1305. public function Margate()
  1306. {
  1307. $timeshares = DB::table('timeshares')
  1308. ->where('resort','=','MARGATE BEACH CLUB')
  1309. ->where('published','=',1)
  1310. ->paginate(5);
  1311. return View::make('resorts.margate-beach-club')
  1312. ->with('timeshares',$timeshares);
  1313. }
  1314. public function Sudwala()
  1315. {
  1316. return Redirect::to('/resort/sudwala-lodge');
  1317. }
  1318. public function Verlorenkloof()
  1319. {
  1320. $timeshares = DB::table('timeshares')
  1321. ->where('resort','=','Verlorenkloof')
  1322. ->where('published','=',1)
  1323. ->paginate(5);
  1324. $resort = DB::table('resorts')
  1325. ->where('resort','=','Verlorenkloof')
  1326. ->first();
  1327. return View::make('resorts.verlorenkloof')
  1328. ->with('resort',$resort)
  1329. ->with('timeshares',$timeshares);
  1330. }
  1331. public function jackalberryRidge()
  1332. {
  1333. $timeshares = DB::table('timeshares')
  1334. ->where('resort','=','JACKALBERRY RIDGE')
  1335. ->where('published','=',1)
  1336. ->paginate(5);
  1337. $resort = DB::table('resorts')
  1338. ->where('resort','=','JACKALBERRY RIDGE')
  1339. ->first();
  1340. return View::make('resorts.jackalberry-ridge')
  1341. ->with('resort',$resort)
  1342. ->with('timeshares',$timeshares);
  1343. }
  1344. public function serveCommercialSales()
  1345. {
  1346. return View::make('commercial-sales');
  1347. }
  1348. public function serveCommercialRentals()
  1349. {
  1350. $rentals = DB::table('commercial_rentals')
  1351. ->where('published','=',1)
  1352. ->get();
  1353. return View::make('commercial-rentals')
  1354. ->with('rentals',$rentals);
  1355. }
  1356. public function serveResidentialSales()
  1357. {
  1358. $rentals = DB::table('residential_sales')
  1359. ->where('published','=',1)
  1360. ->get();
  1361. return View::make('residential-sales')
  1362. ->with('rentals',$rentals);
  1363. }
  1364. public function serveResidentialRentals()
  1365. {
  1366. $rentals = DB::table('residential_rentals')
  1367. ->where('published','=',1)
  1368. ->get();
  1369. return View::make('residential-rentals')
  1370. ->with('rentals',$rentals);
  1371. }
  1372. public function serveCommercialRental($name)
  1373. {
  1374. $rental = DB::table('commercial_rentals')
  1375. ->where('name','=',$name)
  1376. ->first();
  1377. return View::make('commercial-rental')
  1378. ->with('rental',$rental);
  1379. }
  1380. public function serveResidentialRental($name)
  1381. {
  1382. $rental = DB::table('residential_rentals')
  1383. ->where('name','=',$name)
  1384. ->first();
  1385. return View::make('residential-rental')
  1386. ->with('rental',$rental);
  1387. }
  1388. public function serveCommercial()
  1389. {
  1390. return View::make('commercial');
  1391. }
  1392. public function serveResidential()
  1393. {
  1394. return View::make('residential');
  1395. }
  1396. public function handleCommercial()
  1397. {
  1398. $for = Input::get('for');
  1399. $region = Input::get('region');
  1400. $town = Input::get('town');
  1401. $surburb = Input::get('surburb');
  1402. $propertType = Input::get('propertType');
  1403. $validator = Validator::make(Input::all(),
  1404. [
  1405. 'for' => 'required',
  1406. ]);
  1407. if($validator->fails())
  1408. {
  1409. return Redirect::back()->with('view-error', 'Please select For Sale or For Rent')->withInput()->withErrors($validator);
  1410. }
  1411. /*
  1412. $commercials = DB::table('commercials')
  1413. ->where(function($query) use ($for, $region, $town, $surburb, $propertType) {
  1414. if ($for)
  1415. $query->where('for','=', $for);
  1416. if ($region)
  1417. $query->where('region','=', $region);
  1418. if ($town)
  1419. $query->where('town','=', $town);
  1420. if ($surburb)
  1421. $query->where('surburb','=', $surburb);
  1422. if ($propertType)
  1423. $query->where('propertType','=', $propertType); })
  1424. ->where('published','=',1)
  1425. ->get(); */
  1426. $commercials = DB::table('properties')
  1427. ->where(function($query) use ($for, $region, $town, $surburb, $propertType) {
  1428. if ($for)
  1429. $query->where('for','=', $for);
  1430. if ($region)
  1431. $query->where('region','=', $region);
  1432. if ($town)
  1433. $query->where('town','=', $town);
  1434. if ($surburb)
  1435. $query->where('surburb','=', $surburb);
  1436. if ($propertType)
  1437. $query->where('propertType','=', $propertType); })
  1438. ->where('published','=',1)
  1439. ->get();
  1440. if($commercials->isEmpty())
  1441. {
  1442. return Redirect::back()->with('view-search-error', 'There were no results found.');
  1443. }
  1444. else
  1445. {
  1446. return View::make('commercial-results')
  1447. ->with('for',$for)
  1448. ->with('commercials',$commercials);
  1449. }
  1450. }
  1451. public function serveTimeshareResults()
  1452. {
  1453. return View::make('timeshare-results');
  1454. }
  1455. public function handleResidential()
  1456. {
  1457. $validator = Validator::make(Input::all(),
  1458. [
  1459. 'for' => 'required'
  1460. ]);
  1461. if($validator->fails())
  1462. {
  1463. return Redirect::back()->with('view-error', 'Please select For Sale or For Rent')->withInput()->withErrors($validator);
  1464. }
  1465. $for = Input::get('for');
  1466. $region = Input::get('region');
  1467. $town = Input::get('town');
  1468. $surburb = Input::get('surburb');
  1469. $propertType = Input::get('propertType');
  1470. $residentials = DB::table('residentials')
  1471. ->where(function($query) use ($for, $region, $town, $surburb, $propertType) {
  1472. if ($for)
  1473. $query->where('for','=', $for);
  1474. if ($region)
  1475. $query->where('region','=', $region);
  1476. if ($town)
  1477. $query->where('town','=', $town);
  1478. if ($surburb)
  1479. $query->where('surburb','=', $surburb);
  1480. if ($propertType)
  1481. $query->where('propertType','=', $propertType); })
  1482. ->where('published','=',1)
  1483. ->get();
  1484. if($residentials->isEmpty())
  1485. {
  1486. return Redirect::back()->with('view-search-error', 'There were no results found.');
  1487. }
  1488. else
  1489. {
  1490. return View::make('residential-results')
  1491. ->with('for',$for)
  1492. ->with('residentials',$residentials);
  1493. }
  1494. }
  1495. public function serveCommercialResults()
  1496. {
  1497. return View::make('commercial-results');
  1498. }
  1499. public function serveCommercialProperty($id)
  1500. {
  1501. $property = DB::table('commercials')
  1502. ->where('id','=',$id)
  1503. ->first();
  1504. return View::make('commercial-property')
  1505. ->with('property',$property);
  1506. }
  1507. public function serveResidentialProperty($id)
  1508. {
  1509. $property = DB::table('residentials')
  1510. ->where('id','=',$id)
  1511. ->first();
  1512. $facilities = explode(',',$property->facilities);
  1513. return View::make('residential-property')
  1514. ->with('facilities',$facilities)
  1515. ->with('property',$property);
  1516. }
  1517. public function serveListCommercialRental()
  1518. {
  1519. return View::make('list-commercial-rental');
  1520. }
  1521. public function handleListCommercialRental()
  1522. {
  1523. $validator = Validator::make(Input::all(),
  1524. [
  1525. 'region' => 'required',
  1526. 'address' => 'required',
  1527. 'image1' => 'required',
  1528. 'image2' => 'required'
  1529. ]);
  1530. if($validator->fails())
  1531. {
  1532. return Redirect::back()->with('view-error', ' Some information is incomplete in your submission please review below')->withInput()->withErrors($validator);
  1533. }
  1534. $commercial = new Commercial;
  1535. $commercial->name = Input::get('name');
  1536. $commercial->unit = Input::get('unit');
  1537. $commercial->address = Input::get('address');
  1538. $commercial->size = Input::get('size');
  1539. $commercial->region = Input::get('region');
  1540. $commercial->town = Input::get('town');
  1541. $commercial->opCost = Input::get('opCost');
  1542. $commercial->for = 'rental';
  1543. $commercial->description = Input::get('description');
  1544. $commercial->contact_person = Input::get('contact_person');
  1545. $commercial->contact_email = Input::get('contact_email');
  1546. $commercial->contact_mobile = Input::get('contact_mobile');
  1547. $commercial->surburb = Input::get('surburb');
  1548. $commercial->propertType = Input::get('propertType');
  1549. if (Input::hasFile('image1')) {
  1550. $file = Input::file('image1');
  1551. $file->move('img/', $file->getClientOriginalName());
  1552. $commercial->image2 = 'img/' . $file->getClientOriginalName();
  1553. }
  1554. if (Input::hasFile('image2')) {
  1555. $file = Input::file('image2');
  1556. $file->move('img/', $file->getClientOriginalName());
  1557. $commercial->image2 = 'img/' . $file->getClientOriginalName();
  1558. }
  1559. $commercial->save();
  1560. $data = ['commercial' => $commercial];
  1561. Mail::send('emails.commercial-rental-listing', $data, function($message)
  1562. {
  1563. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New Commercial Property Listing');
  1564. $message->from('info@univateproperties.co.za');
  1565. });
  1566. return Redirect::back()->with('view-success',' You have successfully submitted your property listing, an agent will contact you soon.');
  1567. }
  1568. public function serveListResidentialRental()
  1569. {
  1570. return View::make('list-residential-rental');
  1571. }
  1572. public function handleListResidentialRental()
  1573. {
  1574. $validator = Validator::make(Input::all(),
  1575. [
  1576. 'name' => 'required',
  1577. 'region' => 'required',
  1578. 'price' => 'required',
  1579. 'image1' => 'required',
  1580. 'image2' => 'required'
  1581. ]);
  1582. if($validator->fails())
  1583. {
  1584. return Redirect::back()->with('view-error', ' Some information is incomplete in your submission please review below')->withInput()->withErrors($validator);
  1585. }
  1586. $residential = new Residential;
  1587. $residential->name = Input::get('name');
  1588. $residential->ref = Input::get('ref');
  1589. $residential->size = Input::get('size');
  1590. $residential->region = Input::get('region');
  1591. $residential->town = Input::get('town');
  1592. $residential->bedrooms = Input::get('bedrooms');
  1593. $residential->bathrooms = Input::get('bathrooms');
  1594. $residential->contact_person = Input::get('contact_person');
  1595. $residential->contact_email = Input::get('contact_email');
  1596. $residential->contact_mobile = Input::get('contact_mobile');
  1597. $residential->for = 'rental';
  1598. $residential->description = Input::get('description');
  1599. $residential->surburb = Input::get('surburb');
  1600. $residential->propertType = Input::get('propertType');
  1601. if (Input::hasFile('image1')) {
  1602. $file = Input::file('image1');
  1603. $file->move('img/', $file->getClientOriginalName());
  1604. $residential->image1 = 'img/' . $file->getClientOriginalName();
  1605. }
  1606. if (Input::hasFile('image2')) {
  1607. $file = Input::file('image2');
  1608. $file->move('img/', $file->getClientOriginalName());
  1609. $residential->image2 = 'img/' . $file->getClientOriginalName();
  1610. }
  1611. $residential->save();
  1612. $data = ['residential' => $residential];
  1613. Mail::send('emails.residential-rental-listing', $data, function($message)
  1614. {
  1615. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New Residential Property Listing');
  1616. $message->from('info@univateproperties.co.za');
  1617. });
  1618. return Redirect::back()->with('view-success',' You have successfully submitted your property listing.');
  1619. }
  1620. public function serveListResidentialSale()
  1621. {
  1622. return View::make('list-residential-sale');
  1623. }
  1624. public function handleListResidentialSale()
  1625. {
  1626. $validator = Validator::make(Input::all(),
  1627. [
  1628. 'name' => 'required',
  1629. 'region' => 'required',
  1630. 'price' => 'required',
  1631. 'image1' => 'required',
  1632. 'image2' => 'required'
  1633. ]);
  1634. if($validator->fails())
  1635. {
  1636. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1637. }
  1638. $residential = new Residential;
  1639. $residential->name = Input::get('name');
  1640. $residential->ref = Input::get('ref');
  1641. $residential->size = Input::get('size');
  1642. $residential->region = Input::get('region');
  1643. $residential->town = Input::get('town');
  1644. $residential->bedrooms = Input::get('bedrooms');
  1645. $residential->bathrooms = Input::get('bathrooms');
  1646. $residential->contact_person = Input::get('contact_person');
  1647. $residential->contact_email = Input::get('contact_email');
  1648. $residential->contact_mobile = Input::get('contact_mobile');
  1649. $residential->for = 'Sale';
  1650. $residential->description = Input::get('description');
  1651. $residential->surburb = Input::get('surburb');
  1652. $residential->propertType = Input::get('propertType');
  1653. if (Input::hasFile('image1')) {
  1654. $file = Input::file('image1');
  1655. $file->move('img/', $file->getClientOriginalName());
  1656. $residential->image1 = 'img/' . $file->getClientOriginalName();
  1657. }
  1658. if (Input::hasFile('image2')) {
  1659. $file = Input::file('image2');
  1660. $file->move('img/', $file->getClientOriginalName());
  1661. $residential->image2 = 'img/' . $file->getClientOriginalName();
  1662. }
  1663. $residential->save();
  1664. $data = ['residential' => $residential];
  1665. Mail::send('emails.residential-sale-listing', $data, function($message)
  1666. {
  1667. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New Residential Property for sale Listing');
  1668. $message->from('info@univateproperties.co.za');
  1669. });
  1670. return Redirect::back()->with('view-success',' You have successfully submitted your property listing.');
  1671. }
  1672. public function serveListCommercialSale()
  1673. {
  1674. return View::make('list-commercial-sale');
  1675. }
  1676. public function handleListCommercialSale()
  1677. {
  1678. $validator = Validator::make(Input::all(),
  1679. [
  1680. 'name' => 'required',
  1681. 'region' => 'required',
  1682. 'price' => 'required',
  1683. 'image1' => 'required',
  1684. 'image2' => 'required'
  1685. ]);
  1686. if($validator->fails())
  1687. {
  1688. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1689. }
  1690. $commercial = new Commercial;
  1691. $commercial->name = Input::get('name');
  1692. $commercial->ref = Input::get('ref');
  1693. $commercial->size = Input::get('size');
  1694. $commercial->region = Input::get('region');
  1695. $commercial->town = Input::get('town');
  1696. $commercial->contact_person = Input::get('contact_person');
  1697. $commercial->contact_email = Input::get('contact_email');
  1698. $commercial->contact_mobile = Input::get('contact_mobile');
  1699. $commercial->opCost = Input::get('opCost');
  1700. $commercial->for = 'Sale';
  1701. $commercial->description = Input::get('description');
  1702. $commercial->surburb = Input::get('surburb');
  1703. $commercial->propertType = Input::get('propertType');
  1704. if (Input::hasFile('image1')) {
  1705. $file = Input::file('image1');
  1706. $file->move('img/', $file->getClientOriginalName());
  1707. $commercial->image1 = 'img/' . $file->getClientOriginalName();
  1708. }
  1709. if (Input::hasFile('image2')) {
  1710. $file = Input::file('image2');
  1711. $file->move('img/', $file->getClientOriginalName());
  1712. $commercial->image2 = 'img/' . $file->getClientOriginalName();
  1713. }
  1714. $commercial->save();
  1715. $data = ['commercial' => $commercial];
  1716. Mail::send('emails.commercial-sale-listing', $data, function($message)
  1717. {
  1718. $message->to('info@univateproperties.co.za','Info')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New Commercial Property for sale Listing');
  1719. $message->from('info@univateproperties.co.za');
  1720. });
  1721. return Redirect::back()->with('view-success',' You have successfully submitted your property listing.');
  1722. }
  1723. public function backButtonCommercial($for)
  1724. {
  1725. $commercials = DB::table('commercials')
  1726. ->where('for','=',$for)
  1727. ->get();
  1728. return View::make('commercial-results')
  1729. ->with('commercials',$commercials)
  1730. ->with('for',$for);
  1731. }
  1732. public function backButtonResidential($for)
  1733. {
  1734. $residentials = DB::table('residentials')
  1735. ->where('for','=',$for)
  1736. ->get();
  1737. return View::make('residential-results')
  1738. ->with('residentials',$residentials)
  1739. ->with('for',$for);
  1740. }
  1741. public function serveCSI()
  1742. {
  1743. return View::make('csi');
  1744. }
  1745. public function back()
  1746. {
  1747. return redirect()->back();
  1748. }
  1749. public function officeParks()
  1750. {
  1751. $mooikloof = DB::table('commercials')
  1752. ->where('surburb','=','Mooikloof')
  1753. ->get();
  1754. $query = 'Lombardy Business Park';
  1755. $lombardy = DB::table('commercials')
  1756. ->where('name', 'LIKE', '%' . $query . '%')
  1757. ->get();
  1758. return View::make('office-parks')
  1759. ->with('mooikloof',$mooikloof)
  1760. ->with('lombardy',$lombardy);
  1761. }
  1762. public function Lombardy()
  1763. {
  1764. $lombardy = DB::table('commercials')
  1765. ->where('name','=','Lombardy Business Park')
  1766. ->paginate(6);
  1767. $property = DB::table('commercials')
  1768. ->where('name','=','Lombardy Business Park')
  1769. ->first();
  1770. $facilities = explode(',',$property->facilities);
  1771. return View::make('lombardy')
  1772. ->with('property',$property)
  1773. ->with('facilities',$facilities)
  1774. ->with('lombardy',$lombardy);
  1775. }
  1776. public function handleInterestedLombardy($id)
  1777. {
  1778. $unit = DB::table('commercials')
  1779. ->where('id','=',$id)
  1780. ->first();
  1781. $validator = Validator::make(Input::all(),
  1782. [
  1783. 'name' => 'required',
  1784. 'email' => 'required'
  1785. ]);
  1786. if($validator->fails())
  1787. {
  1788. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1789. }
  1790. $interested = new Interest;
  1791. $interested->name = Input::get('name');
  1792. $interested->email = Input::get('email');
  1793. $interested->phone = Input::get('phone');
  1794. $interested->mobile = Input::get('mobile');
  1795. $interested->save();
  1796. $data = ['interested' => $interested, 'unit' => $unit];
  1797. Mail::send('emails.interestedLombardy', $data, function($message)
  1798. {
  1799. $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');
  1800. $message->from('info@univateproperties.co.za');
  1801. });
  1802. return Redirect::back()->with('view-success','Enquiry submitted.');
  1803. }
  1804. public function Mooikloof()
  1805. {
  1806. $mooikloof = DB::table('commercials')
  1807. ->where('name','=','Mooikloof Office Park')
  1808. ->paginate(6);
  1809. $property = DB::table('commercials')
  1810. ->where('name','=','Mooikloof Office Park')
  1811. ->first();
  1812. $facilities = explode(',',$property->facilities);
  1813. return View::make('mooikloof')
  1814. ->with('property',$property)
  1815. ->with('facilities',$facilities)
  1816. ->with('mooikloof',$mooikloof);
  1817. }
  1818. public function handleInterestedMooikloof($id)
  1819. {
  1820. $unit = DB::table('commercials')
  1821. ->where('id','=',$id)
  1822. ->first();
  1823. $validator = Validator::make(Input::all(),
  1824. [
  1825. 'name' => 'required',
  1826. 'email' => 'required'
  1827. ]);
  1828. if($validator->fails())
  1829. {
  1830. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1831. }
  1832. $interested = new Interest;
  1833. $interested->name = Input::get('name');
  1834. $interested->email = Input::get('email');
  1835. $interested->phone = Input::get('phone');
  1836. $interested->mobile = Input::get('mobile');
  1837. $interested->save();
  1838. $data = ['interested' => $interested, 'unit' => $unit];
  1839. Mail::send('emails.interestedMooikloof', $data, function($message)
  1840. {
  1841. $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');
  1842. $message->from('info@univateproperties.co.za');
  1843. });
  1844. return Redirect::back()->with('view-success','Enquiry submitted.');
  1845. }
  1846. public function handleInterestProperty($id)
  1847. {
  1848. $unit = DB::table('commercials')
  1849. ->where('id','=',$id)
  1850. ->first();
  1851. $validator = Validator::make(Input::all(),
  1852. [
  1853. 'name' => 'required',
  1854. 'email' => 'required'
  1855. ]);
  1856. if($validator->fails())
  1857. {
  1858. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1859. }
  1860. $interested = new Interest;
  1861. $interested->name = Input::get('name');
  1862. $interested->email = Input::get('email');
  1863. $interested->phone = Input::get('phone');
  1864. $interested->mobile = Input::get('mobile');
  1865. $interested->save();
  1866. $data = ['interested' => $interested, 'unit' => $unit];
  1867. Mail::send('emails.interestedProperty', $data, function($message)
  1868. {
  1869. $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');
  1870. $message->from('info@univateproperties.co.za');
  1871. });
  1872. return Redirect::back()->with('view-success','Enquiry submitted.');
  1873. }
  1874. public function handleInterestProperty2($id)
  1875. {
  1876. $unit = DB::table('residentials')
  1877. ->where('id','=',$id)
  1878. ->first();
  1879. $validator = Validator::make(Input::all(),
  1880. [
  1881. 'name' => 'required',
  1882. 'email' => 'required'
  1883. ]);
  1884. if($validator->fails())
  1885. {
  1886. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1887. }
  1888. $interested = new Interest;
  1889. $interested->name = Input::get('name');
  1890. $interested->email = Input::get('email');
  1891. $interested->phone = Input::get('phone');
  1892. $interested->mobile = Input::get('mobile');
  1893. $interested->save();
  1894. $data = ['interested' => $interested, 'unit' => $unit];
  1895. Mail::send('emails.interestedProperty', $data, function($message)
  1896. {
  1897. $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');
  1898. $message->from('info@univateproperties.co.za');
  1899. });
  1900. return Redirect::back()->with('view-success','Enquiry submitted.');
  1901. }
  1902. public function serveTimeshareEnquiry($id)
  1903. {
  1904. $timeshare = DB::table('timeshares')
  1905. ->where('id','=',$id)
  1906. ->first();
  1907. $resort = DB::table('resorts')
  1908. ->where('resort','=',$timeshare->resort)
  1909. ->first();
  1910. return View::make('timeshare-enquiry')
  1911. ->with('resort',$resort)
  1912. ->with('timeshare',$timeshare);
  1913. }
  1914. public function handleTimeshareEnquiry($id)
  1915. {
  1916. $timeshare = DB::table('timeshares')
  1917. ->where('id','=',$id)
  1918. ->first();
  1919. $validator = Validator::make(Input::all(),
  1920. [
  1921. 'name' => 'required',
  1922. 'email' => 'required'
  1923. ]);
  1924. if($validator->fails())
  1925. {
  1926. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1927. }
  1928. $interested = new Interest;
  1929. $interested->name = Input::get('name');
  1930. $interested->email = Input::get('email');
  1931. $interested->mobile = Input::get('mobile');
  1932. $interested->save();
  1933. $data = ['interested' => $interested, 'timeshare' => $timeshare];
  1934. Mail::send('emails.interestedTimeshare', $data, function($message)
  1935. {
  1936. $message->to('koketso.maphopha@gmail.com','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in this timeshare');
  1937. $message->from('info@univateproperties.co.za');
  1938. });
  1939. return Redirect::back()->with('view-success','Enquiry submitted.');
  1940. }
  1941. public function serveShareTransferInitiation()
  1942. {
  1943. return View::make('share-transfer-initiation-for-seller');
  1944. }
  1945. public function handleShareTransferIntiation()
  1946. {
  1947. $validator = Validator::make(Input::all(),
  1948. [
  1949. 'paid' => 'required',
  1950. 'spaceBanked' => 'required',
  1951. 'date' => 'required',
  1952. 'purchasePrice' => 'required',
  1953. 'sellingPrice' => 'required',
  1954. 'estateAgency' => 'required',
  1955. 'commission' => 'required'
  1956. ]);
  1957. if($validator->fails())
  1958. {
  1959. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1960. }
  1961. $seller = new Seller;
  1962. $seller->paid = Input::get('paid');
  1963. $seller->rental = Input::get('rental');
  1964. $seller->spaceBanked = Input::get('spaceBanked');
  1965. $seller->date = Input::get('date');
  1966. $seller->purchasePrice = Input::get('purchasePrice');
  1967. $seller->sellingPrice = Input::get('sellingPrice');
  1968. $seller->estateAgency = Input::get('estateAgency');
  1969. $seller->commission = Input::get('commission');
  1970. $seller->save();
  1971. $data = ['seller' => $seller];
  1972. Mail::send('emails.seller', $data, function($message)
  1973. {
  1974. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Share Transfer Intiation for Seller');
  1975. $message->from('info@univateproperties.co.za');
  1976. });
  1977. return Redirect::back()->with('view-success','Your information has been successfully been submitted.');
  1978. }
  1979. public function serveShareTransferInitiationForPurchaser($id)
  1980. {
  1981. $timeshare = DB::table('timeshares')
  1982. ->where('id','=',$id)
  1983. ->first();
  1984. return View::make('share-transfer-initiation-for-purchaser')
  1985. ->with('timeshare',$timeshare);
  1986. }
  1987. public function handleShareTransferInitiationForPurchaser($id)
  1988. {
  1989. $validator = Validator::make(Input::all(),
  1990. [
  1991. 'name' => 'required',
  1992. 'maritalStatus' => 'required',
  1993. 'physicalAddress' => 'required',
  1994. 'postalAddress' => 'required'
  1995. ]);
  1996. if($validator->fails())
  1997. {
  1998. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  1999. }
  2000. $timeshare = DB::table('timeshares')
  2001. ->where('id','=',$id)
  2002. ->first();
  2003. $transfer = new Transfer;
  2004. $transfer->name = Input::get('name');
  2005. $transfer->IDNumber = Input::get('IDNumber');
  2006. $transfer->PassportNumber = Input::get('PassportNumber');
  2007. $transfer->maritalStatus = Input::get('maritalStatus');
  2008. $transfer->marriedIn = Input::get('marriedIn');
  2009. $transfer->otherMeans = Input::get('otherMeans');
  2010. $transfer->tax = Input::get('tax');
  2011. $transfer->annualIncome = Input::get('annualIncome');
  2012. $transfer->physicalAddress = Input::get('physicalAddress');
  2013. $transfer->postalAddress = Input::get('postalAddress');
  2014. $transfer->telephone1 = Input::get('telephone1');
  2015. $transfer->telephone2 = Input::get('telephone2');
  2016. $transfer->phone1 = Input::get('phone1');
  2017. $transfer->phone2 = Input::get('phone2');
  2018. $transfer->fax1 = Input::get('fax1');
  2019. $transfer->fax2 = Input::get('fax2');
  2020. $transfer->email1 = Input::get('email1');
  2021. $transfer->email2 = Input::get('email2');
  2022. $transfer->resort = Input::get('resort');
  2023. $transfer->unit = Input::get('unit');
  2024. $transfer->module = Input::get('module');
  2025. $transfer->price = Input::get('price');
  2026. $transfer->year = Input::get('year');
  2027. $transfer->confirmInfo = Input::get('confirmInfo');
  2028. $transfer->sign = Input::get('sign');
  2029. $transfer->save();
  2030. DB::table('timeshares')
  2031. ->where('id','=', $id)
  2032. ->update(array(
  2033. 'status' => 'Offer Pending'
  2034. )
  2035. );
  2036. $data = ['transfer' => $transfer];
  2037. Mail::send('emails.transfer', $data, function($message)
  2038. {
  2039. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('Share Transfer Intiation for Purchaser');
  2040. $message->from('info@univateproperties.co.za');
  2041. });
  2042. return Redirect::back()->with('view-success','Your information has been successfully been submitted.');
  2043. }
  2044. public function import()
  2045. {
  2046. Excel::import(new TimesharesImport, Input::file('ex_file'));
  2047. return redirect('/')->with('view-success', 'All good!');
  2048. }
  2049. public function serveLombardyEnquiry($id)
  2050. {
  2051. $unit = DB::table('commercials')
  2052. ->where('id','=',$id)
  2053. ->first();
  2054. return View::make('lombardy-enquiry')
  2055. ->with('unit',$unit);
  2056. }
  2057. public function handleLombardyEnquiry($id)
  2058. {
  2059. $unit = DB::table('commercials')
  2060. ->where('id','=',$id)
  2061. ->first();
  2062. $validator = Validator::make(Input::all(),
  2063. [
  2064. 'name' => 'required',
  2065. 'email' => 'required'
  2066. ]);
  2067. if($validator->fails())
  2068. {
  2069. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2070. }
  2071. $interested = new Interest;
  2072. $interested->name = Input::get('name');
  2073. $interested->email = Input::get('email');
  2074. $interested->mobile = Input::get('mobile');
  2075. $interested->save();
  2076. $data = ['interested' => $interested, 'unit' => $unit];
  2077. Mail::send('emails.interestedLombardy', $data, function($message)
  2078. {
  2079. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in Lombardy Unit');
  2080. $message->from('info@univateproperties.co.za');
  2081. });
  2082. return Redirect::back()->with('view-success','Enquiry submitted.');
  2083. }
  2084. public function serveMooikloofEnquiry($id)
  2085. {
  2086. $unit = DB::table('commercials')
  2087. ->where('id','=',$id)
  2088. ->first();
  2089. return View::make('mooikloof-enquiry')
  2090. ->with('unit',$unit);
  2091. }
  2092. public function handleMooikloofEnquiry($id)
  2093. {
  2094. $unit = DB::table('commercials')
  2095. ->where('id','=',$id)
  2096. ->first();
  2097. $validator = Validator::make(Input::all(),
  2098. [
  2099. 'name' => 'required',
  2100. 'email' => 'required'
  2101. ]);
  2102. if($validator->fails())
  2103. {
  2104. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2105. }
  2106. $interested = new Interest;
  2107. $interested->name = Input::get('name');
  2108. $interested->email = Input::get('email');
  2109. $interested->mobile = Input::get('mobile');
  2110. $interested->save();
  2111. $data = ['interested' => $interested, 'unit' => $unit];
  2112. Mail::send('emails.interestedMooikloof', $data, function($message)
  2113. {
  2114. $message->to('info@univateproperties.co.za','Uni-vate')->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('I am interested in Mooikloof Unit');
  2115. $message->from('info@univateproperties.co.za');
  2116. });
  2117. return Redirect::back()->with('view-success','Enquiry submitted.');
  2118. }
  2119. public function makeOffer()
  2120. {
  2121. return View::make('share-transfer-initiation-for-purchaser');
  2122. }
  2123. public function serveSuccessfulPayment()
  2124. {
  2125. /*DB::table('timeshares')
  2126. ->where('id','=', $id)
  2127. ->update(array(
  2128. 'listingFee' => 1
  2129. )
  2130. ); */
  2131. return View::make('successful-payment');
  2132. }
  2133. public function serveRegisterAgent()
  2134. {
  2135. return View::make('register-agent');
  2136. }
  2137. public function handleAgentRegister()
  2138. {
  2139. }
  2140. public function serveMyTimeshares()
  2141. {
  2142. $timeshares = DB::table('timeshares')
  2143. ->where('names','=',Auth::user()->name)
  2144. ->paginate(10);
  2145. return View::make('my-timeshares')
  2146. ->with('timeshares',$timeshares);
  2147. }
  2148. public function serveMyResidentialProperties()
  2149. {
  2150. $residentials = DB::table('residentials')
  2151. ->where('contact_person','=',Auth::user()->name)
  2152. ->paginate(10);
  2153. return View::make('my-residential-properties')
  2154. ->with('residentials',$residentials);
  2155. }
  2156. public function serveMyCommercialProperties()
  2157. {
  2158. $commercials = DB::table('commercials')
  2159. ->where('contact_person','=',Auth::user()->name)
  2160. ->paginate(10);
  2161. return View::make('my-commercial-properties')
  2162. ->with('commercials',$commercials);
  2163. }
  2164. public function serveRegisterTimeshareAgent()
  2165. {
  2166. $agencies = DB::table('agencies')
  2167. ->get();
  2168. return View::make('register-timeshare-agent')
  2169. ->with('agencies',$agencies);
  2170. }
  2171. public function handleRegisterTimeshareAgent()
  2172. {
  2173. $validator = Validator::make(Input::all(),
  2174. [
  2175. 'name' => 'required',
  2176. 'email' => 'required',
  2177. 'username' => 'required'
  2178. ]);
  2179. if($validator->fails())
  2180. {
  2181. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2182. }
  2183. if((Input::get('password'))!=(Input::get('password1')))
  2184. {
  2185. return Redirect::back()->with('view-error', ' Passwords do not match')->withInput()->withErrors($validator);
  2186. }
  2187. $user = new User;
  2188. $user->name = Input::get('name');
  2189. $user->email = Input::get('email');
  2190. $user->phone = Input::get('phone');
  2191. $user->mobile = Input::get('mobile');
  2192. $user->username = Input::get('username');
  2193. $user->password = Hash::make(Input::get('password'));
  2194. $user->EAAB_FFC_Number = Input::get('EAAB-FFC-Number');
  2195. $user->agency = Input::get('agency');
  2196. $user->registrationNum = Input::get('registrationNum');
  2197. $user->role = 'user';
  2198. $user->timeshare = '1';
  2199. $user->role = 'user';
  2200. $user->save();
  2201. $data = ['user' => $user];
  2202. Mail::send('emails.register', $data, function($message) use ($user)
  2203. {
  2204. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New registration on www.univateproperties.co.za');
  2205. $message->from('info@univateproperties.co.za');
  2206. });
  2207. return Redirect::back()->with('view-success','You have successfully registered.');
  2208. }
  2209. public function serveTimeshareAgents()
  2210. {
  2211. $myAgency = Auth::user()->agency;
  2212. $agents = DB::table('users')
  2213. ->where('agency','=',$myAgency)
  2214. ->paginate(10);
  2215. return View::make('timeshare-agents')
  2216. ->with('agents',$agents);
  2217. }
  2218. public function serveRegisterCommercialAgent()
  2219. {
  2220. return View::make('register-commercial-agent');
  2221. }
  2222. public function handleRegisterCommercialAgent()
  2223. {
  2224. $validator = Validator::make(Input::all(),
  2225. [
  2226. 'EAAB-FFC-Number' => 'required',
  2227. 'agency' => 'required',
  2228. 'registrationNum' => 'required'
  2229. ]);
  2230. if($validator->fails())
  2231. {
  2232. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2233. }
  2234. if((Input::get('password'))!=(Input::get('password1')))
  2235. {
  2236. return Redirect::back()->with('view-error', ' Passwords do not match')->withInput()->withErrors($validator);
  2237. }
  2238. if(!Auth::check())
  2239. {
  2240. $user = new User;
  2241. $user->name = Input::get('name');
  2242. $user->email = Input::get('email');
  2243. $user->phone = Input::get('phone');
  2244. $user->mobile = Input::get('mobile');
  2245. $user->username = Input::get('username');
  2246. $user->password = Hash::make(Input::get('password'));
  2247. $user->EAAB_FFC_Number = Input::get('EAAB-FFC-Number');
  2248. $user->agency = Input::get('agency');
  2249. $user->registrationNum = Input::get('registrationNum');
  2250. $user->commercial = '1';
  2251. $user->role = 'user';
  2252. $user->save();
  2253. $data = ['user' => $user];
  2254. Mail::send('emails.register', $data, function($message) use ($user)
  2255. {
  2256. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New registration on www.univateproperties.co.za');
  2257. $message->from('info@univateproperties.co.za');
  2258. });
  2259. }
  2260. else{
  2261. $users = DB::table('users')
  2262. ->get();
  2263. /*
  2264. foreach($users as $user){
  2265. if($user->username == Input::get('username'))
  2266. return Redirect::back()->with('view-error', ' This username already exists, please try a different username.')->withInput()->withErrors($validator);
  2267. }
  2268. foreach($users as $user){
  2269. if($user->email == Input::get('email'))
  2270. return Redirect::back()->with('view-error', ' This email account already exists, please login.')->withInput()->withErrors($validator);
  2271. } */
  2272. $user = DB::table('users')
  2273. ->where('id','=',Auth::user()->id)
  2274. ->first();
  2275. DB::table('users')
  2276. ->where('id','=', Auth::user()->id)
  2277. ->update(array(
  2278. 'EAAB_FFC_Number' => Input::get('EAAB-FFC-Number')
  2279. )
  2280. );
  2281. DB::table('users')
  2282. ->where('id','=', Auth::user()->id)
  2283. ->update(array(
  2284. 'agency' => Input::get('agency')
  2285. )
  2286. );
  2287. DB::table('users')
  2288. ->where('id','=', Auth::user()->id)
  2289. ->update(array(
  2290. 'registrationNum' => Input::get('registrationNum')
  2291. )
  2292. );
  2293. }
  2294. return Redirect::back()->with('view-success','You have successfully registered.');
  2295. }
  2296. public function serveCommercialAgents()
  2297. {
  2298. $agents = DB::table('users')
  2299. ->where('commercial','=','1')
  2300. ->paginate(10);
  2301. if (Auth::check() && Auth::user()->role == "admin") {
  2302. return View::make('commercial-agents')
  2303. ->with('agents',$agents);
  2304. }else{
  2305. return Redirect::to('/');
  2306. }
  2307. }
  2308. public function serveRegisterResidentialAgent()
  2309. {/*
  2310. $user = new User;
  2311. $user->name = 'Arlene';
  2312. $user->email = 'admin1@univateproperties.co.za';
  2313. $user->phone ='+27 (0) 12 492 1238';
  2314. $user->mobile = '+27 (0) 12 492 1238';
  2315. $user->surname = '';
  2316. $user->username = 'Admin1';
  2317. $user->password = Hash::make('Admin1');
  2318. $user->role = 'admin';
  2319. $user->save();
  2320. $user1 = new User;
  2321. $user1->name = 'Caitlinf';
  2322. $user1->email = 'admin2@univateproperties.co.za';
  2323. $user1->phone = '+27 (0) 12 492 1238';
  2324. $user1->mobile = '+27 (0) 12 492 1238';
  2325. $user1->surname = '';
  2326. $user1->username = 'Admin2';
  2327. $user1->password = Hash::make('Admin2');
  2328. $user1->role = 'admin';
  2329. $user1->save(); */
  2330. return View::make('register-residential-agent');
  2331. }
  2332. public function handleRegisterResidentialAgent()
  2333. {
  2334. $validator = Validator::make(Input::all(),
  2335. [
  2336. 'EAAB-FFC-Number' => 'required',
  2337. 'agency' => 'required',
  2338. 'registrationNum' => 'required'
  2339. ]);
  2340. if($validator->fails())
  2341. {
  2342. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2343. }
  2344. if((Input::get('password'))!=(Input::get('password1')))
  2345. {
  2346. return Redirect::back()->with('view-error', ' Passwords do not match')->withInput()->withErrors($validator);
  2347. }
  2348. if(!Auth::check())
  2349. {
  2350. $user = new User;
  2351. $user->name = Input::get('name');
  2352. $user->email = Input::get('email');
  2353. $user->phone = Input::get('phone');
  2354. $user->mobile = Input::get('mobile');
  2355. $user->username = Input::get('username');
  2356. $user->password = Hash::make(Input::get('password'));
  2357. $user->EAAB_FFC_Number = Input::get('EAAB-FFC-Number');
  2358. $user->agency = Input::get('agency');
  2359. $user->registrationNum = Input::get('registrationNum');
  2360. $user->residential = '1';
  2361. $user->role = 'user';
  2362. $user->save();
  2363. $data = ['user' => $user];
  2364. Mail::send('emails.register', $data, function($message) use ($user)
  2365. {
  2366. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New registration on www.univateproperties.co.za');
  2367. $message->from('info@univateproperties.co.za');
  2368. });
  2369. }
  2370. else{
  2371. $users = DB::table('users')
  2372. ->get();
  2373. /*
  2374. foreach($users as $user){
  2375. if($user->username == Input::get('username'))
  2376. return Redirect::back()->with('view-error', ' This username already exists, please try a different username.')->withInput()->withErrors($validator);
  2377. }
  2378. foreach($users as $user){
  2379. if($user->email == Input::get('email'))
  2380. return Redirect::back()->with('view-error', ' This email account already exists, please login.')->withInput()->withErrors($validator);
  2381. } */
  2382. $user = DB::table('users')
  2383. ->where('id','=',Auth::user()->id)
  2384. ->first();
  2385. DB::table('users')
  2386. ->where('id','=', Auth::user()->id)
  2387. ->update(array(
  2388. 'EAAB_FFC_Number' => Input::get('EAAB-FFC-Number')
  2389. )
  2390. );
  2391. DB::table('users')
  2392. ->where('id','=', Auth::user()->id)
  2393. ->update(array(
  2394. 'agency' => Input::get('agency')
  2395. )
  2396. );
  2397. DB::table('users')
  2398. ->where('id','=', Auth::user()->id)
  2399. ->update(array(
  2400. 'registrationNum' => Input::get('registrationNum')
  2401. )
  2402. );
  2403. }
  2404. return Redirect::back()->with('view-success','You have successfully registered.');
  2405. }
  2406. public function serveResidentialAgents()
  2407. {
  2408. $agents = DB::table('users')
  2409. ->where('residential','=','1')
  2410. ->paginate(10);
  2411. if (Auth::check() && Auth::user()->role == "admin") {
  2412. return View::make('residential-agents')
  2413. ->with('agents',$agents);
  2414. }else{
  2415. return Redirect::to('/');
  2416. }
  2417. }
  2418. public function serveRegisterAgency()
  2419. {
  2420. return View::make('register-agency');
  2421. }
  2422. public function handleRegisterAgency()
  2423. {
  2424. $validator = Validator::make(Input::all(),
  2425. [
  2426. 'EAAB-FFC-Number' => 'required',
  2427. 'agency' => 'required',
  2428. 'registrationNum' => 'required',
  2429. 'name' => 'required',
  2430. 'surname' => 'required',
  2431. 'email' => 'required',
  2432. 'phone' => 'required',
  2433. 'mobile' => 'required',
  2434. 'username' => 'required'
  2435. ]);
  2436. if($validator->fails())
  2437. {
  2438. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2439. }
  2440. if((Input::get('password'))!=(Input::get('password1')))
  2441. {
  2442. return Redirect::back()->with('view-error', ' Passwords do not match')->withInput()->withErrors($validator);
  2443. }
  2444. $user = new User;
  2445. $user->name = Input::get('name');
  2446. $user->email = Input::get('email');
  2447. $user->phone = Input::get('phone');
  2448. $user->mobile = Input::get('mobile');
  2449. $user->surname = Input::get('surname');
  2450. $user->username = Input::get('username');
  2451. $user->password = Hash::make(Input::get('password'));
  2452. $user->agencyAdmin = 'YES';
  2453. $user->agency = Input::get('agency');
  2454. $user->role = 'user';
  2455. $user->save();
  2456. $agency = new Agency;
  2457. $agency->EAAB_FFC_Number = Input::get('EAAB-FFC-Number');
  2458. $agency->agency = Input::get('agency');
  2459. $agency->registrationNum = Input::get('registrationNum');
  2460. $agency->save();
  2461. $data = ['agency' => $agency, 'user' => $user];
  2462. Mail::send('emails.register-agency', $data, function($message) use ($user)
  2463. {
  2464. $message->to($user->email,$user->name)->bcc('koketso.maphopha@gmail.com','Koketso Maphopha')->subject('New agency registration');
  2465. $message->from('info@univateproperties.co.za');
  2466. });
  2467. return Redirect::back()->with('view-success','You have successfully registered your agency.');
  2468. }
  2469. public function serveAllAgents()
  2470. {
  2471. $agents = DB::table('users')
  2472. ->where('agency','!=',NULL)
  2473. ->paginate(10);
  2474. if (Auth::check() && Auth::user()->role == "admin") {
  2475. return View::make('admin.all-agents')
  2476. ->with('agents',$agents);
  2477. }else{
  2478. return Redirect::to('/');
  2479. }
  2480. }
  2481. public function serveAllAgencies()
  2482. {
  2483. $agencies = DB::table('agencies')
  2484. ->paginate(10);
  2485. if (Auth::check() && Auth::user()->role == "admin") {
  2486. return View::make('admin.all-agencies')
  2487. ->with('agencies',$agencies);
  2488. }else{
  2489. return Redirect::to('/');
  2490. }
  2491. }
  2492. public function serveAllCommercialProperties()
  2493. {
  2494. $commercials = DB::table('commercials')
  2495. ->get();
  2496. if (Auth::check() && Auth::user()->role == "admin") {
  2497. return View::make('admin.all-commercial-properties')
  2498. ->with('commercials',$commercials);
  2499. }else{
  2500. return Redirect::to('/');
  2501. }
  2502. }
  2503. public function serveAllResidentialProperties()
  2504. {
  2505. $residentials = DB::table('residentials')
  2506. ->paginate(10);
  2507. if (Auth::check() && Auth::user()->role == "admin") {
  2508. return View::make('admin.all-residential-properties')
  2509. ->with('residentials',$residentials);
  2510. }else{
  2511. return Redirect::to('/');
  2512. }
  2513. }
  2514. public function editAgent($id)
  2515. {
  2516. $user = DB::table('users')
  2517. ->where('id','=',$id)
  2518. ->first();
  2519. return View::make('admin.edit-agent')
  2520. ->with('user',$user);
  2521. }
  2522. public function publishAgent($id)
  2523. {
  2524. DB::table('users')
  2525. ->where('id','=', $id)
  2526. ->update(array(
  2527. 'agent_publish' => 1
  2528. )
  2529. );
  2530. return Redirect::back()->withInput()->with('view-success', 'Agent is successfully verified.');
  2531. }
  2532. public function deleteAgent($id)
  2533. {
  2534. DB::table('users')
  2535. ->where('id','=',$id)
  2536. ->delete();
  2537. return Redirect::back()->with('view-success', ' SUCCESS: Agent Deleted');
  2538. }
  2539. public function handleEditAgent($id)
  2540. {
  2541. $validator = Validator::make(Input::all(),
  2542. [
  2543. 'name' => 'required',
  2544. 'email' => 'required'
  2545. ]);
  2546. if($validator->fails())
  2547. {
  2548. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2549. }
  2550. DB::table('users')
  2551. ->where('id','=', $id)
  2552. ->update(array(
  2553. 'name' => Input::get('name')
  2554. )
  2555. );
  2556. DB::table('users')
  2557. ->where('id','=', $id)
  2558. ->update(array(
  2559. 'surname' => Input::get('surname')
  2560. )
  2561. );
  2562. DB::table('users')
  2563. ->where('id','=', $id)
  2564. ->update(array(
  2565. 'email' => Input::get('email')
  2566. )
  2567. );
  2568. DB::table('users')
  2569. ->where('id','=', $id)
  2570. ->update(array(
  2571. 'phone' => Input::get('tel')
  2572. )
  2573. );
  2574. DB::table('users')
  2575. ->where('id','=', $id)
  2576. ->update(array(
  2577. 'mobile' => Input::get('cell')
  2578. )
  2579. );
  2580. return Redirect::to('all-agents')->with('view-success',"You have successfully updated agent's details");
  2581. }
  2582. public function serveEditAgency($id)
  2583. {
  2584. $agency = DB::table('agencies')
  2585. ->where('id','=',$id)
  2586. ->first();
  2587. $user = DB::table('users')
  2588. ->where('agency','=',$agency->agency)
  2589. ->first();
  2590. return View::make('admin.edit-agency')
  2591. ->with('user',$user)
  2592. ->with('agency',$agency);
  2593. }
  2594. public function handleEditAgency($id)
  2595. {
  2596. $agency = DB::table('agencies')
  2597. ->where('id','=',$id)
  2598. ->first();
  2599. $user = DB::table('users')
  2600. ->where('agency','=',$agency->agency)
  2601. ->first();
  2602. $validator = Validator::make(Input::all(),
  2603. [
  2604. 'name' => 'required',
  2605. 'agency' => 'required'
  2606. ]);
  2607. if($validator->fails())
  2608. {
  2609. return Redirect::back()->with('view-error', ' There were errors in your submission please review below')->withInput()->withErrors($validator);
  2610. }
  2611. DB::table('users')
  2612. ->where('id','=', $id)
  2613. ->update(array(
  2614. 'name' => Input::get('name')
  2615. )
  2616. );
  2617. DB::table('users')
  2618. ->where('id','=', $id)
  2619. ->update(array(
  2620. 'surname' => Input::get('surname')
  2621. )
  2622. );
  2623. DB::table('users')
  2624. ->where('id','=', $id)
  2625. ->update(array(
  2626. 'email' => Input::get('email')
  2627. )
  2628. );
  2629. DB::table('users')
  2630. ->where('id','=', $id)
  2631. ->update(array(
  2632. 'phone' => Input::get('phone')
  2633. )
  2634. );
  2635. DB::table('users')
  2636. ->where('id','=', $id)
  2637. ->update(array(
  2638. 'mobile' => Input::get('mobile')
  2639. )
  2640. );
  2641. DB::table('agencies')
  2642. ->where('id','=', $agency->id)
  2643. ->update(array(
  2644. 'EAAB_FFC_Number' => Input::get('EAAB-FFC-Number')
  2645. )
  2646. );
  2647. DB::table('agencies')
  2648. ->where('id','=', $agency->id)
  2649. ->update(array(
  2650. 'registrationNum' => Input::get('registrationNum')
  2651. )
  2652. );
  2653. DB::table('agencies')
  2654. ->where('id','=', $agency->id)
  2655. ->update(array(
  2656. 'agency' => Input::get('agency')
  2657. )
  2658. );
  2659. return Redirect::to('all-agencies')->with('view-success',"You have successfully updated your agency details");
  2660. }
  2661. }