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


PHP Request::segment方法代碼示例

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


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

示例1: handle

 /**
  * Detect the active module and setup our
  * environment with it.
  */
 public function handle()
 {
     /**
      * In order to detect we MUST have a route
      * and we MUST have a namespace in the
      * streams::addon action parameter.
      *
      * @var Route $route
      */
     $route = $this->request->route();
     /* @var Module $module */
     if ($route && ($module = $this->modules->get(array_get($route->getAction(), 'streams::addon')))) {
         $module->setActive(true);
     }
     if (!$module && $this->request->segment(1) == 'admin' && ($module = $this->modules->findBySlug($this->request->segment(2)))) {
         $module->setActive(true);
     }
     if (!$module) {
         return;
     }
     $this->container->make('view')->addNamespace('module', $module->getPath('resources/views'));
     $this->container->make('translator')->addNamespace('module', $module->getPath('resources/lang'));
     $this->asset->addPath('module', $module->getPath('resources'));
     $this->image->addPath('module', $module->getPath('resources'));
 }
開發者ID:huglester,項目名稱:streams-platform,代碼行數:29,代碼來源:DetectActiveModule.php

示例2: getInputView

 /**
  * Get the input view.
  *
  * @return string
  */
 public function getInputView()
 {
     if ($this->request->segment(1) == 'admin') {
         return 'anomaly.field_type.decimal::admin/input';
     }
     return 'anomaly.field_type.decimal::input';
 }
開發者ID:visualturk,項目名稱:decimal-field_type,代碼行數:12,代碼來源:DecimalFieldType.php

示例3: 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()) {
         return redirect($request->segment(1) . '/' . $request->segment(2));
     }
     return $next($request);
 }
開發者ID:Tisho84,項目名稱:conference,代碼行數:14,代碼來源:RedirectIfAuthenticated.php

示例4: tryUrl

 /**
  * Try to get a locale by it's request slug
  *
  * @return bool
  */
 protected function tryUrl()
 {
     if ($slug = $this->request->segment(1, false)) {
         return $this->isValidLanguage($slug);
     }
     return false;
 }
開發者ID:wegnermedia,項目名稱:melon,代碼行數:12,代碼來源:CurrentLanguageDetector.php

示例5: resolve

 /**
  * Resolve locale
  *
  * @return mixed
  */
 public function resolve()
 {
     if ($locale = $this->request->segment(config('localizer.request.segment', 1))) {
         return $locale;
     }
     return $this->resolveHeader();
 }
開發者ID:adminarchitect,項目名稱:localizer,代碼行數:12,代碼來源:RequestResolver.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // $this->makeIlogicalCan();
     switch ($request->method()) {
         case 'GET':
             if ($request->segment(3) == 'create') {
                 $this->makeAuthentization('create', 'posts');
                 // dd($request->segment(3));
             } elseif ($request->segment(4) == 'edit') {
                 $id = $request->segment(3);
                 $this->makeAuthentization('edit', 'posts', (int) $id);
             }
             break;
         case 'POST':
             $this->makeAuthentization('create', 'posts');
             break;
         case 'PUT':
             $id = $request->segment(3);
             $this->makeAuthentization('edit', 'posts', (int) $id);
             break;
         case 'DELETE':
             $id = $request->segment(3);
             $this->makeAuthentization('delete', 'posts', (int) $id);
             break;
     }
     return $next($request);
 }
開發者ID:hazicms,項目名稱:auth,代碼行數:34,代碼來源:AuthBasicMiddleware.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // we expect a url in the form /groups/{group_id}
     if ($request->segment(1) == 'groups') {
         if ($this->auth->guest()) {
             $group = \App\Group::findOrFail($request->segment(2));
             if ($group->isPublic()) {
                 return $next($request);
             } else {
                 return redirect()->back()->with('message', trans('messages.not_allowed'));
             }
         } else {
             $group = \App\Group::findOrFail($request->segment(2));
             if ($group->isPublic()) {
                 return $next($request);
             } elseif ($group->isMember()) {
                 return $next($request);
             } elseif ($request->user()->isAdmin()) {
                 return $next($request);
                 // user is admin, and sees everything, fine (at least in sync with current policies for admins)
             } else {
                 return redirect()->back()->with('message', trans('messages.not_allowed'));
             }
         }
     } else {
         return redirect()->back()->with('message', 'Are you in a group at all !? (url doesnt start with group/something). This is a bug');
     }
 }
開發者ID:philippejadin,項目名稱:Mobilizator,代碼行數:36,代碼來源:RedirectIfNotGroupMemberOrPublicGroup.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $modelIndex = Application::context(Application::CXT_API) ? 3 : 2;
     $idIndex = Application::context(Application::CXT_API) ? $modelIndex + 1 : $modelIndex + 2;
     // Check for the model slug. Throw 404 if not found.
     $modelSegment = $request->segment($modelIndex);
     $idSegment = $request->segment($idIndex);
     $blueprint = ModelBlueprint::slug($modelSegment);
     if (!$blueprint) {
         $message = "Class for '{$modelSegment}' does not exist";
         return Application::context(Application::CXT_API) ? RESTResponse::failed($message, 404) : response($message, 404);
     }
     $class = $blueprint->getClass();
     // Check if the model ID was given.
     if ($idSegment) {
         $model = $class::find($idSegment);
         if (!$model) {
             $message = "Model '{$modelSegment}/{$idSegment}' does not exist";
             return Application::context(Application::CXT_API) ? RESTResponse::failed($message, 404) : response($message, 404);
         }
         $request->Model = $model;
         return $next($request);
     }
     // Otherwise, return the static model class.
     $request->Model = new $class();
     return $next($request);
 }
