本文整理汇总了PHP中Illuminate\Support\Facades\Session::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::has方法的具体用法?PHP Session::has怎么用?PHP Session::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Session
的用法示例。
在下文中一共展示了Session::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request and check for playerId in the session
* If it cannot be found it will redirect the the URL in the config
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Session::has('email')) {
return $next($request);
}
return redirect('/' . config('sol.loginUrl', 'sollogin'));
}
示例2: __construct
/**
* The constructor searches for an already set locale. If none is found, set the default locale.
*/
public function __construct()
{
if (!Session::has('locale')) {
Session::put('locale', $this->languages[0]);
}
app()->setLocale(Session::get('locale'));
}
示例3: set
public function set($key, $value)
{
if (!Session::has($this->namespace)) {
$this->clear();
}
Session::put($this->namespace . '.' . $key, $value);
}
示例4: handle
/**
* @param Request $request
* @param Closure $next
*/
public function handle($request, Closure $next)
{
Lang::setFallback(self::getDefault());
$setLocale = Session::get('setLocale');
//flash data
if (Config::get('app.locale_use_cookie')) {
if ($setLocale) {
Session::set('locale', $setLocale);
}
if (Session::has('locale')) {
App::setLocale(Session::get('locale'));
} else {
self::autoDetect();
}
} else {
if (Config::get('app.locale_use_url')) {
if ($setLocale) {
self::setLocaleURLSegment($setLocale);
} else {
$lang = self::getLocaleFromURL();
if ($lang) {
App::setLocale($lang);
} else {
if ($request->segment(1) != 'locale') {
//ignore set-locale URL
self::autoDetect();
self::setLocaleURLSegment(self::get());
}
}
}
}
}
View::share('lang', self::get());
}
示例5: register
public function register(Request $request)
{
if (Session::has('ror_user')) {
return redirect('/');
}
if ($request->isMethod('post')) {
try {
$objModelUsers = User::getInstance();
$data = array('email' => $request['email'], 'password' => Hash::make($request['signUpPassword']), 'report_login_active' => 1, 'business_login_active' => 1, 'role' => 0);
$user = $objModelUsers->addNewUser($data);
if ($user) {
$userDetails = $objModelUsers->getUserById($user);
$userMetaData['user_id'] = $userDetails['original']['id'];
$userMetaData['full_name'] = $request->input('full_name');
$objModelUserMeta = new Usersmeta();
$usermetaDetails = $objModelUserMeta->InsertUserMeta($userMetaData);
if ($usermetaDetails) {
return redirect()->intended('/login');
} else {
return view("User/Views/user/login")->withErrors(['registerErrMsg' => 'Something went wrong, please try again.']);
}
} else {
return view("User/Views/user/register")->withErrors(['registerErrMsg' => 'Something went wrong, please try again.']);
}
} catch (\Exception $ex) {
return redirect()->back()->with('exception', 'An exception occurred, please reload the page and try again.');
}
}
return view("User/Views/user/register");
}
示例6: isLoggedIn
/**
* Check if user logged in or not
*
* @return bool
*/
public function isLoggedIn()
{
if (Session::has('user_auth')) {
return true;
}
return false;
}
示例7: place
public function place(Order $orderModel, OrderItem $orderItem)
{
//Método plcae order, quando acessar esse método ele ira acessar o carrinho de comprar e começar a executar
//os pedidos
if (!Session::has('cart')) {
return false;
}
$cart = Session::get('cart');
// recupera o carrinho de compras
if ($cart->getTotal() > 0) {
//Order retorna um id que será o código da ORDER
$order = $orderModel->create(['user_id' => Auth::user()->id, 'total' => $cart->getTotal()]);
/*Método all corresponde ao método da classe Cart*/
foreach ($cart->all() as $k => $item) {
//Toda vez que der o save tem que passar a instancia lá para dentro
$order->itens()->create(['product_id' => $k, 'price' => $item['price'], 'qtd' => $item['qtd']]);
}
// Para limpar o carrinho de compras
$cart->clear();
// Evento Checkout
// Precisa passar o usuario, nome, order itens do pedido
event(new CheckoutEvent(Auth::user(), $order));
//event(new CheckoutEvent());
return view('store.checkout', compact('order', 'cart'));
}
$categories = Category::all();
return view('store.checkout', ['cart' => 'empty', 'categories' => $categories]);
}
示例8: __construct
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(Request $r)
{
date_default_timezone_set("Asia/Jakarta");
//$this->middleware('auth');
//echo "<pre>".print_r($_SERVER,1)."</pre>";
$log = new Logdata();
$log->idpengguna = Auth::check() ? Auth::user()->id : 0;
$log->url = $r->url();
$log->user_agent = $_SERVER['HTTP_USER_AGENT'];
$log->ip = $_SERVER['REMOTE_ADDR'];
$log->ip_port = isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : "";
$log->http_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "";
$log->http_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "";
$log->pathinfo = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : "";
$log->save();
// echo Auth::user()->password;
// if(Auth::check()){
// if(Auth::user()->password==""){
// header("location:".url('notfound'));
// die();
// }
// }
// Session::put("a-".getenv('REMOTE_ADDR')."-3",'x');
foreach (\App\Popups::all() as $key) {
$isi = array();
if ($key->tipe_valid == "by_datetime" or $key->tipe_valid == "by_date") {
$cek = $this->check_in_range(date_format(date_create($key->date_valid_start . " " . $key->time_valid_start), "Y-m-d H:i:s"), date_format(date_create($key->date_valid_end . " " . $key->time_valid_end), "Y-m-d H:i:s"), date("Y-m-d H:i:s"));
if ($cek) {
if (!Session::has("a-" . getenv('REMOTE_ADDR') . "-" . $key->id)) {
Session::put("a-" . getenv('REMOTE_ADDR') . "-" . $key->id, 'x');
}
}
}
}
}
示例9: get_user
/**
* Get the user object from the session
* @return mixed|null
*/
function get_user()
{
if (!Session::has("user")) {
return null;
}
return Session::get("user");
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!(Session::has('user') && Session::get('user') == 'admin')) {
return Redirect::to('/auth');
}
return $next($request);
}
示例11: place_order
public function place_order(Order $orderModel, OrderItems $orderItems, CheckoutService $checkoutService)
{
if (!Session::has('cart')) {
return false;
}
$cart = Session::get('cart');
$categories = Category::all();
if ($cart->getTotal() > 0) {
$order = $orderModel::create(['user_id' => Auth::User()->id, 'total' => $cart->getTotal(), 'status' => '0']);
foreach ($cart->all() as $id => $item) {
$order->items()->create(['order_id' => $order->id, 'product_id' => $id, 'price' => $item['price'], 'qtd' => $item['qtd']]);
}
$checkout = $checkoutService->createCheckoutBuilder();
$checkout->setReference($order->id);
foreach ($order->items as $order_item) {
$checkout->addItem(new Item($order_item->product_id, $order_item->product->name, $order_item->price));
}
$response = $checkoutService->checkout($checkout->getCheckout());
$order->update(['payment_code' => $response->getCode()]);
event(new CheckoutEvent($order, Auth::user()));
$cart->clear();
return redirect($response->getRedirectionUrl());
//return view('checkout.place_order', ['order'=>$order, 'cart'=>'saved', 'categories'=>$categories]);
}
return view('checkout.place_order', ['cart' => 'empty', 'categories' => $categories]);
}
示例12: upload
/**
* @param Request $request
* @Post("/gallery/upload")
* @Patch("/gallery/upload")
*/
public function upload(Request $request)
{
if (!Session::has('gallery_hash')) {
Session::put('gallery_hash', md5(time()));
}
return Response::json(['attachment' => ImageUploadFacade::attachmentUpload($request->file('upl'), new GalleryAttachment(), 'gallery', true)]);
}
示例13: place
public function place(Order $orderModel, OrderItem $ordemItem, CheckoutService $checkoutService)
{
if (!Session::has('cart')) {
return "FALSE";
}
$cart = Session::get('cart');
$categories = Category::all();
if ($cart->getTotal() > 0) {
$checkout = $checkoutService->createCheckoutBuilder();
//pagseguro
$order = $orderModel->create(['user_id' => Auth::user()->id, 'total' => $cart->getTotal()]);
//inclui na tabela
foreach ($cart->all() as $k => $item) {
$checkout->addItem(new Item($k, $item['name'], number_format($item['price'], 2, ".", ""), $item['qtd']));
//pagseguro
$order->items()->create(['product_id' => $k, 'price' => $item['price'], 'qtd' => $item['qtd']]);
//inclui na tabela
}
$cart->clear();
event(new CheckoutEvent(Auth::user(), $order));
$response = $checkoutService->checkout($checkout->getCheckout());
//pagseguro
return redirect($response->getRedirectionUrl());
//pagseguro
#return view('store.checkout', compact('cart', 'order', 'categories'));
} else {
return view('store.checkout', ['cart' => 'empty', 'categories' => $categories]);
}
}
示例14: place
public function place(Order $orderModel, Category $cat, CheckoutService $checkoutService)
{
if (!Session::has('cart')) {
return false;
}
# bring all categories
$categories = $cat->all();
$cart = Session::get('cart');
if ($cart->getTotal() > 0) {
$checkoutBuilder = $checkoutService->createCheckoutBuilder();
# create order
$order = $orderModel->create(['user_id' => Auth::user()->id, 'total' => $cart->getTotal()]);
# insert items into this order
foreach ($cart->all() as $id => $item) {
$checkoutBuilder->addItem(new Item($item['num'], $item['name'], $item['price']));
$order->items()->create(['product_id' => $id, 'price' => $item['price'], 'quantity' => $item['num']]);
}
# clear cart
$cart->clear();
# fire event (email) only if everything worked
event(new CheckoutEvent(Auth::user(), $order));
$checkout = $checkoutBuilder->getCheckout();
$response = $checkoutService->checkout($checkout);
# PagSeguro site redirect
return redirect($response->getRedirectionUrl());
//return view('store.checkout', compact('order', 'categories'));
}
return view('store.checkout', ['order' => null, 'categories' => $categories]);
}
示例15: checkQuiz
public function checkQuiz()
{
if (Session::has('id') && (Session::get('type') === 'Student' || Session::get('type') === 'SuperAdmin')) {
$input = Request::all();
$correctAnswers = Session::get('correct_answer');
$total_qus = Session::get('total_qus');
$count = 0;
foreach ($correctAnswers as $key => $value) {
$k = 'q-' . $key;
if (isset($input[$k]) && $input[$k] == $value) {
$count++;
}
}
$marks = $count;
$tot_marks = $total_qus;
$s = $tot_marks - $marks;
//echo $s;
$result = new Result();
$result->marks = $marks;
$result->total_marks = $tot_marks;
$result->unanswered = $s;
$result->save();
return View::make('result', array('result' => $result));
} else {
echo 'You are not authorized';
}
}