如何在我的视图中引用Laravel路由,这样如果我更改路由,我将不必更新所有视图?

Consider the following simple example:

// routes.php 

  // You can get this route by http://localhost/adminpanel/home ...users...etc
  Route::group(array('prefix' => 'adminpanel', 'before' => 'auth'), function(){
      Route::resource('home', 'Admin\Controllers\HomeController');
      Route::resource('users', 'Admin\Controllers\UsersController');
  });


// Admin\Views\users.php
  <!-- I do not want to update this everytime I change the route -->
  <a href="<?=URL::to('adminpanel/home');?>">Click here to go home</a>

If I change adminpanel to something else in my routes.php I will also have to change every View that used it.

Is there another way I can reference the route in my Views or is there any other good strategy I can implement from Laravel naturally?
Otherwise I'm thinking I might need to add some sort of CONSTANT variable to my global.php to possibly accomplish this.

Use the route 'as' parameter to give a name to your route:

Route::get('user/profile', array('as' => 'profile', 'uses' => 'UserController@showProfile'));

Then you just have to

<a href="<?=URL::route('profile');?>">Click here to go home</a>

Using your resource routes, you can list them

php artisan routes

And use the name of the route, third column.

Using your example, you'll have 2 base routes: home and users, this is the list for the home resources:

+--------+----------------------+--------------+------------------------------------------+----------------+---------------+
| Domain | URI                  | Name         | Action                                   | Before Filters | After Filters |
+--------+----------------------+--------------+------------------------------------------+----------------+---------------+
|        | GET home             | home.index   | Admin\Controllers\HomeController@index   |                |               |
|        | GET home/create      | home.create  | Admin\Controllers\HomeController@create  |                |               |
|        | POST home            | home.store   | Admin\Controllers\HomeController@store   |                |               |
|        | GET home/{home}      | home.show    | Admin\Controllers\HomeController@show    |                |               |
|        | GET home/{home}/edit | home.edit    | Admin\Controllers\HomeController@edit    |                |               |
|        | PUT home/{home}      | home.update  | Admin\Controllers\HomeController@update  |                |               |
|        | PATCH home/{home}    |              | Admin\Controllers\HomeController@update  |                |               |
|        | DELETE home/{home}   | home.destroy | Admin\Controllers\HomeController@destroy |                |               |
+--------+----------------------+--------------+------------------------------------------+----------------+---------------+

So you'll build that route using:

<a href="<?=URL::route('home.index');?>">Click here to go home</a>

Note that the your group prefix adminpanel won't be added to your routes names and you don't have to use it. What you need to create your routes is the exact name the command artisan routes shows in Name column.

Using Blade you can just do

{{ link_to_route('home.index', 'Click here to go home') }}

Much cleaner, right?

The best solution for your problem would be to use named routes like Antonio suggested. You could also use the link_to_route helper to generate a full HTML link to the named route.

More information about url helpers can be found here: http://laravel.com/docs/helpers#urls

More information about named routes can be found here: http://laravel.com/docs/routing#named-routes