本文整理汇总了PHP中Illuminate\Support\Facades\Session::push方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::push方法的具体用法?PHP Session::push怎么用?PHP Session::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Session
的用法示例。
在下文中一共展示了Session::push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check() && $this->auth->user()['status'] === 'teacher') {
return $next($request);
}
Session::push('messages', 'danger|Vous devez être professeur pour accéder à cette page');
return redirect('/');
}
示例2: bagAddBySession
/**
* @return \Illuminate\Http\RedirectResponse
*/
public function bagAddBySession()
{
$product_id = Input::get('product_id');
// id du produit récupéré au click au moment d'ajouter un produit
$quantity = Input::get('quantity');
$product = Product::where('id', $product_id)->firstOrFail();
Session::push('panier', ["quantity" => $quantity, "product_id" => $product_id, "title" => $product->title, "image" => isset($product->image->uri_mini) ? $product->image->uri_mini : '', "price" => $product->price, "priceTotalByProduct" => $quantity * $product->price]);
return redirect()->back()->with('message', 'Produit ajouté au panier');
}
示例3: setToHaystack
/**
* Build the not in id array to be evaluated in suggestions.
*
* @param [array] $products, which is the real time query result
* @param [string] $field, which is the validation reference point
*
* @return [array] $needle, that is the array to be evaluated in the where not in
*/
public function setToHaystack($products, $field = 'id')
{
if (empty(Session::get('suggest-listed'))) {
Session::put('suggest-listed', []);
}
if (count($products) > 0) {
foreach ($products as $value) {
if (!in_array($value[$field], Session::get('suggest-listed'))) {
Session::push('suggest-listed', $value[$field]);
}
}
}
Session::save();
}
示例4: retrieve
/**
* Get value of a RagnarokParameter attribute
* @param $name: the name of parameter in the database
* @param $force: force to get the parameter value of the database
* @return mixed
*/
public function retrieve($name, $force = false)
{
$RagnarokParameters = new self($this->SecParameter);
if (self::check()) {
$RagnarokParameters = Session::get($this->getName());
if (property_exists($RagnarokParameters, $name)) {
if ($force) {
$value = $this->SecParameter->wherename($name)->first()->value;
Session::push($this->getName() . $name, $value);
}
$value = $RagnarokParameters->{$name};
return $value;
}
}
$RagnarokParameters->{$name} = $this->SecParameter->wherename($name)->first()->value;
Session::put($this->getName(), $RagnarokParameters);
return $RagnarokParameters->{$name};
}
示例5: initRules
/**
* init Rules
*
* @return \Gsdw\Permission\Helpers\Auth
*/
public function initRules()
{
if (!Session::has('permission.rules')) {
$role = self::$user->getRole();
if (!$role) {
$rules = [];
} else {
$rules = $role->getRules();
}
Session::push('permission.rules', $rules);
}
self::$rules = Session::get('permission.rules');
self::$rules = self::$rules[0];
return $this;
// $role = self::$user->getRole();
// if (!$role) {
// self::$rules = [];
// } else {
// self::$rules = $role->getRules();
// }
// return $this;
}
示例6: setCounters
/**
* Increase the product counters.
*
* @param [object] $product is the object which contain the product evaluated
* @param [array] $data is the method config that has all the info requeried (table field, amount to be added)
* @param [string] $wrapper is the products session array position key.
*/
public static function setCounters($product = null, $data = [], $wrapper = '')
{
if (\Auth::user() && $product != '' && count($data) > 0) {
$_array = Session::get('products.' . $wrapper);
//products already evaluated
if (count($_array) == 0 || !in_array($product->id, $_array)) {
//looked up to make sure the product is not in $wrapper array already
foreach ($data as $key => $value) {
if ($key != '' && $data[$key] != '') {
$product->{$key} = $product->{$key} + intval($data[$key]);
$product->save();
}
}
Session::push('products.' . $wrapper, $product->id);
//build product list to not increase a product more than one time per day
Session::save();
}
}
}
示例7: createRandomNumber
/**
* create new random number to save the grid info on it
*
* @return string
*/
private function createRandomNumber()
{
$str_random = str_random(16);
while (Session::has("tables." . $str_random)) {
$str_random = str_random(16);
}
Session::push("tables." . $str_random, $this->table_name);
Session::push("tables." . $str_random, json_encode($this->columns_name));
Session::push("tables." . $str_random, json_encode($this->columns));
return $str_random;
}
示例8: doCreateField
protected function doCreateField($table_name, $field_name)
{
$field_bd = $this->getAttribute('field');
$data = Session::all();
if (!Session::has($table_name . '.' . $field_name)) {
if ($field_bd && !Schema::hasColumn($table_name, $field_name)) {
Session::push($table_name . '.' . $field_name, 'created');
@(list($field, $param) = explode("|", $field_bd));
Schema::table($table_name, function ($table) use($field_name, $field, $param) {
$field_add = $table->{$field}($field_name);
if ($param) {
$field_add->length($param);
}
});
} else {
Session::push($table_name . '.' . $field_name, 'created');
}
}
}
示例9: appendErrors
public static function appendErrors(\Illuminate\Validation\Validator $validator)
{
foreach ($validator->errors()->all() as $message) {
Session::push('field_validation_errors', $message);
}
}
示例10: addToComparison
public function addToComparison($property)
{
if (!in_array($property->id, Session::get('properties_in_comparison', []))) {
Session::push('properties_in_comparison', $property->id);
}
}
示例11: addWarningMessage
protected function addWarningMessage($message)
{
if (!Session::has('errors') || Session::get('errors')->isEmpty()) {
Session::put('warning', $message);
Session::push('flash.old', 'warning');
}
}
示例12: updateCart
public function updateCart(Request $request)
{
$item = $request->id;
Session::forget('product');
foreach ($item as $index => $key) {
$result = Product::find($key);
$image = $result->image;
$name = $result->name;
$price = $result->price;
$total = $request->number[$index] * $price;
$data = array('token' => $request->_token, 'id' => $key, 'image' => $image, 'name' => $name, 'number' => $request->number[$index], 'price' => $price, 'total' => $total);
Session::push('product', $data);
}
return redirect("cart/view")->withSuccess("Shopping cart update");
}
示例13: getLogout
/**
* Déconnecte l'utilisateur
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function getLogout(Request $request)
{
Session::push('messages', 'success|Vous avez bien été déconnecté');
Auth::logout();
return redirect('/');
}
示例14: getTableAllowedIds
public function getTableAllowedIds()
{
if (!Session::has($this->getOptionDB('table') . "_exist")) {
if (!Schema::hasTable($this->getOptionDB('table'))) {
Schema::create($this->getOptionDB('table'), function ($table) {
$table->increments('id');
});
}
}
$this->db = DB::table($this->getOptionDB('table'));
$this->prepareFilterValues();
$ids = $this->db->lists('id');
Session::push($this->getOptionDB('table') . "_exist", 'created');
return $ids;
}
示例15: storeComment
/**
* function to action to deliver virtual products
* @param $order_id int
* @return json message error or message success
*/
public function storeComment(Request $request)
{
$order_id = $request->get('order_id');
$text = $request->get('comment_text');
$user = \Auth::user();
if ($user) {
$order = Order::find($order_id);
//Checks if the order belongs to the current user, or if the user is the seller of the order
if ($order->user_id == $user->id || $order->seller_id == $user->id) {
$data = array('user_id' => $user->id, 'action_type_id' => 3, 'source_id' => $order_id, 'comment' => $text);
$new_comment = Comment::create($data);
if ($order->user_id == $user->id) {
$mail_subject = trans('email.order_commented.comment_from_user');
$seller_user = User::find($order->seller_id);
$email = $seller_user->email;
}
if ($order->seller_id == $user->id) {
$mail_subject = trans('email.order_commented.comment_from_seller');
$buyer_user = User::find($order->user_id);
$email = $buyer_user->email;
}
$data = ['order_id' => $order_id, 'subject' => $mail_subject, 'email_message' => $mail_subject, 'email' => $email, 'comment' => $text, 'title' => $mail_subject];
Mail::queue('emails.order_comment', $data, function ($message) use($user, $data) {
$message->to($data['email'])->subject($data['subject']);
});
} else {
return \Response::json(array('success' => false, 'order_id' => $order_id), 200);
}
} else {
return \Response::json(array('success' => false, 'order_id' => $order_id), 200);
}
Session::push('message', trans('store.create_comment_modal.added_order_comment'));
return \Response::json(array('success' => true, 'order_id' => $order_id), 200);
}