0

I have a weird situation, where my route seems to be not defined.

I am using Laravel's starter kit Breeze, and I am adding top left navigational links. This is my 4th link already, but it seems that It's the first time I face such issue.

Controller:

public function index(Request $request)
    {
        $user = $request->user();
        $data = $user->campaigns;
        return view('subscribes.index', ['data' => $data]);
    }

Route:

Route::resource('/my_campaigns', App\Http\Controllers\SubscribeController::class);

Navigational link code:

 <div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex">
                    <x-nav-link :href="route('subscribes.index')" :active="request()->routeIs('subscribes.index')">
                        {{ __('My Campaigns') }}
                    </x-nav-link>
                </div>

Error message:

Route [subscribes.index] not defined.

I have spent 2 hours trying to check every single spot, where the issue may lay, but to no avail. I have already cleared route:cache.

I'd like to note, that the page /my_campaigns opens without any issues, and is working, until I try to add it within the navigational links.

My folders and files seems to be created correct as well, due to the fact, that /my_campaigns is working.

Any idea, where I missed something?

2
  • I have now adjusted my route, and given it a name - ->name('myCampaigns'); After that, I receive an error Too few arguments to function Illuminate\Routing\PendingResourceRegistration::name(). Is it due to the fact, that my index controller has Request $request? Commented Jul 23, 2022 at 12:58
  • Nvm, fixed the error mentioned in the comment above, it was due to the name, searching for other methods. But after that fix, we are back to the same original error. Commented Jul 23, 2022 at 13:09

1 Answer 1

0

The issue was within my navigational link code. Where the href route is defined, I have used incorrect URL, therefore, this issue was caused.

Sign up to request clarification or add additional context in comments.

2 Comments

Please accept this answer so that we would know that this question is solved. Thanks!
I can’t accept my own answer, till it becomes 2 days old @SimasJoneliunas

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.