本文整理汇总了PHP中Illuminate\Support\Facades\Route类的典型用法代码示例。如果您正苦于以下问题:PHP Route类的具体用法?PHP Route怎么用?PHP Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Route类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: initializationModule
public function initializationModule()
{
$this->modulePath = app_path('Modules/' . $this->moduleName);
//Config
if (file_exists($this->modulePath . '/config.php')) {
$this->mergeConfigFrom($this->modulePath . '/config.php', 'module' . $this->moduleName);
}
//Language
if (is_dir($this->modulePath . '/Languages')) {
$this->app->language->load($this->moduleName);
}
//Helper
if (file_exists($this->modulePath . '/helpers.php')) {
require $this->modulePath . '/helpers.php';
}
//View
if (is_dir($this->modulePath . '/Views')) {
$this->loadViewsFrom($this->modulePath . '/Views', $this->moduleName);
}
//Hook View
if (isset($this->hookView)) {
foreach ($this->hookView as $key => $value) {
$this->app->config->set('hooks.' . $key, $value);
}
}
//Widget
if (isset($this->widget)) {
foreach ($this->widget as $key => $value) {
$this->app->widget->register($key, $value);
}
}
//Cast
if (isset($this->castPost)) {
foreach ($this->castPost as $key => $value) {
$this->app->config->set('site.cast.post.' . $key, $value);
}
}
if (isset($this->castCategory)) {
foreach ($this->castCategory as $key => $value) {
$this->app->config->set('site.cast.category.' . $key, $value);
}
}
//Permissions
if (isset($this->permissions)) {
foreach ($this->permissions as $key => $value) {
$this->app->config->set('site.permissions.' . $key, $value);
}
}
//Route
if (file_exists($this->modulePath . '/Routes/web.php')) {
Route::group(['middleware' => 'web', 'namespace' => 'App\\Modules\\' . $this->moduleName . '\\Controllers'], function ($router) {
require $this->modulePath . '/Routes/web.php';
});
}
if (file_exists($this->modulePath . '/Routes/api.php')) {
Route::group(['middleware' => 'api', 'namespace' => $this->namespace, 'prefix' => 'api'], function ($router) {
require $this->modulePath . '/Routes/api.php';
});
}
}
开发者ID:vnsource,项目名称:core,代码行数:60,代码来源:ServiceProviderTrait.php
示例2: _routes_status
public static function _routes_status()
{
$_class = get_called_class();
$_uri = static::$uri;
$_as = static::$action;
Route::post("{$_uri}/status/change", ['as' => "{$_as}.edit.status", 'uses' => "{$_class}@change_status"]);
}
开发者ID:xjtuwangke,项目名称:laravel-cms,代码行数:7,代码来源:CMSStatusTrait.php
示例3: loadPageTitle
private function loadPageTitle()
{
$pageTitles = config('forone.nav_titles');
$curRouteName = Route::currentRouteName();
if (array_key_exists($curRouteName, $pageTitles)) {
return $pageTitles[$curRouteName];
} else {
// load menus title
$url = URL::current();
$menus = config('forone.menus');
foreach ($menus as $title => $menu) {
if (array_key_exists('children', $menu) && $menu['children']) {
foreach ($menu['children'] as $childTitle => $child) {
$pageTitle = $this->parseTitle($childTitle, $url, $child['active_uri']);
if ($pageTitle) {
return $pageTitle;
}
}
} else {
$pageTitle = $this->parseTitle($title, $url, $menu['active_uri']);
if ($pageTitle) {
return $pageTitle;
}
}
}
}
return $curRouteName;
}
开发者ID:Mrzhanglu,项目名称:ForoneAdmin,代码行数:28,代码来源:BaseController.php
示例4: boot
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->package('mmanos/laravel-image');
if ($route = Config::get('laravel-image::route')) {
Route::get($route, 'Mmanos\\Image\\ImagesController@getIndex');
}
}
开发者ID:mmanos,项目名称:laravel-image,代码行数:12,代码来源:ImageServiceProvider.php
示例5: track
/**
* Track clicked links and form submissions.
*
* @param Request $request
* @return void
*/
public function track(Request $request)
{
// Don't track if there is no active experiment.
if (!$this->session->get('experiment')) {
return;
}
// Since there is an ongoing experiment, increase the pageviews.
// This will only be incremented once during the whole experiment.
$this->pageview();
// Check current and previous urls.
$root = $request->root();
$from = ltrim(str_replace($root, '', $request->headers->get('referer')), '/');
$to = ltrim(str_replace($root, '', $request->getPathInfo()), '/');
// Don't track refreshes.
if ($from == $to) {
return;
}
// Because the visitor is viewing a new page, trigger engagement.
// This will only be incremented once during the whole experiment.
$this->interact();
$goals = $this->getGoals();
// Detect goal completion based on the current url.
if (in_array($to, $goals) or in_array('/' . $to, $goals)) {
$this->complete($to);
}
// Detect goal completion based on the current route name.
if ($route = Route::currentRouteName() and in_array($route, $goals)) {
$this->complete($route);
}
}
开发者ID:Raphael-C-Almeida,项目名称:laravel-5-ab,代码行数:36,代码来源:Tester.php
示例6: index
public function index()
{
$urls = [];
$routes = Route::getRoutes();
foreach ($routes as $route) {
$path = $route->getPath();
$actions = $route->getAction();
$params = $route->parameterNames();
$controller = $actions['controller'];
if (starts_with($path, '_') or str_contains($controller, 'RedirectController') or count($params)) {
continue;
}
$urls[] = url($path);
}
foreach (Campus::all() as $item) {
$urls[] = url($item->url);
}
foreach (Event::all() as $item) {
$urls[] = url($item->url);
}
foreach (Series::withDrafts()->get() as $item) {
$urls[] = url($item->url);
}
foreach (Staff::all() as $item) {
$urls[] = url($item->url);
}
foreach (MissionLocation::all() as $item) {
$urls[] = url($item->url);
}
foreach (Video::withDrafts()->get() as $item) {
$urls[] = url($item->url);
}
return response()->json($urls);
}
开发者ID:mcculley1108,项目名称:faithpromise.org,代码行数:34,代码来源:SiteMapController.php
示例7: compose
/**
* 将数据绑定到视图。
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
//查询当前登录用户
$admin = Auth::guard('admin')->user();
if ($admin->admin_name == 'admin') {
$menus = Menu::orderBy('sort', 'ASC')->get()->toTree();
} else {
if ($admin->role) {
$ids = DB::table('sys_role_function')->where('sys_role_id', $admin->role[0]->id)->pluck('sys_fun_id');
$menus = Menu::orderBy('sort', 'ASC')->whereIn('id', $ids)->get()->toTree();
}
}
$currentRoute = Route::currentRouteName();
$list = explode('.', $currentRoute);
$route = '';
for ($i = 0; $i < count($list) - 1; $i++) {
if ($i == 0) {
$route .= $list[$i];
} else {
$route .= '.' . $list[$i];
}
}
$route = $route . '.index';
$view->with('currentRoute', $route)->with('trees', $menus);
}
开发者ID:nutsdo,项目名称:nong-store,代码行数:31,代码来源:CommonComposer.php
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($user = $request->user()) {
//判断是不是管理员
$userRoles = Role::all();
foreach ($userRoles as $r) {
$roles[] = $r->name;
}
if (!$user->hasRole($roles)) {
redirect()->guest('auth/login');
}
//创始人拥有所有权限
if (!$user->hasRole('Founder')) {
$can = Route::currentRouteName();
//当前routeName exp:user.test
$res = $request->user()->can($can);
if (!$res) {
return view('admin.noaccess');
}
}
} else {
return redirect()->guest('auth/login');
}
return $next($request);
}
开发者ID:nutsdo,项目名称:mz-service,代码行数:32,代码来源:AccessControl.php
示例9: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
try {
$inputs = array('des_name', 'des_coors', 'des_instruction', 'related_photos');
$obj = array('message' => 'succeeded');
foreach ($inputs as $field) {
$obj[$field] = $request->input($field, '');
}
// TODO: cuối cùng vẫn phải chạy Raw SQL -_-
$destination = DB::table('Destination')->insertGetId(array('des_name' => $obj['des_name'], 'des_instruction' => $obj['des_instruction'], 'coordinate' => DB::raw("GeomFromText(\"POINT(" . $obj['des_coors']['latitude'] . " " . $obj['des_coors']['longitude'] . ")\")")));
// upload selected images too
$images_uploaded = array();
$relPhotos = $obj['related_photos'];
if ($relPhotos) {
foreach ($relPhotos as $photo) {
if ($photo['selected']) {
$rq = Request::create("/admin/destination/{$destination}/photo", "POST", [], [], [], [], array('photo_url' => $photo['url'], 'photo_like' => rand(0, 100)));
array_push($images_uploaded, Route::dispatch($rq)->getContent());
}
}
}
return response()->json(array('addedObject' => Destination::find($destination), 'addedPhotos' => $images_uploaded));
} catch (\Exception $e) {
return response()->json($e);
}
}
开发者ID:hungphongbk,项目名称:ulibi,代码行数:32,代码来源:DestinationController.php
示例10: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
parent::boot($router);
Route::filter('admin', function () {
if (Auth::guest()) {
if (Request::ajax()) {
return Response::make('Unauthorized', 401);
} else {
return redirect('/login');
}
}
if (Auth::user()->level !== 10) {
return redirect('/');
}
});
Route::filter('muhtar', function () {
if (Auth::guest()) {
if (Request::ajax()) {
return Response::make('Unauthorized', 401);
} else {
return redirect('/login');
}
}
if (Auth::user()->level !== 5) {
return redirect('/');
}
});
}
开发者ID:istatease-dev,项目名称:api,代码行数:34,代码来源:RouteServiceProvider.php
示例11: compose
public function compose(View $view)
{
$documentForm = \Request::only('responsable_id');
$route = Route::currentRouteName();
$users = User::orderBy('name', 'ASC')->lists('name', 'id')->toArray();
$view->with(compact('documentForm', 'users', 'route'));
}
开发者ID:aguila302,项目名称:oficios,代码行数:7,代码来源:LoadUsers.php
示例12: boot
public function boot()
{
$this->package('mrosati84/laradmin');
$prefix = Config::get('laradmin::prefix');
$namespace = Config::get('laradmin::namespace');
$entities = Config::get('laradmin::entities');
foreach ($entities as $entity => $properties) {
$fullClassName = $namespace . '\\' . $entity . 'Admin';
$baseAdminController = 'Mrosati84\\Laradmin\\BaseAdminController';
// register admin classes bindings
App::bind($fullClassName, function () use($fullClassName, $entity) {
return new $fullClassName($entity);
});
// register custom filters classes
App::bind('AuthenticationFilter', 'Mrosati84\\Laradmin\\Filters\\AuthenticationFilter');
// register custom route filters
Route::filter('laradmin.auth', 'AuthenticationFilter');
// register laradmin index route (just a redirect to default entity)
Route::get($prefix, array('as' => 'laradmin.index', function () use($prefix) {
return Redirect::route($prefix . '.' . strtolower(Config::get('laradmin::defaultEntity')) . '.index');
}));
// register entities routes
Route::group(array('prefix' => $prefix, 'before' => 'laradmin.auth'), function () use($entity, $fullClassName) {
Route::resource(strtolower($entity), $fullClassName);
});
}
}
开发者ID:mrosati84,项目名称:laradmin,代码行数:27,代码来源:LaradminServiceProvider.php
示例13:
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());
}
开发者ID:KritaMaharjan,项目名称:expert,代码行数:7,代码来源:BaseController.php
示例14: 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);
}
开发者ID:evanhsu,项目名称:rescuecircle,代码行数:17,代码来源:CapitalizeTailnumber.php
示例15: __construct
public function __construct()
{
//$this->beforeFilter(function(){ });
$this->uriSegment = null;
$this->modelName = null;
$this->viewsPath = null;
$this->resourceId = null;
if (Route::input('alias') !== null) {
$this->uriSegment = Route::input('alias');
$this->viewsPath = File::exists(app_path('views/' . Config::get('reactiveadmin::uri') . '/' . $this->uriSegment)) ? Config::get('reactiveadmin::uri') . '.' . $this->uriSegment : 'reactiveadmin::default';
$this->modelName = studly_case(str_singular(Route::input('alias')));
$this->modelWrapper = App::make('model_wrapper');
$this->modelWrapper->model($this->modelName);
if (Route::input('id') !== null) {
$this->resourceId = Route::input('id');
}
View::share('config', $this->modelWrapper->getConfig());
// TODO: refactor this!
// custom behavior
switch ($this->uriSegment) {
case 'settings':
View::composer(array('admin.' . $this->viewsPath . '.index'), function ($view) {
$view->with('settings', Settings::all());
});
break;
default:
# code...
break;
}
}
View::share('view', $this->uriSegment);
View::share('model', $this->modelName);
}
开发者ID:verticalhorizon,项目名称:reactiveadmin,代码行数:33,代码来源:AdminController.php
示例16: mapAuthRoutes
protected function mapAuthRoutes()
{
Route::group(['middleware' => 'web', 'namespace' => $this->namespace], function ($router) {
Route::auth();
Route::get('/logout', 'Auth\\LoginController@logout');
});
}
开发者ID:abalozz,项目名称:glaciar,代码行数:7,代码来源:RouteServiceProvider.php
示例17: decorate
/**
* Add the extra logic needed to finalize the config array before using it.
*
* @param $config
*
* @return mixed
*/
public function decorate($config)
{
if (Route::is('role.user.index')) {
unset($config['user.roles']);
}
return array_values($config);
}
开发者ID:arminsam,项目名称:SimpleUserManagement,代码行数:14,代码来源:UserDataTable.php
示例18: 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;
}
开发者ID:volicon,项目名称:laravel-acl-rbac,代码行数:25,代码来源:AclRoute.php
示例19: _routes_show
public static function _routes_show()
{
$_class = get_called_class();
$_uri = static::$uri;
$_as = static::$action;
Route::get("{$_uri}/show/{id}", ['as' => "{$_as}.show.detail", 'uses' => "{$_class}@show"]);
}
开发者ID:xjtuwangke,项目名称:laravel-cms,代码行数:7,代码来源:CMSDetailTrait.php
示例20: test
public function test(Request $request)
{
// $user = User::find(1);
//
// if($user->hasRole('Founder')){
// return '您是创始人'.'ID:'.$user->id;
// };
if ($request->user()) {
// $userRoles = $request->user()->roles()->get();
// foreach($userRoles as $r){
// $roles[] = $r->name;
// }
// var_dump($roles);
$userRoles = Role::all();
foreach ($userRoles as $r) {
$roles[] = $r->name;
}
if (!$request->user()->hasRole($roles)) {
return redirect()->guest('auth/login');
}
//$can = Route::currentRouteName();//当前route-name exp:user.test
$can = Route::currentRouteAction();
echo $can;
$res = $request->user()->can($can);
echo $res;
}
}
开发者ID:nutsdo,项目名称:rp-wechat,代码行数:27,代码来源:UserController.php
注:本文中的Illuminate\Support\Facades\Route类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论