/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(UserRegistrationRequest $request) { $input = $request->all(); Record::create($input); session()->flash('flash_message', 'Record stored successfully.'); return redirect('records'); }
/** * Execute the console command. * * @return mixed */ public function handle() { $count = 0; $rawdata = OldData::where('Transfered', '0'); $data = $rawdata->get(); $rawdata->update(['Transfered' => 1]); foreach ($data as $check) { $count++; Record::create(['nid' => $check->USERID, 'datetime' => strftime('%Y-%m-%d %X', strtotime($check->CHECKTIME))]); } //DB::connection('sqlsrv')->update('update CHECKINOUT set Transfered = 0'); }
/** * Execute the console command. * * @param Schedule $schedule * @param Event $event * @param Record $record */ public function handle(Schedule $schedule, Event $event, Record $record) { $uptimeRobot = new UptimeRobot(env('UPTIMEROBOT_API')); $getMonitors = simplexml_load_string($uptimeRobot->getMonitors()); foreach ($getMonitors->monitor as $monitor) { // Check for the restart signal. $check = $event->where('event', 'restart'); if ($monitor['status'] == 9) { // Record the restart $event->create(['machine_name' => 'ubuntu-512mb-sgp1-01', 'event' => 'restart']); // Check for the record of recent restart $recentRestart = $record->where('event', 'restart'); // If there is a recent record but no signal found if ($recentRestart->count() > 0 && $check->count() < 6) { \Mail::send('Email.Down', [], function ($message) { $message->to('*****@*****.**', 'Hashim Ibrahim')->subject('About your server'); }); } else { // 4 hours have been passed. $hoursPassed = $check->where('created_at', '<', 'DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 4 HOUR)'); if ($hoursPassed->count() > 0) { if ($schedule->exec('envoy run monitorStatus')) { \Log::info('Envoy ran @ ' . \Carbon\Carbon::now()); \Mail::send('Email.Server', ['time' => \Carbon\Carbon::now()], function ($message) { $message->to('*****@*****.**', 'Hashim Ibrahim')->subject('About your server'); }); // Save this restart to db $record->create(['event' => 'restart']); } else { \Log::info('Envoy is not working @ ' . \Carbon\Carbon::now()); } } $check->delete(); } } else { $check->delete(); \Log::info('Monitor status is good @ ' . \Carbon\Carbon::now()); } } }