Laravel 2021-02-16 19:51

|
DesolatorMagno 2021-02-16 19:51:52
route(‘__index’)
why show me a route named ‘Home’ but them show a link for a route named ‘__index’ ?
amir_0787 2021-02-16 19:52:04
if you have “code with me” plugin i could understand better what should i do
amir_0787 2021-02-16 19:53:07
in html code for example i want to refer a worl(sitename) to a link
DesolatorMagno 2021-02-16 19:53:45
Show printscreen of what you have tried.
stealthSnake 2021-02-16 19:54:32
amir_0787 2021-02-16 19:47:06
<a href=”{{route( __index )}}”>Home</a>

When using route() function, you must put the name of the Route class from you routes file (web.php or routes.php)

Example if the name of the route is home

{{ route(‘home’)}}

In your routes file

Route::get(‘url/to/home’, ‘HomeController@index’)->name(‘home’);

amir_0787 2021-02-16 19:56:06
DesolatorMagno 2021-02-16 19:53:45
Show printscreen of what you have tried.

laravel_discuss-70408.jpg

amir_0787 2021-02-16 19:56:34
laravel_discuss-70409.jpg

DesolatorMagno 2021-02-16 19:56:35
No no, not a photo, a screenshoot, or use a service like pastebin.
amir_0787 2021-02-16 19:57:52
DesolatorMagno 2021-02-16 19:56:35
No no, not a photo, a screenshoot, or use a service like pastebin.

laravel_discuss-70412.jpg

stealthSnake 2021-02-16 19:58:00
amir_0787 2021-02-16 19:56:34

When using route() function, you must put the name of the Route class from you routes file (web.php or routes.php)

Example if the name of the route is home

{{ route(‘home’)}}

In your routes file

Route::get(‘url/to/home’, ‘HomeController@index’)->name(‘home’);

natghi2010 2021-02-16 19:58:44
amir_0787 2021-02-16 19:57:52

sir, your images will not be displayed for a second layer route

natghi2010 2021-02-16 19:59:00
yourroute.com/routelvl1/routelvl2
DesolatorMagno 2021-02-16 19:59:21
Why don’t you try a video tutorial or reading the official documentation, you need to get some theory before you try to practice.
amir_0787 2021-02-16 20:01:45
DesolatorMagno 2021-02-16 19:59:21
Why don’t you try a video tutorial or reading the official documentation, you need to get some theory before you try to practice.

i am trying to publish a website as i am watching a video course
but i see diffrent error in my project!

thanks a lot
i try more

stealthSnake 2021-02-16 20:02:06
amir_0787 2021-02-16 19:56:06

Use asset() function when using an assets in blade template. Make sure you assets is in public folder of your laravel project.

laravel_project/public/path_to_assets

Example you have folder of assets named front. Put it in the public folder and in your blade template, you can access it as

{{ asset(‘front/path_to_assets’) }}

amir_0787 2021-02-16 20:02:21
stealthSnake 2021-02-16 19:58:00
When using route() function, you must put the name of the Route class from you routes file (web.php or routes.php)

Example if the name of the route is home

{{ route(‘home’)}}

In your routes file

Route::get(‘url/to/home’, ‘HomeController@index’)->name(‘home’);

i did it too but the same error appears:
Route [home] not defined. (View: C:xampphtdocsdigilararesourcesviewsfrontmenu.blade.php)

DesolatorMagno 2021-02-16 20:03:09
home !== Home
stealthSnake 2021-02-16 20:04:13
amir_0787 2021-02-16 20:02:21
i did it too but the same error appears:
Route [home] not defined. (View: C:xampphtdocsdigilararesourcesviewsfrontmenu.blade.php)

Screenshot your routes file. (web.php)

amir_0787 2021-02-16 20:04:19
stealthSnake 2021-02-16 20:02:06
Use asset() function when using an assets in blade template. Make sure you assets is in public folder of your laravel project.

laravel_project/public/path_to_assets

Example you have folder of assets named front. Put it in the public folder and in your blade template, you can access it as

{{ asset(‘front/path_to_assets’) }}

thanks
my second problem is to use assets
i will correct it after solving route problem
thanks a lot

amir_0787 2021-02-16 20:05:11
stealthSnake 2021-02-16 20:04:13
Screenshot your routes file. (web.php)

laravel_discuss-70423.jpg

DesolatorMagno 2021-02-16 20:05:36
A problem is not what i would call it, you need to go back and read more documentation, you are shooting in the dark, waiting to get it right eventually.
amir_0787 2021-02-16 20:05:44
DesolatorMagno 2021-02-16 20:03:09
home !== Home

i know it
no misspelling happend

amir_0787 2021-02-16 20:06:02
DesolatorMagno 2021-02-16 20:05:36
A problem is not what i would call it, you need to go back and read more documentation, you are shooting in the dark, waiting to get it right eventually.

sure

DesolatorMagno 2021-02-16 20:06:29
you used __index at first, so any theory is believable now.
stealthSnake 2021-02-16 20:09:16
amir_0787 2021-02-16 20:02:21
i did it too but the same error appears:
Route [home] not defined. (View: C:xampphtdocsdigilararesourcesviewsfrontmenu.blade.php)

You have named the routes correctly in your routes file. You will not have an issue when calling
{{ route (‘home’) }}

amir_0787 2021-02-16 20:09:52
stealthSnake 2021-02-16 20:09:16
You have named the routes correctly in your routes file. You will not have an issue when calling
{{ route (‘home’) }}

that it why i am confused my bro!!

amir_0787 2021-02-16 20:10:04
i use laravel 8
amir_0787 2021-02-16 20:10:26
every thing is done but fails at the end
amir_0787 2021-02-16 20:11:10
stealthSnake 2021-02-16 20:09:16
You have named the routes correctly in your routes file. You will not have an issue when calling
{{ route (‘home’) }}

is it wrong?

<a href=”{{route( ‘__index’ )}}”>Home</a>

stealthSnake 2021-02-16 20:12:59
amir_0787 2021-02-16 20:11:10
is it wrong?

<a href=”{{route( ‘__index’ )}}”>Home</a>

Yeah, its wrong. You don’t have route named __index in your routes file.

stealthSnake 2021-02-16 20:13:33
laravel_discuss-70434.jpg

amir_0787 2021-02-16 20:15:00
sorry i ment ‘home’
amir_0787 2021-02-16 20:16:23
yes i corrected ‘index’ to ‘home’ in html code
but the old error:
Route [__home] not defined. (View: C:xampphtdocsdigilararesourcesviewsfrontmenu.blade.php)
stealthSnake 2021-02-16 20:16:42
laravel_discuss-70437.jpg
If error still persist. Stop your server and enter all of this commands. Then rerun your server
stealthSnake 2021-02-16 20:18:21
amir_0787 2021-02-16 20:16:23
yes i corrected ‘index’ to ‘home’ in html code
but the old error:
Route [__home] not defined. (View: C:xampphtdocsdigilararesourcesviewsfrontmenu.blade.php)

Do not use __ before the route’s name. If you put
->name(‘home’)

{{ route(‘home’)}}

|