/** * Main paige of dashboard. */ public function index() { //get grace period form DB, if exists show it in view $gp = GracePeriod::first(); //add here data which we can render in view $dataToView = array('grace_settings' => $gp ? $gp->days . 'd ' . $gp->hours . 'h ' . $gp->minutes . 'm' : null); return View::make('dashboard.index', $dataToView); }
/** * Store a newly created graceperiod in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::only('days', 'minutes', 'hours'), GracePeriod::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } //Graceperiod::create($data); $gracePeriod = GracePeriod::first(); if ($gracePeriod) { //do update existing entry $gracePeriod->update($data); } else { //create new GracePeriod::create($data); } return Redirect::to('/'); }