本文整理汇总了PHP中Illuminate\Support\Facades\Session::pull方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::pull方法的具体用法?PHP Session::pull怎么用?PHP Session::pull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Session
的用法示例。
在下文中一共展示了Session::pull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addProduct
public function addProduct($id, $num)
{
if (Request::ajax()) {
if (Session::has("cart")) {
$cart = Session::get("cart");
$check = array_key_exists($id, $cart);
//kiem tra san pham da co trong gio chua
if ($check) {
//roi thi tra ve
$result = "Sản phẩm đã có trong giỏ hàng";
return json_encode(["result" => $result]);
} else {
//chua thi them san pham
$product = [$id => $num];
$cart = Session::pull("cart");
$cart += $product;
Session::put("cart", $cart);
$result = "Thêm giỏ hàng thành công";
$tsl = countProducts();
return json_encode(["result" => $result, "tsl" => $tsl]);
}
} else {
//chua ton tai session gio hang
$product = [$id => $num];
Session::put("cart", $product);
$tsl = $num;
$result = "Thêm giỏ hàng thành công";
return json_encode(["result" => $result, "tsl" => $tsl]);
}
} else {
return redirect("/");
}
}
示例2: handle
/**
* Handle the report append command.
*
* @param \Gitamin\Commands\Identity\AddIdentityCommand $command
*
* @return \Gitamin\Models\Identity
*/
public function handle(AddIdentityCommand $command)
{
$data = ['user_id' => $command->userId, 'extern_uid' => $command->data['extern_uid'], 'provider_id' => $command->data['provider_id'], 'nickname' => $command->data['nickname'], 'created_at' => Carbon::now()->toDateTimeString()];
// Create the identify
$identify = Identity::create($data);
Session::pull('connect_data');
return $identify;
}
示例3: postTwoFactor
/**
* Validates the Two Factor token.
*
* This feels very hacky, but we have to juggle authentication and codes.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postTwoFactor()
{
// Check that we have a session.
if ($userId = Session::pull('2fa_id')) {
$code = Binput::get('code');
// Maybe a temp login here.
Auth::loginUsingId($userId);
$valid = Google2FA::verifyKey(Auth::user()->google_2fa_secret, $code);
if ($valid) {
return Redirect::intended('dashboard');
} else {
// Failed login, log back out.
Auth::logout();
return Redirect::route('auth.login')->withError(trans('forms.login.invalid-token'));
}
}
return Redirect::route('auth.login')->withError(trans('forms.login.invalid-token'));
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
if (Session::has('user_instagram_info')) {
$rules = array('firstname' => 'required', 'surname' => 'required', 'shopname' => 'required', 'shopemail' => 'required|email', 'pass' => 'required', 'repass' => 'required|same:pass');
// do the validation ----------------------------------
// validate against the inputs from our form
$validator = Validator::make($request->all(), $rules);
// check if the validator failed -----------------------
if ($validator->fails()) {
// get the error messages from the validator
$messages = $validator->messages();
// redirect our user back to the form with the errors from the validator
return back()->withInput()->withErrors($messages);
} else {
$instagramInfo = Session::pull('user_instagram_info');
$user = new User();
$user->name = $request->input('firstname');
$user->surname = $request->input('surname');
$user->setAsSupplier();
$user->is_active = false;
$user->email = $request->input('shopemail');
$user->password = bcrypt($request->input('pass'));
$user->save();
$supplier = new Supplier();
$supplier->id = $user->id;
$supplier->shop_name = $request->input('shopname');
$supplier->profile_image = $instagramInfo->user->profile_picture;
$supplier->save();
$instagramAccount = new InstagramAccount();
$instagramAccount->instagram_id = $instagramInfo->user->id;
$instagramAccount->username = $instagramInfo->user->username;
$instagramAccount->access_token = $instagramInfo->access_token;
$instagramAccount->full_name = $instagramInfo->user->full_name;
$instagramAccount->bio = $instagramInfo->user->bio;
$instagramAccount->website = $instagramInfo->user->website;
$instagramAccount->profile_picture = $instagramInfo->user->profile_picture;
$supplier->instagramAccount()->save($instagramAccount);
Storage::makeDirectory($user->id);
return redirect()->action('AuthenticationController@showRegister')->with('success', ['Successful']);
}
} else {
return redirect()->action('AuthenticationController@showRegister');
}
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$rules = array('firstname' => 'required', 'surname' => 'required', 'customeremail' => 'required|email', 'pass' => 'required', 'phone' => 'required', 'rpass' => 'required|same:pass');
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
// get the error messages from the validator
$messages = $validator->messages();
// redirect our user back to the form with the errors from the validator
return back()->withInput()->withErrors($messages);
} else {
if (User::where('email', $request->input('customeremail'))->first()) {
return redirect()->action('AuthenticationController@showRegister')->withErrors(['messages' => "Sistemde mail adresi kayıtlı"]);
}
$user = new User();
$user->name = trim($request->input('firstname'));
$user->surname = trim($request->input('surname'));
$user->setAsCustomer();
$user->is_active = false;
$user->email = $request->input('customeremail');
$user->password = bcrypt($request->input('pass'));
$user->save();
$customer = new Customer();
$customer->phone = $request->input('phone');
$customer->id = $user->id;
$customer->save();
if (Session::has('user_instagram_info')) {
$instagramInfo = Session::pull('user_instagram_info');
$instagramAccount = new InstagramAccount();
$instagramAccount->instagram_id = $instagramInfo->user->id;
$instagramAccount->username = $instagramInfo->user->username;
$instagramAccount->access_token = $instagramInfo->access_token;
$instagramAccount->full_name = $instagramInfo->user->full_name;
$instagramAccount->bio = $instagramInfo->user->bio;
$instagramAccount->website = $instagramInfo->user->website;
$instagramAccount->profile_picture = $instagramInfo->user->profile_picture;
$customer->instagramAccount()->save($instagramAccount);
}
Storage::makeDirectory($user->id);
return redirect()->action('AuthenticationController@showRegister')->with('success', ['Successful']);
}
}
示例6: create
/**
* Show the form for creating a single new user.
* @return Response
*/
public function create()
{
// Check to see if we have been given a summary from the bulk add process.
// If this is the case then render the results view instead of the form.
$results = Session::pull('bulkResults');
if ($results) {
return View::make('users.bulk_summary')->with('results', $results);
} else {
return View::make('users.create');
}
}
示例7: removeFromComparison
public function removeFromComparison($property)
{
$modified = array_diff(Session::pull('properties_in_comparison', []), [$property->id]);
Session::put('properties_in_comparison', $modified);
}
示例8: store
//.........这里部分代码省略.........
}
//pr($res);
$i++;
}
//pr($res);
$count = [];
if (isset($res['update_prod'])) {
$count['update_prod'] = count($res['update_prod']);
}
if (isset($res['add_prod'])) {
$count['add_prod'] = count($res['add_prod']);
}
if (isset($res['add_to_GK'])) {
$count['add_to_GK'] = count($res['add_to_GK']);
}
if (isset($res['add_to_TV'])) {
$count['add_to_TV'] = count($res['add_to_TV']);
}
if (isset($res['add_to_MK'])) {
$count['add_to_MK'] = count($res['add_to_MK']);
}
if (isset($res['update_purch'])) {
$count['update_purch'] = count($res['update_purch']);
}
if (isset($res['add_purch'])) {
$count['add_purch'] = count($res['add_purch']);
}
Session::put('count', $count);
Session::put('res', $res);
//pr($res);
$cloudModel->addFile('import', $filename, $real_filename);
return redirect()->route('cloud.index');
}
} else {
Session::flash('message', GetMessages("ERROR_NO_CSV_FILE"));
return redirect()->route('cloud.index');
}
} else {
Session::flash('message', GetMessages("ERROR_NO_CSV_FILE"));
return redirect()->route('cloud.index');
}
}
if (isset($_POST['end_import'])) {
if (!right('Import')) {
abort(404);
}
$count = Session::pull('count', null);
$res = Session::pull('res', null);
//pr($res);
//pr($count);
if (isset($res['update_prod']) and count($res['update_prod']) > 0) {
$productModel->updatingListProducts($res['update_prod']);
}
if (isset($res['add_prod']) and count($res['add_prod']) > 0) {
$idsNewProducts = $productModel->createProducts($res['add_prod']);
Session::put('idsNewProducts', $idsNewProducts);
}
if (isset($res['add_to_GK']) and count($res['add_to_GK']) > 0) {
$productModel->addsToSite($res['add_to_GK'], 'GK');
}
if (isset($res['add_to_TV']) and count($res['add_to_TV']) > 0) {
$productModel->addsToSite($res['add_to_TV'], 'TV');
}
if (isset($res['add_to_MK']) and count($res['add_to_MK']) > 0) {
$productModel->addsToSite($res['add_to_MK'], 'MK');
}
if (isset($res['update_purch']) and count($res['update_purch']) > 0) {
$purchaseModel->updatePurchase($res['update_purch']);
}
if (isset($res['add_purch']) and count($res['add_purch']) > 0) {
$purchaseModel->addPurchases($res['add_purch']);
}
$historyModel->saveHistory('import', $count);
Session::flash('message', GetMessages("SUCCESS_IMPORT_COMPLETED"));
return redirect()->route('cloud.index');
}
if (isset($_POST['send_to_site'])) {
if (!right('Import')) {
abort(404);
}
//pr($_POST);
if (isset($_POST['sent_to_'])) {
$externalModel = new External();
if (isset($_POST['sent_to_']['GK'])) {
$externalModel->send('GK');
}
if (isset($_POST['sent_to_']['TV'])) {
$externalModel->send('TV');
}
if (isset($_POST['sent_to_']['GK'])) {
$externalModel->send('MK');
}
}
if (isset($_POST['clear_list'])) {
$productModel->deleteAllExport();
}
Session::flash('message', GetMessages("SUCCESS_EXTERNAL_EXPORT"));
return redirect()->route('cloud.index');
}
}
示例9: getIndex
/**
* Renders index page for the settings
*
* @return Response
*/
public function getIndex()
{
$settings = Settings::getAll();
$locales = Settings::getLocales();
return view('admin.settings.index', ['settings' => $settings, 'locales' => $locales, 'settings_tab' => Session::pull('settings_tab')]);
}
示例10: callback
public function callback(Request $request)
{
if (Session::get('instagram_operation')) {
$instagramOperation = Session::pull('instagram_operation');
if ($instagramOperation['operation'] == 'login') {
if ($request->get('code')) {
$code = $request->get('code');
$instagram = new InstagramAPI();
$data = $instagram->getOAuthToken($code);
$instagramAccount = InstagramAccount::where(['username' => $data->user->username, 'access_token' => $data->access_token])->first();
if ($instagramAccount) {
if (Auth::loginUsingId($instagramAccount->instagramable->user->id)) {
if ($instagramAccount->instagramable->user->isSupplier()) {
return redirect()->action('Dashboard\\SupplierController@show');
}
if ($instagramAccount->instagramable->user->isCustomer()) {
return redirect()->action('Dashboard\\CustomerController@show');
}
}
} else {
return redirect()->action('AuthenticationController@showRegister')->withErrors(['messages' => "Kayıtlı Kullanıcı Bulunamadı"]);
}
}
}
if ($instagramOperation['operation'] == 'register') {
if ($instagramOperation['user_type'] == 'supplier') {
if (Session::has('user_instagram_info')) {
Session::forget('user_instagram_info');
}
if ($request->get('code')) {
$code = $request->get('code');
$instagram = new InstagramAPI();
$data = $instagram->getOAuthToken($code);
Session::put('user_instagram_info', $data);
return Redirect::action('Dashboard\\SupplierController@create');
}
}
if ($instagramOperation['user_type'] == 'customer') {
if (Session::has('user_instagram_info')) {
Session::forget('user_instagram_info');
}
if ($request->get('code')) {
$code = $request->get('code');
$instagram = new InstagramAPI();
$data = $instagram->getOAuthToken($code);
Session::put('user_instagram_info', $data);
return Redirect::action('Dashboard\\CustomerController@create');
}
}
}
}
}
示例11: processConnect
/**
* Process the response from a provider connect attempt.
*
* @param string $provider
* @param \OAuth\Common\Service\AbstractService $service
* @param array $access_token
*
* @return Redirect
*/
protected function processConnect($provider, $service, $access_token)
{
$user_info_callback = Config::get('laravel-social::providers.' . strtolower($provider) . '.fetch_user_info');
if (empty($user_info_callback) || !$user_info_callback instanceof Closure) {
return Redirect::to(Session::pull('mmanos.social.onerror', '/'))->with(Config::get('laravel-social::error_flash_var'), 'There was a problem connecting your account (6).');
}
try {
$user_info = $user_info_callback($service);
} catch (Exception $e) {
}
if (empty($user_info) || !is_array($user_info)) {
return Redirect::to(Session::pull('mmanos.social.onerror', '/'))->with(Config::get('laravel-social::error_flash_var'), 'There was a problem connecting your account (7).');
}
if (empty($user_info['id'])) {
return Redirect::to(Session::pull('mmanos.social.onerror', '/'))->with(Config::get('laravel-social::error_flash_var'), 'There was a problem connecting your account (8).');
}
$provider_id = array_get($user_info, 'id');
$user_provider = Provider::where('provider', strtolower($provider))->where('provider_id', $provider_id)->first();
if ($user_provider) {
if ($user_provider->user_id != Auth::id()) {
return Redirect::to(Session::pull('mmanos.social.onerror', '/'))->with(Config::get('laravel-social::error_flash_var'), 'There was a problem connecting your account (9).');
}
$user_provider->access_token = $access_token;
$user_provider->save();
} else {
$this->linkProvider(Auth::id(), $provider, $provider_id, $access_token);
}
return Redirect::to(Session::pull('mmanos.social.onsuccess', '/'))->with(Config::get('laravel-social::success_flash_var'), 'You have successfully connected your account.');
}
示例12: logout
public function logout()
{
$post_data = array();
$post_data['ComToken'] = Session::pull('ComToken');
$post_data['Logout'] = Session::pull('AuthToken');
$response = $this->curlRequest($post_data);
Session::flush();
$this->loggedOut = true;
}
示例13: profile
public function profile($user_name = null)
{
if (trim($user_name) == "") {
if (Session::has('user')) {
$aUser = Session::pull('user');
$aCharacters = Character::where('user_id', $aUser['id'])->get()->toArray();
/*if(count($aCharacters) == 0){
return view('users.users.show')->with('characters', $aCharacters);
}*/
return view('users.users.show')->with('characters', $aCharacters);
} else {
return redirect('user');
}
} else {
}
}
示例14: check
public function check($captcha = null, $sessionName = '_captcha')
{
return Session::pull($sessionName) === strtoupper($captcha);
}
示例15: DeleteProductFromBasket
public function DeleteProductFromBasket($id, $model)
{
$ids = array();
foreach (Session::pull("basketProducts") as $product) {
if ($product[0] == $id && $product[1] == $model) {
continue;
}
array_push($ids, array($product[0], $product[1]));
}
Session::put("basketProducts", $ids);
return "success";
}