On what basics we give url and name in laravel route file

laravel route wildcard
laravel route parameters controller
laravel route name
laravel route::resource
laravel route middleware
laravel route redirect
laravel get current url
laravel route helper

You may find me stupid but i am unable to understand on what basics we give url and name in our route file


 Route::get('/order/getOrders', 'OrderController@getOrders')- 

can anyone please tell me. and if we take url on the basics of where our file in view folder like( order->getorder blade file)

Then what if my path is layouts.site.topbar

In view instead of pages, my file is in layouts.


blade file

          <a  href="{{ route('sync.index') }}">

                      @foreach ($syncs as $sync)
                      {{ $sync->session_date }}


controller file

class TopbarController extends Controller {

      public function index()
{ die('o');
   $syncNames = Sync::select('session_date','session_time')->where('user_id',$user_id)->get();

    return view('layouts.site.topbar', array(
            'syncs' =>$syncNames


public function sync_finish_session() {
    $user_id = Auth::id();
   $sync_date = date('M d ',strtotime("now"));
   $sync_time = date('M d, Y H:i:s',strtotime("now"));

     $sync = Sync::where('user_id',$user_id)->get();
         if(count( $sync) > 0) {

                else {

       $dates = new Sync();
       $dates->session_date = $sync_date;
       $dates->session_time = $sync_time;
       $dates->user_id = $user_id;

        return $sync;



web file

Route::post('/sync_finish_session', 'TopbarController@sync_finish_session')->name('sync_finish_session')->middleware('auth');

Route::get('/sync/index', 'TopbarController@index')->name('sync.index')->middleware('auth');

Now whats the problem its giving nothing even i put die but its not going in controller file.

I think this is more a personal preference thing than that there are rules.

The convention I use is name(<model>.<action>)

This way i can create routes like

Route::get('/users/{id}/view', 'UserController@view')->name('users.specific.view')->middleware('auth');

Laravel: How to Get Current Route Name? (v5 & v6), each route in the group with a given URI. Subdomain Routing; Route Prefixes; Route Name Prefixes; Route Model Binding. Implicit Binding; Explicit Binding; Fallback Routes; Rate Limiting; Form Method Spoofing; Accessing The Current Route; Cross-Origin Resource Sharing (CORS) Basic Routing. The most basic Laravel routes accept a URI and a Closure, providing a very simple and expressive method of defining routes:

You just name route as you do want. There is no strict rules how to name route. You can change name('order.getOrders') to name("anyName") and use new name in templates.

Named Routes in Laravel, Named routes allow the convenient generation of URLs or redirects for specific routes. You may specify a name for a route by chaining the name method onto the  Step 1 − Initially, we should execute the root URL of the application. Step 2 − Now, the executed URL should match with the appropriate method in the route.php file. In the present case, it should match the method and the root (‘/’) URL. This will execute the related function.

As the Laravel documentaton about rounting says:

Named routes allow the convenient generation of URLs or redirects for specific routes.

So, you can use this name to generate URLs or redirects. For example:

You could put this in your web.php file:

Route::get('/image/index', 'API\SettingsController@index')->name('image.index');

And call that route like this in your view:

<a href="{{ route('image.index') }}">Le met see that index!</a>

Where the {{ route('image.index') }} references the name you gave to it.

URL Generation - Laravel, Artisan Console · Broadcasting · Cache · Collections · Events · File Storage · Helpers · HTTP Client Introduction; The Basics Laravel provides several helpers to assist you in generating URLs for your application. Named routes allow you to generate URLs without being coupled to the actual URL defined on the route. Example 1: Basic Url To Routes. Laravel 6 provides a global route() function that gets the URL to a named route. The only one Parameter is the route name (string). it would look as routes/web.php file defines routes that are for your web interface: Route::get('home', 'HomeController@index')->name('home');

You can name your route(s) anything you want. If you wanted, you could call your above route "mySuperCoolRouteName":

Route::get('/order/getOrders', 'OrderController@getOrders')- 

and later in a view file you can use this name as a "shorthand" to get/print the URL of that route:

<a href="{{ route('mySuperCoolRouteName') }}">To My Cool Route</a>

will be rendered to

<a href="/order/getOrders">To My Cool Route</a>

Laravel 5 routing using prefix, Basic Routing. You will define most of the routes for your application in the app/​Http/routes.php file, which is loaded by the App\Providers\RouteServiceProvider​  To create a signed URL to a named route, use the signedRoute method of the URL facade: use Illuminate\Support\Facades\URL; return URL::signedRoute('unsubscribe', ['user' => 1]); If you would like to generate a temporary signed route URL that expires, you may use the temporarySignedRoute method:

Routing - Laravel, Named routes allow you to conveniently generate URLs or redirects for a specific routes.php file within a namespace group, allowing you to register controller  By default, the putFile method will generate a unique ID to serve as the file name. The file's extension will be determined by examining the file's MIME type. The path to the file will be returned by the putFile method so you can store the path, including the generated file name, in your database.

HTTP Routing - Laravel, You may do so by placing a ? mark after the parameter name. Make sure to give the route's corresponding variable a default value: Route::get('user/{name?} Sometime, we need to get route name for as per give on url. We can easily get route name two way using following facade: 1) Request: 2) Route: If you are getting route name in controller then "Request" facade will help to get route name. If you want to get route name in view file or anywhere then you can simply use "Route" facade.

The Basics Routing, Instead of defining all of your request handling logic in a single routes.php file, you You may also use the route helper to generate a URL to a named controller  Whenever you need to get current route name then you can get using Request or Route facade. I give you two example one for using Route facade and another for Request facade. so you can get route name both way and how you can see both example.

  • Actually name('order.getOrders') is not where you can put the path of view. It is kind of route variable which you can use inside view, js, html form etc
  • Not sure if I understand your question, but you can name your route anything you want. If you want, you can call your above route kerbholz (->name('kerbholz')) and later in a view file you can use this name as a "shorthand": {{ route('kerbholz') }} will print /order/getOrders.
  • ok i understand, now my problem is let me show you my code what i have made so far with the help of you comment.
  • i will be editing my code.
  • @kerbholz please answer my question.
  • ok @kerbholz, I did as you said but the problem is my view file is not going in controller file. I tried everything which is to my knowledge. You can see the code above as I edit my question.
  • See if running php artisan route:cache to clear and cache your routes file helps. You can also use php artisan route:list to list all of your routes to make sure your routes are there.
  • Also ... your @foreach won't show anything, move {{ $sync->session_date }} inside your @foreach
  • Yes @kerbholz its there both index and second one both in the list and I also cleared the cache but same result
  • And that index() function is inside your TopbarController? (Just making sure, you used a different controller in your original question). And you're on /sync/index on your server? Take a look at your Laravel log /storage/logs/laravel.log and see if there are any errors/warnings