#How to route a view.

45 messages · Page 1 of 1 (latest)

calm radish
#
   return view(‘pageName’);
})```
thick locust
#

@calm radish that hasn't changed anything - still 404.

calm radish
#

Must not have found the file then

#

Make sure you have the file in the views folder

thick locust
#

Could it be to do with the whole blade thing?

#

Should I try using the path?

calm radish
#

When using view it looks inside the views folder in your project directory

static stump
#

I think there is a prefix defination in the RouteProvider, and Could you provide the error URL without hosts ?

calm radish
#

So if you have a page named pageName.blade.php it will look for a file named pageName.blade.php

static stump
#

I have tried the code you provided, it is working well.

#

Of course you can run the shell under your Laravel project dir

php artisan route:list | grep hourly

and find the route you wrote. I think it would be helpful for you.

thick locust
#

I think there is potentially something interfering.

#

There is a resource line above

calm radish
#

Show code….

thick locust
#

Would that influence?

static stump
#

show me the code ..

thick locust
#

Ah

#

It is okay

#

I figured it

#

The resource changes the route beginning.

#

I believe.

static stump
#

Do you mean there is a route conflict in your routes? like

Route::resource('one',...);
Route::view('/one/hourly', 'one.hourly');
thick locust
#

Yes

#

But I moved it above the resource

#

I need to name the route

static stump
#

I think you should not do this.

thick locust
#

Oh

#

What do I do instead?

#

I could add the route to the middleware?

static stump
#

Could you let me know if this resource has a details api, or could you change the new route path to another path?

thick locust
#

I need it on the same path

calm radish
#

@thick locust if you need help. Send us the code in your route file you wish to fix

#

We don’t have telepathy

thick locust
#

@calm radish there was an issue with the Route::resource and the Route::get but I just moved the get above the resource and it works.

#

Jacky Chen is saying that is bad practice, what should I do instead?

calm radish
#

Show me the code

thick locust
#

Do I need to move the route to the middleware?

static stump
#

could you let me know is there a scene that two routes are same routes; like following codes:

Route::get('/one/hourly',.....);
Route::resource('/one',....);// but the resource_id in the route '/one/{resource_id}'  is as same sa 'hourly'?

calm radish
#

There is likely a conflict between your custom route and the resource route. But we can’t help sufficiently if we don’t see the code…. 🤦‍♂️

thick locust
#

@static stump All that is left is to name the route.
I did this, but now all my app renders is the name of the view path.

Route::get('one/hourly', function(){
    return view('module.one.hourly');
})->name('one.hourly');```
#

I am stupid.

#

I fixed.

worthy hearth
#

what is issue ?