本文整理汇总了PHP中Session::push方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::push方法的具体用法?PHP Session::push怎么用?PHP Session::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addCart
public function addCart($id)
{
$product = Product::find($id);
$quantity = Input::get('qt');
$name = $product->name;
if (intval($quantity) > $product->stock) {
return Redirect::to('product/' . $id)->with('message', 'La quantité du stock est insufisante pour votre commande');
}
if (Session::has('cart')) {
$carts = Session::get('cart', []);
foreach ($carts as &$item) {
if ($item['name'] == $name) {
$item["quantity"] += intval($quantity);
Session::set('cart', $carts);
return Redirect::to('product/' . $id)->with('message', 'Votre panier a été mis à jour');
}
}
}
$new_item = array();
$new_item['name'] = $name;
$new_item['price'] = $product->price;
$new_item['quantity'] = intval($quantity);
$new_item['description'] = $product->description;
$new_item['picture'] = $product->picture;
Session::push('cart', $new_item);
return Redirect::to('product/' . $id)->with('message', 'Le produit a été ajouté à votre panier');
}
示例2: getAddToCart
public function getAddToCart($product_id)
{
$cart = !empty(Session::get('cart.items')) ? Session::get('cart.items') : array();
if (!in_array($product_id, $cart)) {
Session::push('cart.items', intval($product_id));
Session::put("cart.amounts.{$product_id}", intval(1));
}
return Redirect::to('cart/my-cart');
}
示例3: viewReset
public function viewReset($token)
{
Session::forget('email');
//This causes an offset exception if the token doesn't exist.
$email = DB::table('password_reminders')->where('token', $token)->first();
$email = $email->email;
Session::push('email', '$email');
return View::make('password.viewReset')->with('token', $token)->with('email', $email);
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$cuisines = [];
if (Input::get('french') == 'french') {
Session::push('cuisines', 'french');
$cuisines[] = Input::get('french');
}
if (Input::get('italian') == 'italian') {
Session::push('cuisines', 'italian');
$cuisines[] = Input::get('italian');
}
if (Input::get('chinese') == 'chinese') {
Session::push('cuisines', 'chinese');
$cuisines[] = Input::get('chinese');
}
if (Input::get('indian') == 'indian') {
Session::push('cuisines', 'indian');
$cuisines[] = Input::get('indian');
}
if (Input::get('mexican') == 'mexican') {
Session::push('cuisines', 'mexican');
$cuisines[] = Input::get('mexican');
}
if (Input::get('lebanese') == 'lebanese') {
Session::push('cuisines', 'lebanese');
$cuisines[] = Input::get('lebanese');
}
if (Input::get('japanese') == 'japanese') {
Session::push('cuisines', 'japanese');
$cuisines[] = Input::get('japanese');
}
if (Input::get('spanish') == 'spanish') {
Session::push('cuisines', 'spanish');
$cuisines[] = Input::get('spanish');
}
if (Input::get('greek') == 'greek') {
Session::push('cuisines', 'greek');
$cuisines[] = Input::get('greek');
}
if (Input::get('american') == 'american') {
Session::push('cuisines', 'american');
$cuisines[] = Input::get('american');
}
$validation = Validator::make(Input::all(), ['zipcode' => 'max:5']);
if ($validation->fails()) {
return Redirect::back()->withInput()->withErrors($validation->messages());
}
if (count($cuisines) < 1) {
return Redirect::back()->withInput();
}
Session::push('zipcode', Input::get('zipcode'));
Session::push('gender', Input::get('gender'));
return Redirect::route('results.index');
#Session::get('zipcode');#
}
示例5: addToCart
public function addToCart($event_id)
{
if (Request::ajax()) {
//on récupère les informations envoyer avec ajax
$data = Input::all();
// on récupère les informations du produit
$product = Produit::find($data['product_id']);
//on prépare les donnée à insérer dans la session cart
$parsedata = ['id' => $data['product_id'], 'price' => $data['price'], 'nom' => $product->description, 'evenement_id' => $data['evenement_id']];
// on charge la session cart avec les nouvelles données.
Session::push('cart.items', $parsedata);
}
}
示例6: isValid
public function isValid()
{
$validator = Validator::make($this->attributesToArray(), $this->rules);
if ($validator->fails()) {
Session::remove('messages');
foreach ($validator->getMessageBag()->getMessages() as $message) {
Session::push('messages', $message[0]);
}
// debug(Session::get('messages')); exit;
return false;
}
return true;
}
示例7: register
public function register()
{
Session::clear();
$data = Input::all();
$rules = ['username' => 'required|unique:users,username|min:3', 'email' => 'required|email|unique:users,email', 'password' => 'required|confirmed|min:6', 'password_confirmation' => 'required'];
$validation = Validator::make($data, $rules);
if ($validation->passes()) {
$user = $this->userRepo->nuevoUser($data);
Session::push('iduser', $user->id);
return \Redirect::route('paso2');
} else {
return \Redirect::back()->withInput()->withErrors($validation->messages());
}
}
示例8: setUser
public function setUser($user)
{
// Userのセッションを削除
\Session::forget("User");
// ログインに成功したのでセッションIDを再生成
\Session::regenerate();
$object = app('stdClass');
$object->id = $user->id;
$object->username = $user->username;
$object->email = $user->email;
// ログインユーザーの情報を保存
\Session::push('User', $object);
\Session::save();
}
示例9: prv_add
/**
* Add a notification
*/
private static function prv_add($_type, $_messages)
{
if ($_messages instanceof \Illuminate\Support\MessageBag) {
$_messages = $_messages->all();
} elseif ($_messages instanceof \Illuminate\Validation\Validator) {
$_messages = $_messages->getMessageBag()->all();
}
if (is_array($_messages)) {
foreach ($_messages as $k => $m) {
\Session::push(self::$mSessionPrefix . '.' . $_type, $m);
}
} else {
\Session::push(self::$mSessionPrefix . '.' . $_type, $_messages);
}
}
示例10: store
public function store()
{
$user = User::where('email', '=', Input::get('email'))->first();
$count = User::where('email', '=', Input::get('email'))->count();
if ($count == 0) {
return Redirect::to('/register');
}
if ($count > 0 && $user->verified == '0') {
Session::push('email', Input::get('email'));
return Redirect::to('/verify');
}
if (Auth::attempt(Input::only('email', 'password'))) {
return Redirect::to('/sessions');
}
return Redirect::back()->withInput();
}
示例11: process_form
public function process_form()
{
if (!count($_POST)) {
return View::make('includes/template')->with('template', 'form');
} else {
Validator::extend('day_of_month', function ($attribute, $value, $parameters) {
$month = intval($_POST['dob_month']);
$year = intval($_POST['dob_year']) ? intval($_POST['dob_year']) : 2013;
if (!$month) {
return false;
}
$total_days = date("t", mktime(1, 1, 1, $month, 1, $year));
return intval($value) <= $total_days;
});
$rules = array('picture' => 'Required|Mimes:jpeg|Max:2048', 'image_title' => array('Required', 'Regex:/[\\p{L}\\-_ 0-9]+/u', 'Max:150'), 'drawn_by' => array('Required', 'Regex:/[\\p{L}][\\p{L}\\- ]+/u', 'Max:150'), 'dob_year' => 'Required|Integer|Between:1999,2013', 'dob_month' => 'Required|Integer|Between:1,12', 'dob_day' => 'Required|Integer|Between:1,31|day_of_month', 'title' => array('Required', 'Regex:/^(Mr|Mrs|Ms|Miss|Other)$/'), 'forename' => array('Required', 'Regex:/[\\p{L}][\\p{L}\\- ]+/u', 'Max:150'), 'surname' => array('Required', 'Regex:/[\\p{L}][\\p{L}\\- ]+/u', 'Max:150'), 'address' => array('Required', 'Regex:/[\\p{L}\\-_ 0-9]+/u', 'Max:150'), 'town' => array('Required', 'Max:50', 'Regex:/[\\p{L}\\- ]+/u'), 'country' => 'In:England,Scotland,Wales,Northern Ireland,Republic of Ireland', 'postcode' => array('Regex:/^([a-pr-uwyz]((\\d{1,2})|([a-hk-y]\\d{1,2})|(\\d[a-hjkstuw])|([a-hk-y]\\d[a-z])) *\\d[abd-hjlnp-uw-z]{2})?$/i', 'Max:10'), 'email' => 'Required|Email|Confirmed', 'email_confirmation' => 'Required|Email', 'terms' => 'Required');
$messages = array('picture.mimes' => "Sorry - our systems don't recognise the type of file you've uploaded. Please have another go with a jpg file", 'picture.max' => "Sorry - the file you've tried to upload is too big for our systems! Please have another go with a smaller jpg", 'image_title.required' => "Oops, your drawing doesn't have a title", 'drawn_by.required' => "Sorry, our systems don't recognise the drawer’s name you've entered. We just want a first name with no numbers or symbols and it must start with a letter. Please try again!", 'drawn_by.regex' => 'Sorry, the name can only contain letters, spaces, and hyphens and it must start with a letter', 'dob_year:required' => 'Sorry, you must enter a year of birth', 'dob_year.integer' => 'Sorry, your year of birth must be between 1999 and the present', 'dob_year.between' => 'Sorry, your year of birth must be between 1999 and the present', 'dob_month:required' => 'Sorry, you must enter the month the drawer was born', 'dob_month.integer' => 'Sorry, the month the drawer was born must be a number from 1 to 12', 'dob_month.between' => 'Sorry, the month the drawer was born must be a number from 1 to 12', 'dob_day.required' => 'Sorry, you need to enter the day of the month the drawer was born', 'dob_day.integer' => 'Sorry, the day of the month the drawer was born should be between 1 and 31', 'dob_day.between' => 'Sorry, the day of the month the drawer was born should be between 1 and 31', 'dob_day.day_of_month' => 'Sorry, that month doesn\'t have that many days!', 'forename.required' => "Hello stranger. We're missing your first name.", 'forename.regex' => 'Sorry, the name can only contain letters, spaces, and hyphens', 'surname.required' => "We're missing your surname.", 'surname.regex' => 'Sorry, the name can only contain letters, spaces, and hyphens', 'address.required' => "We need your address so, if you win, the postman knows where to deliver your petrifying prize.", 'town.required' => "Where do you live?", 'postcode.required' => "Don't forget to pop in your post code.", 'postcode.regex' => "Sorry, our systems don’t recognise what you've entered as a post code. Please use a regular UK format, like KT22 7GR.", 'email.required' => "What's your email?", 'email.email' => "Sorry, our systems don't recognise what you've entered as an email. Please use a regular email format, like info@Persil.com", 'email.confirmed' => "Sorry, the emails you’ve entered don’t match up. Please check them and have another go.", 'terms.required' => "See that tiny box? You need to tick it if you agree to the terms and conditions.");
$input = Input::all();
// note to self - all() is required instead of get() if processing uploads - just wasted a good hour hunting down this little bug
$input['dob_day'] = trim($input['dob_day'], '0');
$input['dob_month'] = trim($input['dob_month'], '0');
$validator = Validator::make($input, $rules, $messages);
if ($validator->fails()) {
// spit out the form again with the errors shown
return View::make('includes/template')->with('template', 'form')->with('errors', $validator->messages())->with('input', $input);
} else {
// first - process the image
$image = Persil::save_uploaded_image($input);
$added = Persil::insert_user_data($input);
$traction_added = Persil::post_traction_data($input, $this->url, $this->password);
if ($image && $added) {
// push the validated data into the session so that it can be shown in the form again if they go to make another submission
Session::put('submitted_data', array());
foreach ($input as $key => $value) {
if ($key != 'picture') {
Session::push("submitted_data.{$key}", $value);
}
}
//Session::put('submitted_data', $input);
return View::make('includes/template')->with('template', 'confirmation')->with('input', $input);
} else {
echo 'error page';
}
// this will probably be the form again with some generic error message or something
}
}
}
示例12: saveProductImage
public function saveProductImage()
{
if (!Auth::guest()) {
$file = Input::file('file');
$directory = public_path() . '/product_images/';
$file_name = $file->getClientOriginalName();
if (!File::exists($directory . $file_name)) {
$file->move($directory, $file_name);
}
if (!Session::has('files')) {
Session::put('files', []);
}
Session::push('files', $file_name);
return Response::json(array('success' => true));
}
return Response::json(array('success' => false));
}
示例13: store
public function store()
{
/*$user = new User;
$user->email = Input::get('email');
$user->*/
if (!User::isValid(Input::all())) {
return Redirect::to('/failed');
}
$accesscode = Str::random(60);
User::create(['email' => Input::get('email'), 'password' => Hash::make(Input::get('password')), 'gender' => Input::get('gender'), 'accesscode' => $accesscode, 'verified' => '0']);
$email_data = array('recipient' => Input::get('email'), 'subject' => 'Share-A-Meal: Verification Code');
$view_data = ['accesscode' => $accesscode];
Mail::send('emails.verify', $view_data, function ($message) use($email_data) {
$message->to($email_data['recipient'])->subject($email_data['subject']);
});
Session::push('email', Input::get('email'));
return Redirect::to('/verify');
}
示例14: setSessionFeeds
public static function setSessionFeeds($user_id)
{
# Set Feeds for this user in the Session Variable
$feeds = \p4\UserFeed::where('user_id', '=', $user_id)->orderby('weight', 'DESC')->get();
$tags = \p4\Tag::where('user_id', '=', $user_id)->orderby('weight', 'DESC')->get();
$categories = \p4\Category::where('user_id', '=', $user_id)->orderby('weight', 'DESC')->get();
foreach ($feeds as $f) {
$f->stats = $f->get_stats();
}
foreach ($tags as $t) {
$t->stats = $t->get_stats();
}
\Session::forget('myfeeds');
\Session::forget('mytags');
\Session::forget('categories');
\Session::push('myfeeds', $feeds);
\Session::push('mytags', $tags);
\Session::push('categories', $categories);
}
示例15: menu
public static function menu()
{
$items = [];
$menu = __DIR__ . '/../Data/admin_menu.json';
$routes = array();
if (file_exists($menu)) {
$options = json_decode(file_get_contents($menu), true);
foreach ($options as $n => $o) {
$add = true;
if (array_key_exists('type', $o)) {
$add = \Auth::user()->type == $o['type'];
}
if ($add) {
$item = ['label' => $n, 'icon' => $o['icon'], 'route' => $o['route'], 'container' => isset($o['container']) ? $o['container'] : '', 'class' => isset($o['class']) ? $o['class'] : ''];
array_push($routes, $o['code']);
array_push($items, $item);
}
}
}
// Add routes to session
\Session::push('routes', $routes);
return $items;
}