本文整理汇总了PHP中Illuminate\Support\Facades\Route::current方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::current方法的具体用法?PHP Route::current怎么用?PHP Route::current使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Route
的用法示例。
在下文中一共展示了Route::current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Creates the view object for the HTML client.
*
* @param \Aimeos\MW\Config\Iface $config Configuration object
* @param array $templatePaths List of base path names with relative template paths as key/value pairs
* @param string|null $locale Code of the current language or null for no translation
* @return \Aimeos\MW\View\Iface View object
*/
public function create(\Aimeos\MW\Config\Iface $config, array $templatePaths, $locale = null)
{
$params = $fixed = array();
if ($locale !== null) {
$params = Route::current()->parameters() + Input::all();
$fixed = $this->getFixedParams();
$i18n = app('\\Aimeos\\Shop\\Base\\I18n')->get(array($locale));
$translation = $i18n[$locale];
} else {
$translation = new \Aimeos\MW\Translation\None('en');
}
$view = new \Aimeos\MW\View\Standard($templatePaths);
$helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation);
$view->addHelper('translate', $helper);
$helper = new \Aimeos\MW\View\Helper\Url\Laravel5($view, app('url'), $fixed);
$view->addHelper('url', $helper);
$helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $params);
$view->addHelper('param', $helper);
$helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
$view->addHelper('config', $helper);
$sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
$sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
$helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000);
$view->addHelper('number', $helper);
$helper = new \Aimeos\MW\View\Helper\Request\Laravel5($view, Request::instance());
$view->addHelper('request', $helper);
$helper = new \Aimeos\MW\View\Helper\Csrf\Standard($view, '_token', csrf_token());
$view->addHelper('csrf', $helper);
return $view;
}
示例2: validateRoute
public static function validateRoute()
{
$route = Route::current();
$route_name = $route->getName();
if (!$route_name) {
$route_name = $route->getActionName();
}
$params = $route->parametersWithoutNulls();
$ids = [];
if ($params) {
$param = current($params);
if (is_numeric($param)) {
$ids[] = $param;
}
}
$result = AclFacade::check($route_name, $ids);
if (!$result) {
$error_message = "No Permission for {$route_name}";
if ($ids) {
$error_message .= " for id: {$ids[0]}";
}
throw new NoPermissionsException($error_message);
}
return $result;
}
示例3:
function __construct()
{
// share current route in all views
View::share('current_url', Route::current()->getPath());
// share current logged in user details all views
View::share('current_user', $this->current_user());
}
示例4: handle
/**
* Handle an incoming request.
* This Middleware checks for a 'tailnumber' parameter and converts it to all uppercase if it exists.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param String $permission
* @param String $enforce_same_crew
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Route::current()->hasParameter('tailnumber')) {
Route::current()->setParameter('tailnumber', strtoupper(Route::current()->getParameter('tailnumber')));
}
return $next($request);
}
示例5: __construct
/**
* Controller constructor
*
* @param jsonRPCClient $bitcoin_core
* @param ZebraCURL $curl
* @return void
*/
public function __construct(jsonRPCClient $bitcoin_core, ZebraCURL $curl)
{
$this->curl = $curl;
$this->bitcoin_core = $bitcoin_core;
if ($guid = Route::current()->getParameter('guid')) {
$this->user = $this->attemptAuth($guid);
$this->bitcoin_core->setRpcConnection($this->user->rpc_connection);
}
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$group = Route::current()->parameter('groups');
$user = Auth::user();
if ($user->id != $group->owner->id) {
flash()->error('Unauthorised Request');
return redirect()->action('UsersController@show', [$user->profile_link]);
}
return $next($request);
}
示例7: routeinfo
public static function routeinfo()
{
$route = Route::current();
if (preg_match("/\\//", $route->uri())) {
list($action) = explode('/', $route->uri());
} elseif ('/' === $route->uri()) {
$action = 'home';
} else {
$action = $route->uri();
}
return (object) ['action' => $action, 'params' => $route->parameters(), 'uri' => $route->uri()];
}
示例8: updateRole
private function updateRole(Request $request, User $user)
{
$validator = Validator::make($request->all(), ['role' => 'required']);
if ($validator->fails()) {
return redirect(route(Route::currentRouteName()))->withErrors($validator->errors());
} else {
$user->update($request->all());
Session::flash('success', "Le profil utilisateur a bien été mis à jour.");
}
if ($param = Route::current()->getParameter('id')) {
return redirect()->route(Route::currentRouteName(), $param);
}
return redirect()->route(Route::currentRouteName());
}
示例9: routeinfo
public static function routeinfo()
{
$route = Route::current();
if (preg_match("/conferences\\/\\{year\\?\\}\\/\\{conference\\?\\}/i", $route->uri()) && count($route->parameters()) > 0) {
$action = 'conference';
} elseif (preg_match("/\\/(.+)/", $route->uri())) {
list($action) = explode('/', $route->uri());
} elseif ('/' === $route->uri()) {
$action = 'home';
} else {
$action = $route->uri();
}
// dd((object)['action' => $action, 'params' => $route->parameters(), 'uri' => $route->uri()]);
return (object) ['action' => $action, 'params' => $route->parameters(), 'uri' => $route->uri()];
}
示例10: checkGroup
/**
* Checks if the user with the given ID is in the specified group
*
* @param string $userid Unique user ID
* @param string|array $groupcodes Unique user/customer group codes that are allowed
* @return boolean True if user is part of the group, false if not
*/
public function checkGroup($userid, $groupcodes)
{
$site = Route::current() ? Route::input('site', Input::get('site', 'default')) : 'default';
$context = $this->context->get(false);
$context->setLocale($this->locale->getBackend($context, $site));
$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/group');
$search = $manager->createSearch();
$search->setConditions($search->compare('==', 'customer.group.code', (array) $groupcodes));
$groupItems = $manager->searchItems($search);
$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists');
$search = $manager->createSearch();
$expr = array($search->compare('==', 'customer.lists.parentid', $userid), $search->compare('==', 'customer.lists.refid', array_keys($groupItems)), $search->compare('==', 'customer.lists.domain', 'customer/group'));
$search->setConditions($search->combine('&&', $expr));
$search->setSlice(0, 1);
return (bool) count($manager->searchItems($search));
}
示例11: currentType
/**
* Returns the current auth type set via route or the default value
*
* @return string
* @throws \Exception
*/
public function currentType()
{
if (Route::current()) {
$action = Route::current()->getAction();
if (isset($action['auth'])) {
$actionAuth = $action['auth'];
if (is_array($actionAuth)) {
return end($actionAuth);
}
return $actionAuth;
}
}
if ($this->app['config']['auth.default'] === null) {
throw new \Exception('No auth name given and no default setting for MultiAuth found!');
}
return $this->app['config']['auth.default'];
}
示例12: forget
/**
* 找回密码
* @param [type] $p3 找回密码类型 - employee , agency
* @return [type] [description]
*/
public function forget($p3 = null)
{
$email = rq('email');
$ins = Route::current()->parameter('p3');
$row = M($ins)->where('email', $email)->first();
if ($row) {
// 发送邮件
$hash = hash_password($row->email . time());
Mail::send('emails.reminder', ['user' => $row, 'hash' => $hash], function ($m) use($row) {
$m->to($row->email, $row->name)->subject('密码重置');
});
// 发送log
Event::fire(new LogEvent('reminder', 'auth', ['type' => $ins, 'user' => $row, 'hash' => $hash]));
return ss('邮件已发送');
} else {
return ss('无相关用户', 0);
}
}
示例13: __construct
/**
* Using service container in constructor to instantiate a class
*
* @param Article $article
*/
public function __construct(Article $article)
{
$this->article = $article;
$this->blog = AdminFunctionType::where('code', 'blog')->select('admin_function_type_id')->first();
$this->destinationPath = 'uploads';
if (Auth::user() != "") {
$this->user = Auth::user();
} else {
$this->route_parameter = Route::current()->parameters();
$this->user = User::findOrFail($this->route_parameter['user_id']);
}
$this->categories = $this->user->categories()->orderBy('name')->get();
$this->article_index_url = 'admin/article';
foreach ($this->categories as $category) {
$this->article_amount[$category->category_id] = $category->articles()->count();
$this->total += $category->articles()->count();
}
$this->article_amount['total'] = $this->total;
}
示例14: handle
/**
* Handle an incoming request.
* This Middleware checks the current user's Permissions array for $permission.
* If this user has the specified $permission, let them through.
* Otherwise, redirect to the main page.
*
* The optional 2nd argument determines whether or not to require that this user
* has the same crew_id as the page being requested.
* i.e. When $enforce_same_crew is TRUE, a user with crew_id=2 cannot access /crews/1/status
*
* NOTE
* Users with the 'global_admin' permission will ALWAYS be allowed through this middleware.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param String $permission
* @param String $enforce_same_crew
* @return mixed
*/
public function handle($request, Closure $next, $permission, $enforce_same_crew = false)
{
// Convert $enforce_same_crew from a string to a boolean
// The case-insensitive string "true" is converted to boolean TRUE.
// Any other string value is converted to boolean FALSE.
$enforce_same_crew = $enforce_same_crew === strtolower('true');
// Filter and redirect
if ($request->user()->isGlobalAdmin()) {
// Do not redirect - this user will be allowed through
} elseif (!$request->user()->hasPermission($permission)) {
// This user did not have the $permission string in his User.permissions array
return redirect()->back();
} elseif ($enforce_same_crew && Route::current()->getParameter('id') != $request->user()->crew_id) {
// This user's crew_id does not match the crew_id of the requested page (AND the $enforce_same_crew flag was set to TRUE)
return redirect()->back()->withErrors("You can't change data that belongs to a different crew");
}
// $request->session()->flash('perms',$permission); // Debugging output
return $next($request);
}
示例15: saveProduct
private function saveProduct(Request $request, Product $product)
{
$validator = Product::validate($request->all());
if ($validator->fails()) {
return redirect(route(Route::currentRouteName()))->withErrors($validator->errors());
} else {
if (!is_null($product->id)) {
$product->update($request->all());
Session::flash('success', "Le produit a bien été mis à jour.");
} else {
$product->fill($request->all());
$product->save();
Session::flash('success', "Le produit a bien été crée.");
}
}
if ($param = Route::current()->getParameter('id')) {
return redirect()->route(Route::currentRouteName(), $param);
}
return redirect()->route(Route::currentRouteName());
}