開發者ID:breachofmind,項目名稱:birdmin,代碼行數:34,代碼來源:ModelRequest.php

示例9: getUriLocale

 /**
  * Get locale for uri.
  *
  * @return string
  */
 public function getUriLocale()
 {
     $segment = $this->request->segment(1);
     if ($this->isValidLocale($segment)) {
         return $segment;
     }
     return $this->getDefaultLocale();
 }
開發者ID:kiaking,項目名稱:laravel-locale,代碼行數:13,代碼來源:Manager.php

示例10: index

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     if (CNF_FRONT == 'false' && $request->segment(1) == '') {
         return Redirect::to('dashboard');
     }
     $page = $request->segment(1);
     if ($page != '') {
         $content = \DB::table('tb_pages')->where('alias', '=', $page)->where('status', '=', 'enable')->get();
         //print_r($content);
         //return '';
         if (count($content) >= 1) {
             $row = $content[0];
             $this->data['pageTitle'] = $row->title;
             $this->data['pageNote'] = $row->note;
             $this->data['pageMetakey'] = $row->metakey != '' ? $row->metakey : CNF_METAKEY;
             $this->data['pageMetadesc'] = $row->metadesc != '' ? $row->metadesc : CNF_METADESC;
             $this->data['breadcrumb'] = 'active';
             if ($row->access != '') {
                 $access = json_decode($row->access, true);
             } else {
                 $access = array();
             }
             // If guest not allowed
             if ($row->allow_guest != 1) {
                 $group_id = \Session::get('gid');
                 $isValid = isset($access[$group_id]) && $access[$group_id] == 1 ? 1 : 0;
                 if ($isValid == 0) {
                     return Redirect::to('')->with('message', \SiteHelpers::alert('error', Lang::get('core.note_restric')));
                 }
             }
             if ($row->template == 'backend') {
                 $page = 'pages.' . $row->filename;
             } else {
                 $page = 'layouts.' . CNF_THEME . '.index';
             }
             //print_r($this->data);exit;
             $filename = base_path() . "/resources/views/pages/" . $row->filename . ".blade.php";
             if (file_exists($filename)) {
                 $this->data['pages'] = 'pages.' . $row->filename;
                 //	print_r($this->data);exit;
                 return view($page, $this->data);
             } else {
                 return Redirect::to('')->with('message', \SiteHelpers::alert('error', \Lang::get('core.note_noexists')));
             }
         } else {
             return Redirect::to('')->with('message', \SiteHelpers::alert('error', \Lang::get('core.note_noexists')));
         }
     } else {
         $this->data['pageTitle'] = 'Home';
         $this->data['pageNote'] = 'Welcome To Our Site';
         $this->data['breadcrumb'] = 'inactive';
         $this->data['pageMetakey'] = CNF_METAKEY;
         $this->data['pageMetadesc'] = CNF_METADESC;
         $this->data['pages'] = 'pages.home';
         $page = 'layouts.' . CNF_THEME . '.index';
         return view($page, $this->data);
     }
 }
開發者ID:alvarobfdev,項目名稱:applog,代碼行數:63,代碼來源:HomeController.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @return mixed
  */
 public function handle($request, \Closure $next)
 {
     $locale = $this->request->segment(1) ?: App::getLocale();
     $item = $this->menuItem->findByUriInLanguage($this->request->segment(2), $locale);
     if ($this->isOffline($item)) {
         App::abort(404);
     }
     return $next($request);
 }
開發者ID:Houbsi,項目名稱:Core,代碼行數:16,代碼來源:PublicMiddleware.php

示例12: getCategory

 /**
  * Get the current category based on the URL
  *
  * @throws Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 protected function getCategory()
 {
     $path = $this->request->segment(1);
     $this->category = Category::findPublicCategory($path);
     if (!$this->category) {
         throw new NotFoundHttpException('Category not found.');
     }
     return $this->category;
 }
開發者ID:newmarkets,項目名稱:content,代碼行數:14,代碼來源:Controller.php

示例13: handle

 /**
  * Handle the event.
  */
 public function handle()
 {
     if (in_array($this->request->path(), ['admin/logout'])) {
         return;
     }
     if ($this->request->segment(1) !== 'admin') {
         return;
     }
     $this->template->put('cp', $this->controlPanel->build());
 }
開發者ID:jacksun101,項目名稱:streams-platform,代碼行數:13,代碼來源:LoadControlPanel.php

示例14: exportRefereeTwo

 public function exportRefereeTwo(Request $request)
 {
     $profile = Applications::where('reference_two_id', $request->segment(4))->first();
     $ref = References::where('id', '=', $request->segment(4))->first();
     $settings = Fields::where('references_id', '=', $request->segment(4))->first();
     $pdf = PDF::loadView('pdf.refereetwo', compact('profile', 'ref', 'settings', 'custom'));
     $name = $profile->first_name . '-' . $profile->surname . '-references-';
     $pdfFilename = urlencode(strtolower($name . '-' . date('d-m-Y') . '.pdf'));
     return $pdf->download($pdfFilename);
 }
開發者ID:wyrover,項目名稱:applications,代碼行數:10,代碼來源:ApplicationsController.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest($request->segment(1) . '/' . $request->segment(2) . '/auth/login');
         }
     }
     return $next($request);
 }
開發者ID:Tisho84,項目名稱:conference,代碼行數:18,代碼來源:Authenticate.php


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