Esempio n. 1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function checkErf($street)
 {
     // dynamically change database
     $userDB = Auth::user()->suburb;
     $otf = new \App\Database\OTF(['database' => $userDB]);
     $db = DB::connection($userDB);
     // check database type
     $databaseType = Auth::user()->suburb_type;
     if ($databaseType == 1) {
         $freeholds_table = "tblSuburbOwners";
         $freeholds_table_key = $freeholds_table . ".numErf";
         $freeholds_identity = $freeholds_table . ".strIdentity";
         $mem_Table = "tblErfNumbers";
         $mem_key = "tblErfNumbers.numErf";
     }
     if ($databaseType == 2) {
         $freeholds_table = "tblSuburbOwners";
         $freeholds_table_key = $freeholds_table . ".strKey";
         $freeholds_identity = $freeholds_table . ".strIdentity";
         $mem_Table = "tblFHPropertyID";
         $mem_key = $mem_Table . ".strKey";
     }
     if ($databaseType == 3) {
         $freeholds_table = "tblSuburbOwners";
         $freeholds_table_key = $freeholds_table . ".strKey";
         $freeholds_identity = $freeholds_table . ".strIdentity";
         $mem_Table = "tblFHPropertyID";
         $mem_key = $mem_Table . ".strKey";
     }
     $streets = $db->table($freeholds_table)->Join($mem_Table, $freeholds_table_key, '=', $mem_key)->Join('tblSuburbContactNumbers', $freeholds_identity, '=', 'tblSuburbContactNumbers.strIDNumber')->orderBy('strStreetName', 'asc')->orderBy('strStreetNo', 'asc')->orderBy($freeholds_table . '.strComplexName', 'asc')->orderBy($freeholds_table . '.strComplexNo', 'asc')->orderBy($freeholds_table . '.strKey', 'asc')->select('*')->groupby($freeholds_table . '.ID')->where($freeholds_table . '.numErf', $street)->paginate(1);
     // format phone and currency
     foreach ($streets as $value) {
         $value->strHomePhoneNo = helpers::phoneFormat($value->strHomePhoneNo);
         $value->strWorkPhoneNo = helpers::phoneFormat($value->strWorkPhoneNo);
         $value->strCellPhoneNo = helpers::phoneFormat($value->strCellPhoneNo);
         $value->strAmount = helpers::currencyFormat($value->strAmount);
         $value->strBondAmount = helpers::currencyFormat($value->strBondAmount);
         $value->strSurname = str::title($value->strSurname);
         $value->strFirstName = str::title($value->strFirstName);
     }
     // log
     $radio = 'checkErf';
     $append = Auth::user()->name . "    " . \Carbon\Carbon::now()->toDateTimeString() . "    " . 'streetscontroller ' . $radio . "    " . $street . "    " . $userDB;
     Storage::append('logfile.txt', $append);
     return view('pages.streets1', compact('streets', 'street'));
     dd('checkgrid streetcontroller', $street);
 }