title: Laravel go-back dynamic button?
body: <p>I want to implement a dynamic way of the go-back button in my Laravel project.</p>
  <p>So I have this button:</p>
  <pre><code>&lt;a href=&quot;WHAT TO DO HERE&quot;&gt;
      &lt;div class=&quot;go-back&quot;&gt;
          &lt;div class=&quot;go-back-inside&quot;&gt;
              &lt;h6 class=&quot;text&quot;&gt;Go Back&lt;/h6&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/a&gt;
  </code></pre>
  <p>Which I have included on every page, what I want to do is to have one button that is included in all pages, and for instance, if I am on <code>bentley-flying-spur</code> and click on back I want to go to the prefix's base route (/) [services/cars/], or if I am on <code>riva</code> and click on the go-back-button to go to the base route (/) [services/yacht/];</p>
  <p>The same button is included in both <code>bentley-flying-spur</code> and <code>riva</code> how can it dynamically go to the route group's (/)</p>
  <pre><code>Route::prefix('services')-&gt;group(function () {
  
      Route::get('/', function () {
          return view('web.services');
      });
      Route::prefix('cars')-&gt;group(function () {
          Route::get('/', function () {
              return view('web.modules.cars.products');
          });
          Route::get('/bentley-flying-spur', function () {
              return view('web.modules.cars.models.bentley-flying-spur');
          });
      });
      Route::prefix('yacht')-&gt;group(function () {
          Route::get('/', function () {
              return view('web.modules.riva.products');
          });
          Route::get('/riva', function () {
              return view('web.modules.riva.models.riva');
          });
      });
  }):
  </code></pre>
  <p><strong>DYNAMIC ROUTES</strong></p>
  <pre><code>Route::get('/', 'MainController@index');
  Route::get('/services', 'MainController@services');
  Route::get('/services/{service}', 'MainController@service');
  Route::get('/services/{service}/{product}', 'MainController@product');
  </code></pre>