當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::url方法代碼示例

本文整理匯總了PHP中Illuminate\Http\Request::url方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::url方法的具體用法?PHP Request::url怎麽用?PHP Request::url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Http\Request的用法示例。


在下文中一共展示了Request::url方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: resolve

 /**
  * Resolve the post.
  *
  * @return PostInterface|null
  */
 public function resolve()
 {
     $url = $this->request->url();
     $tmp = explode('/', $url);
     $last_seg = end($tmp);
     return $this->repository->findBySlug($last_seg);
 }
開發者ID:RowlandOti,項目名稱:ooglee-blogmodule,代碼行數:12,代碼來源:PostResolver.php

示例2: email

 public function email(Request $request)
 {
     $data = [];
     // @todo: place the validation logics somewhere else
     if ($request->isMethod('post')) {
         // Require only first row
         $validator = \Validator::make($request->all(), ['invite.email.0' => 'required', 'invite.name.0' => 'required']);
         // Validate the inputs
         $validator->each('invite.email', ['email']);
         $validator->each('invite.name', ['max:50', 'min:5']);
         $validator->setCustomMessages(['invite.email.0.required' => 'First row email required', 'invite.name.0.required' => 'First row name required']);
         if ($validator->fails()) {
             return redirect($request->url())->withInput()->withErrors($validator->errors());
         }
         foreach ($request->input('invite.email') as $key => $email) {
             $name = $request->input('invite.name.' . $key, strstr($email, '@', true));
             // Sometimes exception is thrown even though mail is sent successfully
             try {
                 \Mail::send('emails.invitation', compact('name', 'email'), function ($mail) use($email, $name) {
                     $mail->from('invitation@footies.report', 'Footies Report')->to($email, $name)->subject('Invitation to join Footies Report!');
                 });
             } catch (\Exception $e) {
                 // Do nothing
             }
         }
         return redirect($request->url())->with('success', 'Processed successfully');
     }
     return view('admin.invite.email', $data);
 }
開發者ID:bibekbhattaraibrt,項目名稱:football,代碼行數:29,代碼來源:InviteController.php

示例3: generateMenu

 private function generateMenu()
 {
     $currentUrl = $this->request->url();
     $user = $this->request->user();
     if (empty($user)) {
         return array();
     }
     return array(array('prefix' => 'Добрый день,', 'href' => route('admin.user.show', $this->request->user()->id), 'link' => $this->getUserName(), 'active' => $currentUrl == route('admin.user.show', $user->id) || $currentUrl == route('admin.user.edit', $user->id)), array('prefix' => '', 'href' => route('admin.user.index'), 'link' => 'Управление пользователями', 'active' => $currentUrl == route('admin.user.index')), array('prefix' => '', 'href' => route('admin.index'), 'link' => 'Рабочий стол', 'active' => $currentUrl == route('admin.index')), array('prefix' => '', 'href' => route('admin.logout'), 'link' => 'Выход'));
 }
開發者ID:qubikr,項目名稱:laravel,代碼行數:9,代碼來源:AdminTopMenuComposer.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //check for user's role
     $has_role = false;
     if (!$this->auth->guest() && $this->auth->user() != null) {
         $required_role = $request->route()->getAction()['role'];
         if ($required_role == '*') {
             $has_role = true;
         } else {
             $roles = $this->auth->user()->roles;
             foreach ($roles as $role) {
                 if ($role->id_role == 'admin' || $role->id_role == $required_role) {
                     $has_role = true;
                     break;
                 }
             }
         }
     }
     if ($this->auth->guest() || !$has_role) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect(route('admin-login') . '?return_url=' . urlencode($request->url()));
         }
     }
     return $next($request);
 }
開發者ID:neonbug,項目名稱:meexo-common,代碼行數:34,代碼來源:AuthenticateAdmin.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (($this->isMobile() || $this->isTablet()) && !strstr($request->url(), 'sorry')) {
         return redirect('sorry');
     }
     return $next($request);
 }
