/** * Flash a general message to the session data. * * This method allows you to conveniently pass messages to views. * * <code> * // Redirect and flash messages to the session * return Redirect::to('item_list')->with_message('Your item was added.'); * * // Flash a message with a type * return Redirect::to('item_list')->with_message('Your item was added.', 'success'); * </code> * * @param string $text * @param string $type * @return Redirect */ public function with_message($text, $type = '') { $messages = Session::get('messages', new TypedMessages()); $messages->add_typed($text, $type); Session::flash('messages', $messages); return $this; }
/** * Add an item to the session flash data. * * This is useful for "passing" status messages or other data to the next request. * * <code> * // Create a redirect response and flash to the session * return Redirect::to('profile')->with('message', 'Welcome Back!'); * </code> * * @param string $key * @param mixed $value * @return Redirect */ public function with($key, $value) { if (Config::get('session.driver') == '') { throw new \Exception('A session driver must be set before setting flash data.'); } Session::flash($key, $value); return $this; }
/** * Add a notification of any sort * * @param string $type * @param string $message * @param int $time * @param boolean $close * @return void */ protected static function add($type, $message, $time, $close) { static::$notifications[] = array('type' => $type, 'message' => $message, 'time' => $time, 'close' => $close); Session::flash('notifications', static::$notifications); }
public static function flush() { Session::flash(Input::old_input, array()); }