本文整理汇总了PHP中app\Contact::on方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::on方法的具体用法?PHP Contact::on怎么用?PHP Contact::on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Contact
的用法示例。
在下文中一共展示了Contact::on方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newMultiUnit
public function newMultiUnit($updatesA, $unit, $database)
{
$echo = "Entering newMultiUnit ........................................ ";
File::append($this->logfilename, $echo . "\r\n");
//dd($updatesA, $unit);
// check if multiple units
// get sqM for specific unit
$a = explode(" & ", $updatesA['strComplexNo']);
$sqM = explode(" & ", $updatesA['strSqMeters']);
$found = in_array($unit, $a);
if ($found) {
$place = array_search($unit, $a);
$updatesA['strSqMeters'] = $sqM[$place];
}
$now = \Carbon\Carbon::now('Africa/Johannesburg')->toDateTimeString();
$updatesA['id'] = null;
$updatesA['strKey'] = $updatesA['strKey'];
$updatesA['numStreetNo'] = $updatesA['strStreetNo'];
$updatesA['numComplexNo'] = $updatesA['strComplexNo'];
$updatesA['created_at'] = $now;
// dd($updatesA, $a, $found, $place, $a[$place], $sqM[$place]);
// delete older ones
$delOld = Property::on($database)->where('strKey', $updatesA['strKey'])->where(DB::raw("STR_TO_DATE(dtmRegDate, '%Y-%m-%d')"), '<', Date($updatesA['dtmRegDate']))->delete();
$echo = "..DELETE OLD ............ " . $updatesA['strKey'] . " - " . $delOld;
File::append($this->logfilename, $echo . "\r\n");
// insert new property record
Property::on($database)->insert($updatesA);
// add owner record if not existing
//
$hascontact = Owner::on($database)->select('id')->where('strIDNumber', '=', $updatesA['strIdentity']);
if ($hascontact->count() == 0) {
// update details from admin contacts
$admin_contacts = "farmbook_admin";
$otf = new \App\Database\OTF(['database' => $admin_contacts]);
$db = DB::connection($admin_contacts);
$owner_details = Contact::on($admin_contacts)->select('*')->where('strIDNumber', $updatesA['strIdentity'])->first();
// contact details found in admin contacts
if (sizeof($owner_details) == 1) {
$uid = $owner_details->strIDNumber;
// set database back
$dbname = $database;
$otf = new \App\Database\OTF(['database' => $dbname]);
$db = DB::connection($dbname);
// update contact details
$owner = Owner::on($database)->insert(array('strIDNumber' => $owner_details->strIDNumber, 'NAME' => $owner_details->NAME, 'TITLE' => $owner_details->TITLE, 'INITIALS' => $owner_details->INITIALS, 'strSurname' => $owner_details->strSurname, 'strFirstName' => $owner_details->strFirstName, 'strHomePhoneNo' => $owner_details->strHomePhoneNo, 'strWorkPhoneNo' => $owner_details->strWorkPhoneNo, 'strCellPhoneNo' => $owner_details->strCellPhoneNo, 'EMAIL' => $owner_details->EMAIL, 'created_at' => $now, 'updated_at' => $now));
// update from prop rec
} else {
$dbname = $database;
$otf = new \App\Database\OTF(['database' => $dbname]);
$db = DB::connection($dbname);
$owner = Owner::on($database)->insert(array('strIDNumber' => $updatesA['strIdentity'], 'NAME' => $updatesA['strOwners'], 'created_at' => $now));
}
} else {
// dont wipe old details
}
// add note
//
$hasnote = Note::on($database)->select('id')->where('strKey', '=', $updatesA['strKey'])->get();
if ($hasnote->count() == 0) {
//$note = Note::on($database)->insert(array('strKey' => $updatesA[$x]['strKey'], 'numErf' => $updatesA[$x]['numErf'], 'memNotes' => "\n" . $now . ' ' . $updatesA[$x]['strOwners'] . ' - New Owner.', 'created_at' => $now));
$note = Note::on($database)->insert(array('strKey' => $updatesA['strKey'], 'numErf' => $updatesA['numErf'], 'created_at' => $now));
} else {
$note = Note::on($database)->where('strKey', '=', $updatesA['strKey'])->update(array('memNotes' => DB::raw('concat(memNotes, " \\n' . $now . ' ' . $updatesA['strOwners'] . ' - New Owner.")'), 'updated_at' => $now));
}
$echo = "Finishing newMultiUnit ........................................ ";
File::append($this->logfilename, $echo . "\r\n");
}