開發者ID:morosawamikihito,項目名稱:ChatApp,代碼行數:14,代碼來源:RedirectIfMobile.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!\App\Gini\Gapper\Client::getUserName() && !in_array($request->url(), [route('root'), route('login')])) {
         return redirect()->to(route('root'));
     }
     return $next($request);
 }
開發者ID:genee-projects,項目名稱:snail,代碼行數:15,代碼來源:GapperMiddleware.php

示例7: paginate

 private function paginate($items, $perPage, Request $request)
 {
     $page = Input::get('page', 1);
     // get current page or default to 1
     $offset = $page * $perPage - $perPage;
     return new LengthAwarePaginator(array_slice($items, $offset, $perPage, false), count($items), $perPage, $page, ['path' => $request->url(), 'query' => $request->query()]);
 }
開發者ID:ReyRodriguez,項目名稱:laravel-reddit,代碼行數:7,代碼來源:CommentController.php

示例8: category

 public function category(Request $request)
 {
     $lastSegment = preg_split("/\\//", $request->url());
     $categorySlug = array_pop($lastSegment);
     // get the last segment on the current url
     $category = Tag::where('slug', $categorySlug)->first();
     // check if there is no category found.
     if (!$category) {
         return redirect()->route('front.error-404');
     }
     // condition where clause for parent categories or child.
     if ($category->parent_id == 0) {
         $field = 'tags.parent_id';
         $value = $category->id;
     } else {
         $field = 'tags.slug';
         $value = $category->slug;
     }
     // Get posts by PostTag slug or parent_id field
     $properties = Post::join('post_tags', 'posts.id', '=', 'post_tags.post_id')->join('tags', 'post_tags.tag_id', '=', 'tags.id')->where($field, $value)->select('posts.*', 'tags.name as tagName')->paginate(config('front.postPerPage'));
     $pageTitle = 'Category: ' . $category->name;
     if ($category->parent_id == 0) {
         $breadcrumbData = [['url' => url(), 'name' => 'Home'], ['url' => route('front.category') . '/' . $category->slug, 'name' => $category->name]];
     } else {
         $breadcrumbData = [['url' => url(), 'name' => 'Home'], ['url' => route('front.category', $category->parent()->slug), 'name' => $category->parent()->name], ['url' => route('front.category') . '/' . $category->parent()->slug . '/' . $category->slug, 'name' => $category->name]];
     }
     return view('properties', compact('properties', 'pageTitle', 'breadcrumbData'));
 }
開發者ID:junibrosas,項目名稱:realestate,代碼行數:28,代碼來源:FrontController.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Put in cache all of route which are tag
     $routes = Cache::remember('tags', 120, function () {
         return Route::all();
     });
     $results = [];
     // Check if current route has tags
     foreach ($routes as $route) {
         if (preg_match('%^' . $route->route . '$%', $request->url())) {
             array_push($results, $route->tag_container_id);
         }
     }
     // Get all container tag of the current route and add this to the layout
     $contents = Tag::whereIn('tag_container_id', $results)->get();
     if ($contents) {
         foreach ($contents as $content) {
             // if data content format this to integrate them into the script
             if ($content->data) {
                 $data = explode(',', $content->data);
                 $params = [];
                 foreach ($data as $value) {
                     $params[] = "'+ {$value} +'";
                 }
                 $script = sprintf($content->content, ...$params);
             } else {
                 $script = $content->content;
             }
             // add script to namespace declared in database
             js($content->position . '-tag')->append($script);
         }
     }
     return $next($request);
 }
開發者ID:frenchfrogs,項目名稱:tag,代碼行數:41,代碼來源:TagMiddleware.php

示例10: __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');
                 }
             }
         }
     }
 }
