Introduction To Eloquent | Laravel For Beginners | Learn Laravel

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024
  • This video will show you how to work with Laravel’s ORM tool called Eloquent. Eloquent stands out for its simplicity - Learn one of the most popular PHP frameworks for its advanced features, templating engine, fast commands and security.
    📚 New Udemy Course
    If you're looking to level up your Laravel skills, my new course "Udemy Migirations, Seeders, Factories, Query Builder, Eloquent & Relationships" is the perfect opportunity. Learn the essential tools and techniques for building robust and scalable web applications with Laravel: www.udemy.com/...
    📲 Let’s plan a meeting
    Plan a (paid) 1-hour meeting on Calendly to do portfolio reviews, code reviews resume reviews or a coaching session for Laravel. Please read the description before booking: calendly.com/c...
    💌 Newsletter
    Sign up for my free weekly email newsletter: www.newsletter...
    🔥 Resources
    PHP Hosting (10% DISCOUNT): www.hostinger....
    TikTok: / codewithdary
    Instagram: / codewithdary
    Twitter: / codewithdary
    Blog: blog.codewithd...
    Newsletter: newsletter.cod...
    Patreon: www.patreon.co...
    GitHub: github.com/cod...
    Want to learn more?
    Courses: / @codewithdary
    #laravel #laravel8 #php #introduction

