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?

Hoolis
  • 47
  • 6
  • 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? – Hoolis Jul 23 '22 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. – Hoolis Jul 23 '22 at 13:09

1 Answers1

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.

Hoolis
  • 47
  • 6