php - Laravel- getting i think POST message after set_date submit -
hello have form sets date of voting start , stop, today started information on screen. tell me mean ? functionality uses 2 php files. makevotecontroller in take date form , carbon::create , put them database , there's function in votingstatus model. checking if current date in between begin , end date returns voting_status(started or stopped) votingmgmt controller
<?php namespace app\http\controllers; use illuminate\http\request; use db; use app\http\requests; use illuminate\support\facades\input; use carbon\carbon; class votingmgmtcontroller extends controller { public function start() { self::setstart(); return view('panel.startvoting'); } public function stop() { self::setstop(); return view('panel.stopvoting'); } // public function setdateview() { return view('panel.startvoting'); } public function setdate(request $request) { $rok_start = input::get('rok'); $miesiac_start = input::get('miesiac'); $dzien_start = input::get('dzien'); $godzina_start = input::get('godzina'); $minuta_start = input::get('minuta'); $rok_stop = input::get('rok_end'); $miesiac_stop = input::get('miesiac_end'); $dzien_stop = input::get('dzien_end'); $godzina_stop = input::get('godzina_end'); $minuta_stop = input::get('minuta_end'); $begin_date = carbon::create($rok_start,$miesiac_start,$dzien_start,$godzina_start,$minuta_start,59,'europe/warsaw'); $stop_date = carbon::create($rok_stop,$miesiac_stop,$dzien_stop,$godzina_stop,$minuta_stop,59,'europe/warsaw'); $now = carbon::now('europe/warsaw'); //set begin , end date in database db::table('voting_status') ->where('id',1) ->update(['voting_start_date' => $begin_date]); db::table('voting_status') ->where('id',1) ->update(['voting_end_date' => $stop_date]); return redirect()->route('set_date')->with('success','ustawiono datę rozpoczęcia zakończenia głosowania'); } public function setenddate() { } private function setstart() { try { db::table('voting_status') ->where('id',1) ->update(['status' => 'started']); } catch(\illuminate\database\queryexception $ex) { return view('info.dash_service_unavailable'); } } private function setstop() { try { db::table('voting_status') ->where('id',1) ->update(['status' => 'stopped']); } catch(\illuminate\database\queryexception $ex) { return view('info.dash_service_unavailable'); } return true; } private function checkdate() { } }
votingstatus model
<?php namespace app; use db; use pdo; use illuminate\database\eloquent\model; use carbon\carbon; class votingstatus extends model { protected $table = "voting_status"; //check table votingstatus whether started or not function checkstatus() { /*query database status of voting , print output */ db::setfetchmode(pdo::fetch_assoc); $begin_date = db::select('select voting_start_date voting_status id=1 '); $end_date = db::select('select voting_end_date voting_status id=1'); $now = carbon::now('europe/warsaw'); $begin_var; $end_var; foreach($begin_date $key => $value) { $begin_var= (string)$value['voting_start_date']; echo $begin_var; } foreach($end_date $key => $value) { $end_var= (string)$value['voting_end_date']; echo $end_var; } $carbon_start = carbon::parse($begin_var,'europe/warsaw'); $carbon_stop = carbon::parse($end_var,'europe/warsaw'); if(($now->gt($carbon_start)) && ($now->lt($carbon_stop))) { try { db::table('voting_status') ->where('id',1) ->update(['status' => 'started']); } catch(\illuminate\database\queryexception $ex) { dd("upss start"); } } else { try { db::table('voting_status') ->where('id',1) ->update(['status' => 'stopped']); } catch(\illuminate\database\queryexception $ex) { dd("upss stop"); } } db::setfetchmode(pdo::fetch_class); $db_stat = db::table('voting_status')->where('id',1)->first(); $status = $db_stat->status; return $status; } }
error has been fixed. after uploading newer version of application on server there still old version of web.php. in mentioned web.php form submit handled function
set_date(request $request) { return $request; }
now works
Comments
Post a Comment