Комментарии • 155

  • @codewithdary
    @codewithdary  2 года назад +2

    LETS CONNECT THROUGH INSTAGRAM.
    instagram.com/codewithdary

  • @rajeshbudhathoki7888
    @rajeshbudhathoki7888 3 года назад +25

    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!

    • @yeasinarafat8227
      @yeasinarafat8227 3 года назад +1

      I have got the problem about this issue. Thanks for your comments!

    • @ahahahathanks5060
      @ahahahathanks5060 2 года назад +1

      thanks, it helped!

    • @tanveermalik5907
      @tanveermalik5907 2 года назад +4

      Isn't this a bit 'disappointing' not to see a response from `Code With Dary'?

    • @niklaswennerstrand1010
      @niklaswennerstrand1010 2 года назад +1

      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.

    • @wmafendi
      @wmafendi Год назад +1

      great!

  • @sulaimanmisri9570
    @sulaimanmisri9570 3 года назад +1

    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'));

  • @siidsharma7810
    @siidsharma7810 3 года назад +10

    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

  • @bassemchrist74
    @bassemchrist74 2 года назад +3

    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.

  • @nathanstanfordsr
    @nathanstanfordsr 3 года назад +2

    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?

    • @nimasaleh4923
      @nimasaleh4923 2 года назад +1

      did you resolve your problem? I'm having the same issue. please help

    • @leeyoung5765
      @leeyoung5765 2 года назад

      @@nimasaleh4923 Me too.

  • @SwitchedOn
    @SwitchedOn 3 года назад +1

    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
      @codewithdary  3 года назад

      I changed it somewhere in the video.
      /cars is a folder called cars with a method index.
      / is the index inside the views folder.

    • @danielevitiello1299
      @danielevitiello1299 3 года назад +1

      @@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!!

  • @gietece
    @gietece 3 года назад +4

    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!

    • @SwitchedOn
      @SwitchedOn 3 года назад +5

      yes, same here.... changed mine to;
      $car = Car::where('id', '=', $id)->first();

    • @ugurd3mir
      @ugurd3mir 3 года назад

      @@SwitchedOn I just removed the first() method and it works.

    • @hussainhakimi8028
      @hussainhakimi8028 3 года назад

      @@SwitchedOn thank you

  • @fredriksundgren2326
    @fredriksundgren2326 2 года назад +4

    Thank you so much Dary for these tutorials. Im working on a school project and your videos are worth more then gold.

    • @codewithdary
      @codewithdary  2 года назад

      Happy to help Fredrik! Rock that sh*t!

  • @felixluk3167
    @felixluk3167 Год назад +1

    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?

    • @codewithdary
      @codewithdary  Год назад

      It looks like you are trying to access a property that doesn't exist

  • @notexpert8902
    @notexpert8902 3 года назад +4

    Great tutorials 👌
    Will there be some kind of bigger project in Laravel 8 like e-commerce site or something similar?
    Greetings from Bosnia :)

    • @codewithdary
      @codewithdary  3 года назад +4

      Hi! Yes, that’s eventually where I’m going to with this course. Got to teach the basics and stuff to get there.

  • @josuebarros-desenvolvedorw2490
    @josuebarros-desenvolvedorw2490 3 года назад +4

    Thanks for the TailwindCSS bro ;)

  • @debalinadas2022
    @debalinadas2022 2 года назад +1

    How to open that MySQL you did not tell that

    • @codewithdary
      @codewithdary  2 года назад

      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 :)

  • @muhdbasiirzulkifle5090
    @muhdbasiirzulkifle5090 2 года назад +1

    Thank you for the excellent tutorial. Can I request to see your desk setup? Thank you.

    • @codewithdary
      @codewithdary  2 года назад

      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! :)

    • @muhdbasiirzulkifle5090
      @muhdbasiirzulkifle5090 10 месяцев назад

      @@codewithdary do you have a favourite keyboard?

  • @PunLlarena
    @PunLlarena 2 года назад +1

    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

    • @codewithdary
      @codewithdary  2 года назад

      Erhm, what?

    • @PunLlarena
      @PunLlarena 2 года назад

      Never mind this comment, I forgot to put @csrf

  • @nibirafsan7609
    @nibirafsan7609 2 года назад +1

    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?

    • @codewithdary
      @codewithdary  2 года назад +1

      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

    • @nibirafsan7609
      @nibirafsan7609 2 года назад

      ​@@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?

  • @vee-z7f
    @vee-z7f Год назад +1

    Thanks , great tutorial

  • @upperlip
    @upperlip 3 года назад +1

    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.

    • @codewithdary
      @codewithdary  3 года назад

      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?

    • @codewithdary
      @codewithdary  3 года назад

      Show me the timestamp otherwise and I'll let you know :)

    • @upperlip
      @upperlip 3 года назад

      @@codewithdary yes that's it. Thanks a lot for the great tutorials and happy new year!

    • @davidfyork
      @davidfyork 3 года назад +6

      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’);

    • @Lx45_
      @Lx45_ 3 года назад +2

      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?

  • @marcgeonet8796
    @marcgeonet8796 2 года назад

    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

  • @carlfranz6805
    @carlfranz6805 2 года назад

    um. My 'css/app.css' has nothing in it. What did I forget to do?

  • @professormeow3399
    @professormeow3399 3 года назад

    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.

    • @codewithdary
      @codewithdary  3 года назад

      Thank you for sharing, I'll look into it! :)

  • @sirbangalot569
    @sirbangalot569 3 года назад +2

    👏👏👏 Most definitely recommending this to the guys at work.

  • @upperlip
    @upperlip 3 года назад +1

    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?

    • @codewithdary
      @codewithdary  3 года назад +1

      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.

  • @tallitvak5325
    @tallitvak5325 3 года назад +1

    love you man!!!!

    • @codewithdary
      @codewithdary  3 года назад

      A lot of love back from over here!

  • @blobbyblue02
    @blobbyblue02 2 года назад

    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.

  • @benbigrasvirtualtourswebde7116
    @benbigrasvirtualtourswebde7116 3 года назад +2

    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?

    • @tech-trials
      @tech-trials 3 года назад +2

      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');
      }

    • @goldfngr
      @goldfngr 3 года назад +1

      neither version of web.php or the CarsController works for me..

    • @tech-trials
      @tech-trials 3 года назад

      @@goldfngr 2 checks
      are you using laravel 8
      and is your view in
      'views/cars/index.blade.php'
      or
      'views/index.blade.php'

    • @codewithdary
      @codewithdary  3 года назад +1

      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
      ]);
      }

    • @codewithdary
      @codewithdary  3 года назад +2

      I honestly have no idea what happened over there. I thought I changed it in the video, lol!

  • @ryanseguiro5479
    @ryanseguiro5479 Год назад +1

    Man thankyou so much, you helped me a LOT! ❣️😎

  • @richardracine9055
    @richardracine9055 2 года назад +1

    Thank you for this great tutorial . I especially appreciate how the flow mirrors the laravel docs.

    • @codewithdary
      @codewithdary  2 года назад

      Thank you Richard, I'll try my best to work around the Laravel docs!

  • @richardracine9055
    @richardracine9055 Год назад +1

    Awesome tutorial, Dary. Thank you very much.

  • @charitysimon-peraboh5555
    @charitysimon-peraboh5555 3 года назад +1

    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.

    • @tusharagrawal5458
      @tusharagrawal5458 3 года назад +1

      same. Have you found any solution?

    • @charitysimon-peraboh5555
      @charitysimon-peraboh5555 3 года назад

      @@tusharagrawal5458 no sir, will be grate for your help

    • @harisshahjahan1090
      @harisshahjahan1090 3 года назад

      have you found a solution for this yet?

    • @charitysimon-peraboh5555
      @charitysimon-peraboh5555 3 года назад

      @@harisshahjahan1090 No sir

    • @harisshahjahan1090
      @harisshahjahan1090 3 года назад +8

      @@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

  • @value-for-money
    @value-for-money 3 года назад +1

    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

    • @codewithdary
      @codewithdary  3 года назад +1

      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!

  • @msaadcartoon5617
    @msaadcartoon5617 3 года назад +1

    I like your way of teaching i love it ;
    keep it up,

  • @siidsharma7810
    @siidsharma7810 3 года назад +1

    You’ll have 100k subscribers very soon, best of luck

    • @codewithdary
      @codewithdary  3 года назад +1

      Goals brother. I'll do my best :)

  • @CODINGVENTURE
    @CODINGVENTURE 2 года назад

    Adding the tailwinds preset does not work for me for some reason, I’m not sure if its my windows configuration for composer

    • @codewithdary
      @codewithdary  2 года назад +1

      Is has been depreciated. I've got different videos on how you could setup TailwindCSS or the easiest way is implementing Laravel Breeze :)

    • @CODINGVENTURE
      @CODINGVENTURE 2 года назад

      @@codewithdary thank you I would to over that. I’m currently going through the udemy cloudways course

  • @nimasaleh4923
    @nimasaleh4923 2 года назад

    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??

    • @codewithdary
      @codewithdary  2 года назад

      This is a video series where I have added Tailwindcss into my project :)

    • @nimasaleh4923
      @nimasaleh4923 2 года назад +1

      @@codewithdary Thanks Dary!! You make really awesome videos!

    • @codewithdary
      @codewithdary  2 года назад

      I make awesome videos for awesome people! :)

  • @davidrowlands8548
    @davidrowlands8548 3 года назад +1

    I finished the video set up the entire CRUD application, but never got Tailwind to work.

    • @codewithdary
      @codewithdary  3 года назад

      Why?

    • @davidrowlands8548
      @davidrowlands8548 3 года назад +1

      ​@@codewithdary Followed the steps, but Tailwind just didn't work. Not sure why.

    • @codewithdary
      @codewithdary  3 года назад

      What's the error? :D

    • @davidrowlands8548
      @davidrowlands8548 3 года назад

      @@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=

  • @ahmadrio
    @ahmadrio 2 года назад

    terimakasih mr. dary 👍

  • @joemarvillagracia4078
    @joemarvillagracia4078 2 года назад +1

    Thanks i learn much

  • @shaheerarain1026
    @shaheerarain1026 3 года назад

    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.

    • @codewithdary
      @codewithdary  3 года назад +1

      Already done! Watch this video: ruclips.net/video/bKUNHPvhsF0/видео.html

  • @muzika5001
    @muzika5001 2 года назад

    Amazing tutorial! :)

  • @smurffronda2951
    @smurffronda2951 Год назад

    Thank you, Dary!

  • @dacpuspadewi
    @dacpuspadewi 3 года назад

    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. :)

    • @codewithdary
      @codewithdary  3 года назад +1

      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.

    • @dacpuspadewi
      @dacpuspadewi 3 года назад

      @@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

  • @summaryofcode4573
    @summaryofcode4573 3 года назад +1

    Thanks dear

  • @jensknaack9016
    @jensknaack9016 2 года назад

    A very good tutorial. Thank you very much.

  • @emmanuelasaolu5745
    @emmanuelasaolu5745 3 года назад +2

    Dary... I love you.
    Please, don't stop the videos... They're really awesome...
    Keep them going man.

    • @codewithdary
      @codewithdary  3 года назад

      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

    • @OnlyJavascript
      @OnlyJavascript 3 года назад

      @@codewithdary That's why we love you Dary

  • @invalidname4899
    @invalidname4899 3 года назад

    I dont know what happened but none of my tailwind classes are working :/

    • @maykelesser
      @maykelesser 3 года назад

      Me either. My app.css is empty after the same steps.

    • @graham-wright
      @graham-wright 2 года назад +1

      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.

    • @nimasaleh4923
      @nimasaleh4923 2 года назад

      @@graham-wright OMG! thank you so so much!! I kept searching on google. Your comment came to my laravel-knowledge's rescue :D

  • @rajabhishek2936
    @rajabhishek2936 3 года назад

    Awosem

  • @danb9393
    @danb9393 3 года назад

    5:03 ,i got 404 not found.what is the reason

    • @danb9393
      @danb9393 3 года назад

      5:08

    • @codewithdary
      @codewithdary  3 года назад +1

      Your endpoint is wrong. Perform php artisan route:list to see your endpoints.

    • @danb9393
      @danb9393 3 года назад

      @@codewithdary thanks.it works

  • @Isthiyaquekambathagothi
    @Isthiyaquekambathagothi 3 года назад

    how to add image and store on database when creating ? do we have to pass the path or is there any other way?

    • @codewithdary
      @codewithdary  3 года назад +1

      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! :)

    • @Isthiyaquekambathagothi
      @Isthiyaquekambathagothi 3 года назад

      @@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

    • @marktheunknown1829
      @marktheunknown1829 4 месяца назад +1

      @@Isthiyaquekambathagothi I know it's been 3 years, but maybe for sb else is useful, that MySQL doesn't support Many to Many relationships

    • @Isthiyaquekambathagothi
      @Isthiyaquekambathagothi 4 месяца назад

      Thanks for responding even after 3 years.. now I have been working on flutter for last 3 years

  • @elkhanhamet2561
    @elkhanhamet2561 3 года назад

    thank you Dary!!!👍👍👍

  • @GeekZone69
    @GeekZone69 3 года назад

    Best tutorial

  • @josuebarros-desenvolvedorw2490
    @josuebarros-desenvolvedorw2490 3 года назад

    This TailwindCSS preset saves a loooot of time!

    • @codewithdary
      @codewithdary  3 года назад +1

      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.

    • @josuebarros-desenvolvedorw2490
      @josuebarros-desenvolvedorw2490 3 года назад

      @@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!

    • @codewithdary
      @codewithdary  3 года назад +1

      @@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

    • @josuebarros-desenvolvedorw2490
      @josuebarros-desenvolvedorw2490 3 года назад

      @@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!

    • @OnlyJavascript
      @OnlyJavascript 3 года назад

      @@codewithdary can't wait to learn it

  • @techjavaid6177
    @techjavaid6177 3 года назад

    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

    • @OnlyJavascript
      @OnlyJavascript 3 года назад +1

      you have enough time to practice more. utilize it bro.

    • @codewithdary
      @codewithdary  3 года назад +1

      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

  • @biancaschuurman2213
    @biancaschuurman2213 3 года назад

    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!

    • @codewithdary
      @codewithdary  3 года назад

      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.

    • @codewithdary
      @codewithdary  3 года назад

      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.