開發者ID:ariefsetya,項目名稱:it-club,代碼行數:40,代碼來源:HomeController.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     //
     echo $request->path(), '<br>';
     echo $request->url();
     //return "this is  Admin";
 }
開發者ID:elickzhao,項目名稱:laravel_test,代碼行數:12,代碼來源:AdminController.php

示例12: create

 /**
  * post的方式添加一條記錄
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     $request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
     //驗證參數
     $validator = Validator::make($request->all(), ['name' => 'required|max:255']);
     //驗證參數完整性
     if ($validator->fails()) {
         $error = $validator->errors()->all();
         //寫入日誌
         Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
         //返回錯誤信息
         return Error::returnError($request_url, 1001);
     }
     //驗證token
     //        $user_id=Common::validateToken($request->get('token'));
     //
     //        if($user_id == false){
     //            return Error::returnError($request_url,2002);
     //        }
     $name = $request->get('name');
     //寫入操作
     $add = Task::addTask($name);
     $info = Task::getTaskInfo($add);
     //返回對應的結果
     $json_arr = ['request' => $request_url, 'ret' => $info];
     return Common::returnResult($json_arr);
 }
開發者ID:diandianxiyu,項目名稱:LaravelApi,代碼行數:32,代碼來源:TaskController.php

示例13: VisitorModel

 function __construct(Request $request)
 {
     $visitorModel = new VisitorModel();
     $visitorModel->ip = $request->getClientIp();
     $visitorModel->url = $request->url();
     $visitorModel->save();
 }
開發者ID:nunonano,項目名稱:ideprogram,代碼行數:7,代碼來源:FrontendController.php

示例14: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Exception $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if (strpos($request->url(), '/api/') === false) {
         return parent::render($request, $e);
     }
     $response = [];
     // If the app is in debug mode
     if (config('app.debug')) {
         // Add the exception class name, message and stack trace to response
         $response['exception'] = get_class($e);
         // Reflection might be better here
         $response['message'] = $e->getMessage();
         $response['file'] = $e->getFile();
         $response['line'] = $e->getLine();
     }
     // Default response of 400
     $status = 400;
     // If this exception is an instance of HttpException
     if ($this->isHttpException($e)) {
         // Grab the HTTP status code from the Exception
         $status = $e->getStatusCode();
         $response['status'] = $status;
         $response['message'] = self::$statusMessages[$status];
     }
     // Return a JSON response with the response array and status code
     return response()->json($response, $status)->header('Access-Control-Allow-Origin', env('ALLOWED_HOSTS', '*'))->header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')->header('Access-Control-Allow-Credentials', 'true')->header('Access-Control-Allow-Headers', 'Content-Type, X-Auth-Token, Origin, Authorization');
 }
開發者ID:yayatoure42,項目名稱:service-exchange,代碼行數:34,代碼來源:ApiHandler.php

示例15: login

 /**
  * 用戶通過郵箱和密碼進行登錄操作
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function login(Request $request)
 {
     //獲取當前訪問的全部的地址
     $request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
     //驗證參數
     $validator = Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required']);
     //驗證參數完整性
     if ($validator->fails()) {
         // var_dump($validator);
         $error = $validator->errors()->all();
         //寫入日誌
         Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
         //返回錯誤信息
         return Error::returnError($request_url, 1001);
     }
     $email = $request->get('email');
     $password = $request->get('password');
     //檢查有沒有
     $user_model = User::checkUserLogin($email, $password);
     if ($user_model == false) {
         return Error::returnError($request_url, 2001);
     }
     //更新token
     $token = User::updateToken($user_model);
     //返回對應的結果
     $json_arr = ['request' => $request_url, 'ret' => User::getUserInfo($user_model->id), 'token' => $token];
     return Common::returnResult($json_arr);
 }
開發者ID:diandianxiyu,項目名稱:LaravelApi,代碼行數:34,代碼來源:UserController.php


注:本文中的Illuminate\Http\Request::url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。