本文整理汇总了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'));
}
示例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';
}
示例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);
}
示例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;
}
示例5: resolve
/**
* Resolve locale
*
* @return mixed
*/
public function resolve()
{
if ($locale = $this->request->segment(config('localizer.request.segment', 1))) {
return $locale;
}
return $this->resolveHeader();
}
示例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);
}
示例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');
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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);
}
示例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;
}
示例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());
}
示例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);
}
示例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);
}