chinleung / laravel-multilingual-routes

A package to handle multilingual routes in your Laravel application.
https://github.com/chinleung/laravel-multilingual-routes-demo
MIT License
395 stars 25 forks source link

Prefixed route results in 404 #50

Closed MarcelWeidum closed 3 years ago

MarcelWeidum commented 3 years ago

Describe the bug

When I group a route and prefix it, it throws a 404.

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'routes/web.php'
  2. Make a grouped route
  3. Make a child route in the grouped route
  4. Navigate to child route
  5. See error

Expected behavior

Run controller method.

Result of route:list:

+--------+----------+----------------------------------+-----------------------+------------------------------------------------------+---------------+
| Domain | Method   | URI                              | Name                  | Action                                               | Middleware    |
+--------+----------+----------------------------------+-----------------------+------------------------------------------------------+---------------+
|        | GET|HEAD | /                                |                       | Closure                                              | web           |
|        | GET|HEAD | api/user                         |                       | Closure                                              | api           |
|        |          |                                  |                       |                                                      | auth:api      |
|        | GET|HEAD | blog/                            | en.blog.index         | App\Http\Controllers\BlogController@index            | web           |
|        | GET|HEAD | blog/create                      | en.blog.create        | App\Http\Controllers\BlogController@create           | web           |
|        | GET|HEAD | blog/edit/{post}                 | en.blog.edit          | App\Http\Controllers\BlogController@edit             | web           |
|        | GET|HEAD | blog/show/{post}                 | en.blog.show          | App\Http\Controllers\BlogController@show             | web           |
|        | GET|HEAD | livewire/livewire.js             |                       | Livewire\Controllers\LivewireJavaScriptAssets@source |               |
|        | GET|HEAD | livewire/livewire.js.map         |                       | Livewire\Controllers\LivewireJavaScriptAssets@maps   |               |
|        | POST     | livewire/message/{name}          | livewire.message      | Livewire\Controllers\HttpConnectionHandler           | web           |
|        | GET|HEAD | livewire/preview-file/{filename} | livewire.preview-file | Livewire\Controllers\FilePreviewHandler@handle       | web           |
|        | POST     | livewire/upload-file             | livewire.upload-file  | Livewire\Controllers\FileUploadHandler@handle        | web           |
|        |          |                                  |                       |                                                      | throttle:60,1 |
+--------+----------+----------------------------------+-----------------------+------------------------------------------------------+---------------+

My routes/web.php:

<?php

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});

Route::group(['prefix' => 'blog'], function () {
    $c = App\Http\Controllers\BlogController::class;

    Route::multilingual('/', [$c, 'index'])->name('blog.index');
    Route::multilingual('/create', [$c, 'create'])->name('blog.create');
    Route::multilingual('/edit/{post}', [$c, 'edit'])->name('blog.edit');
    Route::multilingual('/show/{post}', [$c, 'show'])->name('blog.show');
});

If I navigate to /blog it throws a 404. And if I change the child route to get it works:

Route::get('/', [$c, 'index'])->name('blog.index');
chinleung commented 3 years ago

@MarcelWeidum Just wanted to let you know that I've been able to reproduce the error. I'll be having a look on what's causing this and publish a fix.

MarcelWeidum commented 3 years ago

@chinleung great thank you 🤩

AbdullahFaqeir commented 3 years ago

Is this issue still presented?

MarcelWeidum commented 3 years ago

@AbdullahFaqeir yes, never fixed

AbdullahFaqeir commented 3 years ago

If the package maintainer can check my PR the soonest, I'd submit a PR fixing this within 2-3 hours.

chinleung commented 3 years ago

@MarcelWeidum Sorry, I totally forgot about this issue!

@AbdullahFaqeir Can you please submit a pull request? I'll review it right after.

AbdullahFaqeir commented 3 years ago

Hello @chinleung,

Sure I will, I'm currently working on another PR, I'll instantly move to it once I submit the PR I'm working on it, I need like 2 hours.

chinleung commented 3 years ago

@MarcelWeidum This is fixed in v2.7.5. 😄

AbdullahFaqeir commented 3 years ago

@chinleung can you please add hacktoberfest to the topics of the repo?

chinleung commented 3 years ago

@chinleung can you please add hacktoberfest to the topics of the repo?

Hey @AbdullahFaqeir! I've added the topic. :)

AbdullahFaqeir commented 3 years ago

@chinleung can you please add hacktoberfest to the topics of the repo?

Hey @AbdullahFaqeir! I've added the topic. :)

Thanks a lot <3

AbdullahFaqeir commented 3 years ago

@chinleung can you please add hacktoberfest to the topics of the repo?

Hey @AbdullahFaqeir! I've added the topic. :)

Hey, I'm really sorry for the disturb ^^', but there's a typo in the repo's topic, it's "hacktoberfest" not "hactoberfest", there's a missing k hahahah

chinleung commented 3 years ago

Hey, I'm really sorry for the disturb ^^', but there's a typo in the repo's topic, it's "hacktoberfest" not "hactoberfest", there's a missing k hahahah

Oops, I've corrected it now. Sorry, added it from my mobile phone. 😅