private function getLastReplicate() { $master = \Hosxp\Master\ReplicateLock::all(); foreach ($master as $key => $value) { $lrl = LocalReplicateLock::firstOrNew(array('computer_name' => $value->computer_name)); $lrl->last_active = $value->last_active; $lrl->save(); } $result = LocalReplicateLock::select('computer_name', 'last_active', DB::raw('NOW() as currenttime'))->get(); return $result; }
private function CheckReplicate() { if (Cache::has('notify_replication_active') == false) { $master = \Hosxp\Master\ReplicateLock::all(); foreach ($master as $key => $value) { $lrl = LocalReplicateLock::firstOrNew(array('computer_name' => $value->computer_name)); $lrl->last_active = $value->last_active; $lrl->save(); } $result = LocalReplicateLock::select('computer_name', 'last_active', DB::raw('NOW() as currenttime'))->get(); foreach ($result as $value) { $diff = Carbon::parse($value->last_active)->diffInSeconds(Carbon::now()); if ($diff > 120 && Cache::has('notify_replication_active') == false) { $user = User::all(); foreach ($user as $u) { $u->newNotification()->withType('Replicate')->withSubject('แจ้งรายการ Replicate')->withBody("กรุณาตรวจสอบการ replication ข้อมูลของ computer name " . $value->computer_name)->deliver(); } Cache::put('notify_replication_active', Carbon::now(), 60); } } } }