本文整理汇总了PHP中Illuminate\Support\Facades\Route类的典型用法代码示例。如果您正苦于以下问题:PHP Route类的具体用法?PHP Route怎么用?PHP Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Route类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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';
});
}
}
示例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"]);
}
示例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;
}
示例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');
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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('/');
}
});
}
示例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'));
}
示例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);
});
}
}
示例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());
}
示例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);
}
示例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);
}