I think you made a mistake at 38:18 while implementing edit and update method, the following code was returning the first row from the database: $car = Car::find($id)->first(); I omitted the first() method as the following and it worked: $car = Car::find($id); Thanks!
Thanks for your fix Rajesh. It prevented the selection to always get Audi as the id to edit. Always getting id 1 to edit no matter what item you wanted to edit. It did work in the video but that was because Daryl selected id Nr 1 to edit.
Hey Dary. I just love your tutorial. For junior-level like me, your tutorials help me a lot. Thank you so much. And if I can share with you, before this I code using your code (which is I found more readable for junior level). Later when I do some research, I found we can simplify your code (Refer to minutes 31:17. At store part). What I do is I refactor the code and my code after that is like this : $product = Product::create($request->only('name', 'founded', 'description'));
People like you are the reason why I do this man. I get very satisfied from the fact that I can teach people cool stuff, whether it’s 10, 100 of 1000000 people! :D
pay attention colleagues : that the return view in CarsController file must be: return view('cars.index'); and not: return view('index'); otherwise you will get no view at the browser.
I dont understand how this is working? Routes is calling for '/cars' but you dont put that URL in, you are just in the root. Then it looks from the breadcrumbs, you create 'index.blade.php' in the root of 'views' not under cars (though the folder structure does look like its nested under cars!) Really confused, I've 100% got the code the way you have done it - when I go to the root domain, I get a "404". If I browse to /cars URI, I get the index.blade.php in the root of 'views' I have set up? I'm just confused why you set up the cars directory and also why your Route is to /cars ? Great vids by the way, really enjoying learning from them!
@@codewithdary I also encountered the same problem. We have index.blade.php stored in cars folder and Route::resource('/cars' , CarsController::class). But if you point to root in URL (so your URI is equal to '/'), how can you get the index.blade.php printed out? If I set my URI in Route::resource to '/', then in my controller I set return view('cars.index') so I can get index.blade.php pointing to root, but if I follow your set up, I get only 404. Can you explain why we have this problem? I'm sorry Dary, your videos are great!! Really! Thanks for your time and patience!!
My setup is very simple, just an external monitor and my laptop. Most likely will not make a video about it just because I don't like to record myself haha! :)
Hi, there seems to be an error at 37:50 $car = Car::find($id)->first(); when i try to edit car with id=3, the displayed values are from id=1, removing first() seems to work ok. BTW great tutorial, thanks!
Hi Dary, maybe this is a dumb question. I tried to search for answers on the Internet but wasn't able to find one. At 21:15 you changed the get() to firstOrFail(), which caused the frontend to bork with an "Trying to get property 'founded' of non-object" error. My question is, why did that happen? the firstOrFail() returned an array with one row, which the @foreach should be able to pick up and process. However, this didn't seen to be the case. So is the Laravel @foreach doesn't work with arrays with only one row?
Thanks a lot for your amazing tutorial. Love your teaching style :) Wish you make dedicated Playlist about Laravel Livewire since it make Laravel more more powerful :D
Not sure what I missed rewatched to find it. Somehow my tailwindcss did not get put in my app.css - Where in the video do I make sure that my app.css is not empty?
Hi Dary, when looping through data passed via the controller, I sometimes see {{ $item['description'] }} instead of {{ $item->description }}. Both in the context of eloquent. Are both interchangeable?
You can’t access arrays with the access operator [->]. It only applies to objects. But you can use the brackets to access an array. It just depends on how you pull out data from your database.
Hi Dary, thanks for the great tutorials. I'm a bit confused about the routing here: In the web.php the uri defined in the routing is /cars, but in the browser /cars is not needed.
Yeah I made a small mistake by starting off with the / as the URI. I changed it later on to /cars when I needed to create other methods. Is that what you mean?
I think some might not have spotted that in the video you create index.blade.php in the views folder, not the newly created views/cars folder, which is why it worked fine in the video, but some people following along might have created it in the cars folder (so in CarsController would need to return view(‘cars.index’); instead of return view(‘index’);
Im confused here as well, the index.blade.php file is created in the views folder, but the route points to the cars folder. Why didn't you get a 404 Error?
Hello Dary, 1:32 I couldn't install npm, it says " 'npm' is not recognized as an internal or external command, operable program or batch file." could you please tell me the solution?
Just Download and Install Node.js from here nodejs.org/en/ If you run the downloaded file and install it, they will automatically configure for your system You don't need any other configurations anymore, now you can use the npm command anywhere
@@codewithdary Thank you so much, you did a great help! :) since I already installed npm through that link, so I can skip 1:32 - 1:38 that part of that video?
Hi Dary, something threw me off, around the 5 minute mark of this video. You set your route end point to "/cars" but then again everything works from the root URL. I would expect that you would need to add "/cars" in the URL to have this work, but it seems to work from the root URL. why?
There seems to be a small mistake Dont change 'web.php' Route::resource('/cars', CarsController::class); leave it as Route::resource('/', CarsController::class); Rather change 'CarsController.php' to public function index() { return view('cars.index'); }
This is unrelated, but you made a mistake with your affiliate links (The link for one of your Laptops goes to the Laptop cooler, so you have this one twice). Maybe this doesn't matter that much, but I don want you to miss out any potential profits, you deserve every penny for the content you create.
Whoa, even for myself. It usually took like 30 minutes to design a basic website, Tailwind made it so much easier! Might create a course about it soon.
@@codewithdary cool! This is trending and saves a lot of time! A tailwind course will fit very well, thanks for sharing bro! ;) Ever heard of Livewire, AlpineJS and Jetstream? Laravel's ecossystem is soooo rich!
@@josuebarros-desenvolvedorw2490 Oh, don’t get me started on Livewire and Jetstreams! Incredible to use, will definitely do it in the future. Honestly haven’t really worked with AlphineJS. I’m currently working on React and Vue on the side, so that might be a thing for in the future as well! Btw, no idea where you’re from but have a great new year man! :D
@@codewithdary I'm new to Laravel, started studying 3 weeks ago and I'm in love with Livewire and Jetstreams... got my first client to work with laravel, lets hope I finish the job without bugs haha AlpineJS is almost like a VueJS but lightweight, fits perfectly well with TailwindCSS, I think you'll love it!
Edit: Don't mind this comment, I just forgot to put in @csrf 28:43 I'm on Laravel 9.7 Using GET, HEAD, PUT, PATCH, DELETE method in route isn't supported anymore
Hi appreciate your work, I am your next subscriber. Can you please share the video how you customize your terminal using ohmyzsh? Its look so good. Thanks.
Hello Mr. Dary, thanks so much for the video, after deleting welcome.php and creating cars/index.php then changing route to Route::resource('/cars', CarsController::class) it results in error 404. Pls has anybody the same error as me? I need help pls.
@@charitysimon-peraboh5555 Inside your carscontroller file change the index method such that, Public function index (){ return view ('cars.index'); } Inside your Web.php file your route will be, Route:resource('/cars', CarsController::class); And then access 127.0.0.1:8000/cars. This should work
It's a very nice tutorial, u teaching very well, very helpful. thankyou so much.. anyway, I'm really confused about how to deal with metadata that has key and value things for eloquent laravel, let's say the user table has relation with user_meta table(that has id, key, value column). i have no idea how to deal with it and show the value based on the key(?), i hope u will create the tutorial. :)
I always recommend developers to think relationships out loud. You need to create a relationship between the users table and user_meta right? - A user has one meta (I’m guessing) - A meta has one user (I’m guessing) Then you need to create a relationship between them. We’re talking about a one to one right here.
@@codewithdary yeah i already made the relation and its one to many (1 user has many meta), and it solved by installing metable package from kodeine. Thanks Dary :D
4:16 for me "Route::resource('/', CarsController::class);" didn't work, I had to use "Route::resource('/', 'CarsController');" that seemed to work. I hope I helped someone with this, this was very hard to find out.
Hello Dary, first of all i'm so happy to find your channel. I learn a lot of things in a great way and thank you for it. Just a question about the Route::resource in the web.php page( around 4'18''), but maybe something has changed in laravel. Your method "Route::resource('/cars', CarsController::class);" with the view page index.blade.php in a subdirectory cars in views directory doesn't seem to work with me. I need to put the index.blade.php directly in the views folder and use the next method "Route::resource('cars', CarsController::class);" to make it work with the url localhost:8000/cars. Do you think it is the wright way to proceed ? Thx a lot. Marc
@@codewithdary yes, i have watched it,i haved watched whole series, it very easy to understand, am loving it, i have started to work on test based on this series, now am stuck with a error when i tried ManyToMany Eloquents
It's a video series and you just watched episode 22. It's pretty much the same MySQL as any other tool though, shouldn't be worried about it too much :)
I'm sure you guys worked this out by now, but for future reference, I think the video missed out the command: php artisan ui tailwindcss which adds the tailwind stuff to the app.css. After working this out I had problems with mix not working. ('mix' is not recognized as an internal or external command, operable program or batch file.) - This was fixed by running npm audit fix --force and then the npm run dev.
Hi Dary, thank you for the video. It is great! Someone wrote this in the comments: We have index.blade.php stored in cars folder and Route::resource('/cars' , CarsController::class). But if you point to root in URL (so your URI is equal to '/'), how can you get the index.blade.php printed out? If I set my URI in Route::resource to '/', then in my controller I set return view('cars.index') so I can get index.blade.php pointing to root, but if I follow your set up, I get only 404. Unfortunately, I am having the same problem. Could you explain why is that? Thank you in advance!
Hi Bianca, thank you for your awesome comment! Let me explain to you what’s going on. The best way to showcase this is s by running php artisan:route list in the CLI. I think I replied to that comment that I changed the route when I was recording the video and accidentality cut it out. In the project, I’ve got the following as my Route: Since we’re using the resource method right here, it will automatically detect that /cars belongs to the index method inside the CarsController (php artisan:route list). Route::resource('/cars', CarsController::class); Then inside the index method, you can define whatever route you want, but I am returning: Return view(‘cars.index’, ‘cars’ => $cars); This will search for a file inside the cars folder inside our view, where we’ve got a index.blade.php file. I think that I started off in this video by adding the index.blade.php inside the views folder, and not inside the cars folder, that’s where the issue occurs. You can do that, but then you need to return a view(‘index’) inside your index method.
It’s a long response, but I hope it make sense. 404 means that the page has not been found. So somewhere (route or index method) something is being called that doesn’t exist.
LETS CONNECT THROUGH INSTAGRAM.
instagram.com/codewithdary
Thank you so much Dary for these tutorials. Im working on a school project and your videos are worth more then gold.
Happy to help Fredrik! Rock that sh*t!
I think you made a mistake at 38:18 while implementing edit and update method, the following code was returning the first row from the database:
$car = Car::find($id)->first();
I omitted the first() method as the following and it worked:
$car = Car::find($id);
Thanks!
I have got the problem about this issue. Thanks for your comments!
thanks, it helped!
Isn't this a bit 'disappointing' not to see a response from `Code With Dary'?
Thanks for your fix Rajesh. It prevented the selection to always get Audi as the id to edit. Always getting id 1 to edit no matter what item you wanted to edit. It did work in the video but that was because Daryl selected id Nr 1 to edit.
great!
Thank you for this great tutorial . I especially appreciate how the flow mirrors the laravel docs.
Thank you Richard, I'll try my best to work around the Laravel docs!
Hey Dary. I just love your tutorial. For junior-level like me, your tutorials help me a lot. Thank you so much.
And if I can share with you, before this I code using your code (which is I found more readable for junior level). Later when I do some research, I found we can simplify your code (Refer to minutes 31:17. At store part).
What I do is I refactor the code and my code after that is like this :
$product = Product::create($request->only('name', 'founded', 'description'));
👏👏👏 Most definitely recommending this to the guys at work.
Wow that's awesome! :D
Dary... I love you.
Please, don't stop the videos... They're really awesome...
Keep them going man.
People like you are the reason why I do this man. I get very satisfied from the fact that I can teach people cool stuff, whether it’s 10, 100 of 1000000 people! :D
@@codewithdary That's why we love you Dary
thank you so much for this tutorial, can you please build a project in laravel with react JS, I could not find any react project in laravel
Great suggestion!
You’ll have 100k subscribers very soon, best of luck
Goals brother. I'll do my best :)
Awesome tutorial, Dary. Thank you very much.
You're very welcome Richard!
Man thankyou so much, you helped me a LOT! ❣️😎
Thank you for waching Ryan!!
pay attention colleagues :
that the return view in CarsController file must be: return view('cars.index'); and not: return view('index');
otherwise you will get no view at the browser.
Thank you for sharing.
I dont understand how this is working? Routes is calling for '/cars' but you dont put that URL in, you are just in the root. Then it looks from the breadcrumbs, you create 'index.blade.php' in the root of 'views' not under cars (though the folder structure does look like its nested under cars!)
Really confused, I've 100% got the code the way you have done it - when I go to the root domain, I get a "404". If I browse to /cars URI, I get the index.blade.php in the root of 'views' I have set up?
I'm just confused why you set up the cars directory and also why your Route is to /cars ?
Great vids by the way, really enjoying learning from them!
I changed it somewhere in the video.
/cars is a folder called cars with a method index.
/ is the index inside the views folder.
@@codewithdary I also encountered the same problem. We have index.blade.php stored in cars folder and Route::resource('/cars' , CarsController::class). But if you point to root in URL (so your URI is equal to '/'), how can you get the index.blade.php printed out? If I set my URI in Route::resource to '/', then in my controller I set return view('cars.index') so I can get index.blade.php pointing to root, but if I follow your set up, I get only 404. Can you explain why we have this problem? I'm sorry Dary, your videos are great!! Really! Thanks for your time and patience!!
I like your way of teaching i love it ;
keep it up,
Thank you, I will!!
Great tutorials 👌
Will there be some kind of bigger project in Laravel 8 like e-commerce site or something similar?
Greetings from Bosnia :)
Hi! Yes, that’s eventually where I’m going to with this course. Got to teach the basics and stuff to get there.
Thank you for the excellent tutorial. Can I request to see your desk setup? Thank you.
My setup is very simple, just an external monitor and my laptop. Most likely will not make a video about it just because I don't like to record myself haha! :)
@@codewithdary do you have a favourite keyboard?
A very good tutorial. Thank you very much.
Glad it was helpful!
Hi, there seems to be an error at 37:50
$car = Car::find($id)->first();
when i try to edit car with id=3, the displayed values are from id=1, removing first() seems to work ok.
BTW great tutorial, thanks!
yes, same here.... changed mine to;
$car = Car::where('id', '=', $id)->first();
@@SwitchedOn I just removed the first() method and it works.
@@SwitchedOn thank you
Hi Dary, maybe this is a dumb question. I tried to search for answers on the Internet but wasn't able to find one. At 21:15 you changed the get() to firstOrFail(), which caused the frontend to bork with an "Trying to get property 'founded' of non-object" error.
My question is, why did that happen? the firstOrFail() returned an array with one row, which the @foreach should be able to pick up and process. However, this didn't seen to be the case. So is the Laravel @foreach doesn't work with arrays with only one row?
It looks like you are trying to access a property that doesn't exist
Thanks a lot for your amazing tutorial. Love your teaching style :)
Wish you make dedicated Playlist about Laravel Livewire since it make Laravel more more powerful :D
Hi! Thanks man, appreciate the honesty. I will probably do it after this one since I’m getting a lot of requests about it. Thanks!
Thanks , great tutorial
You're welcome!
Thank you, Dary!
Thank you for watching :)
Not sure what I missed rewatched to find it. Somehow my tailwindcss did not get put in my app.css - Where in the video do I make sure that my app.css is not empty?
did you resolve your problem? I'm having the same issue. please help
@@nimasaleh4923 Me too.
terimakasih mr. dary 👍
Amazing tutorial! :)
Thanks for the TailwindCSS bro ;)
More than welcome Josue!
Hi Dary, when looping through data passed via the controller, I sometimes see {{ $item['description'] }} instead of {{ $item->description }}. Both in the context of eloquent. Are both interchangeable?
You can’t access arrays with the access operator [->]. It only applies to objects. But you can use the brackets to access an array.
It just depends on how you pull out data from your database.
Hi Dary, thanks for the great tutorials.
I'm a bit confused about the routing here: In the web.php the uri defined in the routing is /cars, but in the browser /cars is not needed.
Yeah I made a small mistake by starting off with the / as the URI. I changed it later on to /cars when I needed to create other methods. Is that what you mean?
Show me the timestamp otherwise and I'll let you know :)
@@codewithdary yes that's it. Thanks a lot for the great tutorials and happy new year!
I think some might not have spotted that in the video you create index.blade.php in the views folder, not the newly created views/cars folder, which is why it worked fine in the video, but some people following along might have created it in the cars folder (so in CarsController would need to return view(‘cars.index’); instead of return view(‘index’);
Im confused here as well, the index.blade.php file is created in the views folder, but the route points to the cars folder. Why didn't you get a 404 Error?
Thanks i learn much
You're welcome!
thank you Dary!!!👍👍👍
You are so welcome!
love you man!!!!
A lot of love back from over here!
Thanks dear
Welcome 😊
Hello Dary, 1:32 I couldn't install npm, it says " 'npm' is not recognized as an internal or external command,
operable program or batch file." could you please tell me the solution?
Just Download and Install Node.js from here nodejs.org/en/
If you run the downloaded file and install it, they will automatically configure for your system
You don't need any other configurations anymore, now you can use the npm command anywhere
@@codewithdary Thank you so much, you did a great help! :) since I already installed npm through that link, so I can skip 1:32 - 1:38 that part of that video?
Hi Dary, something threw me off, around the 5 minute mark of this video. You set your route end point to "/cars" but then again everything works from the root URL. I would expect that you would need to add "/cars" in the URL to have this work, but it seems to work from the root URL. why?
There seems to be a small mistake
Dont change 'web.php'
Route::resource('/cars', CarsController::class);
leave it as
Route::resource('/', CarsController::class);
Rather change 'CarsController.php' to
public function index()
{
return view('cars.index');
}
neither version of web.php or the CarsController works for me..
@@goldfngr 2 checks
are you using laravel 8
and is your view in
'views/cars/index.blade.php'
or
'views/index.blade.php'
Routes:
Route::resource('/cars', CarsController::class);
Controller:
public function index()
{
//Query builder
//$cars = DB::table('cars')->paginate(4);
$cars = Car::paginate(3);
return view('cars.index', [
'cars' => $cars
]);
}
I honestly have no idea what happened over there. I thought I changed it in the video, lol!
This is unrelated, but you made a mistake with your affiliate links (The link for one of your Laptops goes to the Laptop cooler, so you have this one twice). Maybe this doesn't matter that much, but I don want you to miss out any potential profits, you deserve every penny for the content you create.
Thank you for sharing, I'll look into it! :)
This TailwindCSS preset saves a loooot of time!
Whoa, even for myself. It usually took like 30 minutes to design a basic website, Tailwind made it so much easier! Might create a course about it soon.
@@codewithdary cool! This is trending and saves a lot of time!
A tailwind course will fit very well, thanks for sharing bro! ;)
Ever heard of Livewire, AlpineJS and Jetstream?
Laravel's ecossystem is soooo rich!
@@josuebarros-desenvolvedorw2490 Oh, don’t get me started on Livewire and Jetstreams! Incredible to use, will definitely do it in the future. Honestly haven’t really worked with AlphineJS. I’m currently working on React and Vue on the side, so that might be a thing for in the future as well!
Btw, no idea where you’re from but have a great new year man! :D
@@codewithdary I'm new to Laravel, started studying 3 weeks ago and I'm in love with Livewire and Jetstreams... got my first client to work with laravel, lets hope I finish the job without bugs haha
AlpineJS is almost like a VueJS but lightweight, fits perfectly well with TailwindCSS, I think you'll love it!
@@codewithdary can't wait to learn it
Best tutorial
Best viewers :D
Edit: Don't mind this comment, I just forgot to put in @csrf
28:43
I'm on Laravel 9.7 Using GET, HEAD, PUT, PATCH, DELETE method in route isn't supported anymore
Erhm, what?
Never mind this comment, I forgot to put @csrf
Hi appreciate your work, I am your next subscriber.
Can you please share the video how you customize your terminal using ohmyzsh?
Its look so good.
Thanks.
Already done! Watch this video: ruclips.net/video/bKUNHPvhsF0/видео.html
Hello Mr. Dary, thanks so much for the video, after deleting welcome.php and creating cars/index.php then changing route to Route::resource('/cars', CarsController::class) it results in error 404. Pls has anybody the same error as me? I need help pls.
same. Have you found any solution?
@@tusharagrawal5458 no sir, will be grate for your help
have you found a solution for this yet?
@@harisshahjahan1090 No sir
@@charitysimon-peraboh5555 Inside your carscontroller file change the index method such that,
Public function index (){ return view ('cars.index'); }
Inside your Web.php file your route will be,
Route:resource('/cars', CarsController::class);
And then access 127.0.0.1:8000/cars.
This should work
Waited for 3-4 day for new videos...kindly make 3-4 a week.. Thank you, for your awesome work and quality time...love every video
you have enough time to practice more. utilize it bro.
Appreciate It my friend. Try to stay active and read the Laravel documentation about the specific topic in the meantime! I try to do my best
It's a very nice tutorial, u teaching very well, very helpful. thankyou so much..
anyway, I'm really confused about how to deal with metadata that has key and value things for eloquent laravel, let's say the user table has relation with user_meta table(that has id, key, value column). i have no idea how to deal with it and show the value based on the key(?), i hope u will create the tutorial. :)
I always recommend developers to think relationships out loud. You need to create a relationship between the users table and user_meta right?
- A user has one meta (I’m guessing)
- A meta has one user (I’m guessing)
Then you need to create a relationship between them. We’re talking about a one to one right here.
@@codewithdary yeah i already made the relation and its one to many (1 user has many meta), and it solved by installing metable package from kodeine. Thanks Dary :D
4:16 for me "Route::resource('/', CarsController::class);" didn't work, I had to use "Route::resource('/', 'CarsController');" that seemed to work.
I hope I helped someone with this, this was very hard to find out.
Adding the tailwinds preset does not work for me for some reason, I’m not sure if its my windows configuration for composer
Is has been depreciated. I've got different videos on how you could setup TailwindCSS or the easiest way is implementing Laravel Breeze :)
@@codewithdary thank you I would to over that. I’m currently going through the udemy cloudways course
um. My 'css/app.css' has nothing in it. What did I forget to do?
I finished the video set up the entire CRUD application, but never got Tailwind to work.
Why?
@@codewithdary Followed the steps, but Tailwind just didn't work. Not sure why.
What's the error? :D
@@codewithdary Finally got it working!!!
I made a school boy error.
I wrote the CSS tag wrong.
I had
instead of:
I forgot to add: rel=
Hello Dary, first of all i'm so happy to find your channel. I learn a lot of things in a great way and thank you for it.
Just a question about the Route::resource in the web.php page( around 4'18''), but maybe something has changed in laravel. Your method "Route::resource('/cars', CarsController::class);" with the view page index.blade.php in a subdirectory cars in views directory doesn't seem to work with me. I need to put the index.blade.php directly in the views folder and use the next method "Route::resource('cars', CarsController::class);" to make it work with the url localhost:8000/cars. Do you think it is the wright way to proceed ? Thx a lot. Marc
how to add image and store on database when creating ? do we have to pass the path or is there any other way?
Best way is to store the path and not the actual image. I have a video about it in this series! You should watch it! :)
@@codewithdary yes, i have watched it,i haved watched whole series, it very easy to understand, am loving it, i have started to work on test based on this series, now am stuck with a error when i tried ManyToMany Eloquents
@@Isthiyaquekambathagothi I know it's been 3 years, but maybe for sb else is useful, that MySQL doesn't support Many to Many relationships
Thanks for responding even after 3 years.. now I have been working on flutter for last 3 years
Hello.. can anyone help me? at 5:56 Dary shows his app.css inside public -> css -> app.css When i check my app.css its all empty. Why is that??
This is a video series where I have added Tailwindcss into my project :)
@@codewithdary Thanks Dary!! You make really awesome videos!
I make awesome videos for awesome people! :)
How to open that MySQL you did not tell that
It's a video series and you just watched episode 22. It's pretty much the same MySQL as any other tool though, shouldn't be worried about it too much :)
I dont know what happened but none of my tailwind classes are working :/
Me either. My app.css is empty after the same steps.
I'm sure you guys worked this out by now, but for future reference, I think the video missed out the command: php artisan ui tailwindcss which adds the tailwind stuff to the app.css.
After working this out I had problems with mix not working. ('mix' is not recognized as an internal or external command, operable program or batch file.) - This was fixed by running npm audit fix --force and then the npm run dev.
@@graham-wright OMG! thank you so so much!! I kept searching on google. Your comment came to my laravel-knowledge's rescue :D
5:03 ,i got 404 not found.what is the reason
5:08
Your endpoint is wrong. Perform php artisan route:list to see your endpoints.
@@codewithdary thanks.it works
Awosem
Hi Dary,
thank you for the video. It is great!
Someone wrote this in the comments:
We have index.blade.php stored in cars folder and Route::resource('/cars' , CarsController::class). But if you point to root in URL (so your URI is equal to '/'), how can you get the index.blade.php printed out? If I set my URI in Route::resource to '/', then in my controller I set return view('cars.index') so I can get index.blade.php pointing to root, but if I follow your set up, I get only 404.
Unfortunately, I am having the same problem. Could you explain why is that?
Thank you in advance!
Hi Bianca, thank you for your awesome comment! Let me explain to you what’s going on. The best way to showcase this is s by running php artisan:route list in the CLI.
I think I replied to that comment that I changed the route when I was recording the video and accidentality cut it out.
In the project, I’ve got the following as my Route: Since we’re using the resource method right here, it will automatically detect that /cars belongs to the index method inside the CarsController (php artisan:route list).
Route::resource('/cars', CarsController::class);
Then inside the index method, you can define whatever route you want, but I am returning:
Return view(‘cars.index’, ‘cars’ => $cars);
This will search for a file inside the cars folder inside our view, where we’ve got a index.blade.php file.
I think that I started off in this video by adding the index.blade.php inside the views folder, and not inside the cars folder, that’s where the issue occurs. You can do that, but then you need to return a view(‘index’) inside your index method.
It’s a long response, but I hope it make sense. 404 means that the page has not been found. So somewhere (route or index method) something is being called that doesn’t exist.