Laravel 5.2 PHP - Build a Shopping Cart - #9 Cart Views

  Рет қаралды 58,739

Academind

Academind

Күн бұрын

Пікірлер: 192
@toomass2668
@toomass2668 8 жыл бұрын
This is astonishing, absolutely astonishing. Instructor speaks very well, good pace and very understandable. Code is well written and everything is explained well. You really do learn alot from this course.
@academind
@academind 8 жыл бұрын
Again, many thanks for this great feedback, it really means a lot to me! :)
@dhanashreedeshpande7100
@dhanashreedeshpande7100 5 жыл бұрын
You have mentioned wrong spelling of toggle , but still its working in your video, Whereas at my end, for the same code, it does not show drop down. Action Reduce by 1 Reduce All
@edwinchp
@edwinchp 4 жыл бұрын
I am using Laravel 7 and this still works! It's awesome. You are awesome. Thanks dude :)
@mrzink9180
@mrzink9180 2 жыл бұрын
I see that when you press add to cart the page doesnt refresh, however when I do it, the page refreshes. Any clue how I can fix that and make it not refresh after I add something to the cart?
@MeAsh768
@MeAsh768 4 жыл бұрын
It is great toutorial the explanation is very easy anf frequently understandable before this i was tens how to make cart and many thinks rolling in my mind but after watching your toutorial its clear now really it is best tutorial and you are best teacher thank-you much love from india 😃
@bipensawden6074
@bipensawden6074 7 жыл бұрын
Can you please include the tutorial for delete and update of particular product also? Thanks in advance :)
@geraldyvancabarrubias6196
@geraldyvancabarrubias6196 3 жыл бұрын
sir do you have a video for update cart?
@SazaYT
@SazaYT 4 жыл бұрын
So when i added my first item, lets name it "chicken"..and then i try to add 'beef' in the basket as well, what will happen is the qty of chicken will go to 2 instead off adding the beef. Something must be wrong in my Basket.php class. Any ideas?
@yoonastk3042
@yoonastk3042 7 жыл бұрын
if i quite the localhost..nd return back the cart 1 is there..how can i clear it?
@dhanashreedeshpande7100
@dhanashreedeshpande7100 5 жыл бұрын
Drop down is not working. What may be the reason? I have coded everything exactly similar to your video. Using Laravel 5.7...Plz help...
@rikimarusaintpreux8448
@rikimarusaintpreux8448 8 жыл бұрын
HI Sir is there any chance to reset the number of shopping carts ? cause when i started to use different user the value doesnt change thanks a lot
@andreeamaria8108
@andreeamaria8108 4 жыл бұрын
Hello! How can I display the image of the product in my cart? I tried to introduce the image path in shopping-cart.blade.php but it doesn't work ..
@mauri29robayo
@mauri29robayo 8 жыл бұрын
If I have 100 items. I add the 99 item to the cart => the page of the shopping cart will be reloaded and it shows me again the firsts products and not the 99 product. How can I do so that after adding an item the page reloads and goes exactly where the 99 item was? Thanks a lot
@kainushia1073
@kainushia1073 6 жыл бұрын
when i press ADD TO CART i get this NotFoundHttpException in RouteCollection.php line 161: please help
@haytham6776
@haytham6776 6 жыл бұрын
in the getCart function i got Undefined variable: oldCart as error even tho it works in in getAddcart() i don't know why ?and by the way why did you type 'as'=>'product.shoppingCart' and not shop.shoppingCart
@arslanjaved5625
@arslanjaved5625 7 жыл бұрын
after adding span into this file, no item is incrementing. Suggestion pleaase. Table cart {{ Session::has('cart') ? Session::get('cart')->totalQty : ''}}
@tutorialsviewers1381
@tutorialsviewers1381 7 жыл бұрын
items no not increasing in badge . I had checked for many time but could no fix . why ??? please suggest........
@rohailbutt4223
@rohailbutt4223 4 жыл бұрын
Hello Sir , How can i delete an item from a session ????
@LouisPierreBeatsChan
@LouisPierreBeatsChan 5 жыл бұрын
Functionality of it is fine but why does my page constantly refresh upon adding an item to the shopping cart? Doesn't necessarily change anything but the problem is that... that seems wrong and it doesn't do that for you :/
@oldnewsongs944
@oldnewsongs944 7 жыл бұрын
I would like to sent data to the session.How to do with ajax?
@guruzone2288
@guruzone2288 7 жыл бұрын
HI, How to make coupons for this ? What are the tables/columns needed?
@danieldixon4347
@danieldixon4347 5 жыл бұрын
Could any show the if statement instead of the span
@dp4dileep
@dp4dileep 8 жыл бұрын
how can i remove item from cart ?
@majidshah2253
@majidshah2253 3 жыл бұрын
how remove ?
@0557186558
@0557186558 8 жыл бұрын
When I click the items the quantity is not increment I followed you code line by line
@CindyK9
@CindyK9 5 жыл бұрын
Me too : ( . . . Have you by chance already fixed this problem? Because now I'm also stuck at this course.
@HansenHermanto
@HansenHermanto 7 жыл бұрын
hey i got an error Undefined variable: products (View: F:\xampp\htdocs\TugasUAS esources\views\shop\shopping-cart.blade.php) how to solve this, please reply
@shem2382
@shem2382 8 жыл бұрын
hey, how did you learn all of this is this taught on the job because i was told development is learning while on the job. were u shown these things by others or working with a group of developers?? i never could get great resources on building eCommerce platforms etc. if u have any suggestion im all ears.
@academind
@academind 8 жыл бұрын
Actually I learned all that on my own, though of course I used it in many projects and improved my skills, learned new things etc whilst working on such projects.
@shem2382
@shem2382 8 жыл бұрын
Mindspace I want to get into the web development industry as a back end developer. Any advice. And how can one manage merchandise in terms of the qty of a particular shirt and keeping inventory on a whole up to date. so when the user purchases an item it shows how much of the product is left for other customers to see. do u think this is a feature that is necessary. my apologize for asking a million questions
@muhammadherry185
@muhammadherry185 4 жыл бұрын
sorry I have watched and followh this tutorial then I got an error in my shopping-cart.blade.php like this "Invalid argument supplied for foreach()",so how I can fix this error.PLEASE HELP ME SIR thx
@yashonathreddy1810
@yashonathreddy1810 8 жыл бұрын
i Love the way you have paced the tuts ...thank you soo much
@academind
@academind 8 жыл бұрын
Awesome to hear this, thanks a lot for this great feedback! :)
@SashenMe
@SashenMe 7 жыл бұрын
How does "Reduce All" button work?
@vinceduderino9807
@vinceduderino9807 8 жыл бұрын
Hi, I'm new to your channel and I would like to thank you for those tutorials. But I've got a question/observation : Shouldn't we inject the Cart as a dependency ? The constructor of the Cart would verify if the session exists, to hydrate the object, and then the controller would only have to care about adding/removing a product, and call the method to save the Cart into the session ? " $this->cart->add([........])->save() "
@academind
@academind 8 жыл бұрын
Hi Vince, I'm happy to hear that you're liking it! You are right, injecting the Cart would be a great solution. But it's also a bit more advanced (since you need to register it with a ServiceProvider) and even though it's certainly not difficult to do, I tried to not make this tutorial too complicated.
@discoboy1500
@discoboy1500 8 жыл бұрын
Awesome video as usual, I was wondering tho At 4:32second why do we create a new cart and add the old cart in it, I mean it doesn't look like it does anything
@academind
@academind 8 жыл бұрын
Thanks for your great feedback. I get your point. I'm doing this to ensure that we will always have a valid cart and I don't have to manage its state (as I simply re-create it every time)
@mohamedamjad7594
@mohamedamjad7594 8 жыл бұрын
awesome , keeping rocking with laravel :D (Y) , notice a issue with Session, After a customer adding an item to his cart, by admin item deleted from database, even the item deleted, item will be available in session so deleted item will be available in cart, so customers may try to purchase deleted items too,, how can solve this
@joemelkinposadas2218
@joemelkinposadas2218 7 жыл бұрын
i have a problem how to resolve this issue in shopping-cart blade " Invalid argument supplied for foreach() "
@howto05
@howto05 7 жыл бұрын
did you fix this
@puji7563
@puji7563 4 жыл бұрын
???
@ahmedhussin5704
@ahmedhussin5704 7 жыл бұрын
why you didn't create cart table and make a relationship with users to fetch users product from his cart
@azeezadio1932
@azeezadio1932 8 жыл бұрын
this is the error am getting after clicking shopping cart "Invalid argument supplied for foreach() " /Sites/Shop/storage/framework/views/6b3cbb896316c71cc7625e2b1a78d16da3bc4f09.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'products' => null, 'totalPrice' => '0')) in and also invalid argument supplied, i have spent a whole day trying to debug
@academind
@academind 8 жыл бұрын
Did you compare the problematic code with mine (link in video description)? Maybe a tiny typo or something like that.
@azeezadio1932
@azeezadio1932 8 жыл бұрын
thanks soooo much....the problem was in my Cart class, my constructor was suppose to have double underscore, i kept only one ....i works well now...moreover, your videos have been really helpful
@azeezadio1932
@azeezadio1932 8 жыл бұрын
my cart numbers still shows after have logged out, until i clear in session in views...how do i solve this issue
@enricoperez9147
@enricoperez9147 8 жыл бұрын
try this: change the getLogout function inside the UserController.php like so, public function getLogout(Request $request) { Auth::logout(); $request->session()->forget('cart'); return redirect('/'); } what this does is that it removes the session cart.
@azeezadio1932
@azeezadio1932 8 жыл бұрын
thanks soo much ...it worked
@kallaldeveloper9072
@kallaldeveloper9072 8 жыл бұрын
Invalid argument supplied for foreach() (View: /home/ubuntu/workspace/resources/views/shop/shopping-cart.blade.php) Every time this error shows when I clicked on shooping cart
@ahmedmagdy6298
@ahmedmagdy6298 7 жыл бұрын
you may but $this->$items and this is wrong you need to make it $this->items
@raginipatlolla3253
@raginipatlolla3253 6 жыл бұрын
bro did u get this
@agungmaliki360
@agungmaliki360 5 жыл бұрын
How to reduce item in the shopping card?
@ashrafsaleh8654
@ashrafsaleh8654 7 жыл бұрын
You are great Developer and your explain is great
@academind
@academind 7 жыл бұрын
Thanks so much!
@AdrianMorenoGarcia
@AdrianMorenoGarcia 8 жыл бұрын
Can I use this tutorial for a real shopping project in production, there is not legal problem or something like that from the author?
@academind
@academind 8 жыл бұрын
You can do this BUT keep in mind: This is an tutorial. It's NOT optimized for security or performance. It might miss some crucial features you need in a real shop. So you will have to dive deeper into it, build up upon it on your own. I also do of course not take any legal or other responsibility.
@AdrianMorenoGarcia
@AdrianMorenoGarcia 8 жыл бұрын
Thank you, for your reply, i´ll take note from your advices!
@raginipatlolla3253
@raginipatlolla3253 6 жыл бұрын
Every tutorial listener stucked here.
@MAHOSSAN1
@MAHOSSAN1 5 жыл бұрын
Can you please upload the complete code because some of the user like me facing some problems with code
@pasanglama417
@pasanglama417 5 жыл бұрын
for the undefined variable products error in public function getCart(){ if(!Session::has('cart')){ return view('shop.shopping-cart'); } $oldCart = Session::get('cart'); $cart = new Cart($oldCart); return view('shop.shopping-cart', ['products' => $cart->items, 'totalPrice' => $cart->totalPrice]); } You may have missed the ! before Session in the if condition
@TheBasiru
@TheBasiru 8 жыл бұрын
Hey am having a problem because when I do it, it tells me that I invalid argument for foreach
@academind
@academind 8 жыл бұрын
Sounds like your variable doesn't get passed correctly from Controller to view. Make sure data is fetched and passed (posdible typos in variable names?) correctly.
@TheBasiru
@TheBasiru 8 жыл бұрын
sorry for bothering you but that's is fixed but now i get this: Invalid argument supplied for foreach()
@TheBasiru
@TheBasiru 8 жыл бұрын
hey is there by any chance you can make a video for email verification and activation after a different video. Also i was still not able to fix the previous video
@academind
@academind 8 жыл бұрын
Regarding the invalid argument: That's the same error you initially posted, right? See my answer regarding this, you may also have a syntax error in your @foreach loop (=> Syntax i @foreach($elements as $element)) Regarding your suggestion: I'll see what I can do, but for the near future, I have no such plans. Definitely might be something I'll have a look at in a few months
@TheBasiru
@TheBasiru 8 жыл бұрын
+Mindspace thank you very much, you are best, you were right, it was a syntax error.
@euphoria3148
@euphoria3148 6 жыл бұрын
why dropdown isn't working in my case. I tried everything.Plz Help.....
@dhanashreedeshpande7100
@dhanashreedeshpande7100 5 жыл бұрын
Same problem I have got. I am using Laravel 5.7
@majidshah2253
@majidshah2253 3 жыл бұрын
sir totalprice not working sir what i do now?
@MAHOSSAN1
@MAHOSSAN1 5 жыл бұрын
When I click the items the quantity is only increment once why ?
@leonardvictorio5616
@leonardvictorio5616 5 жыл бұрын
public function getAddToCart(Request $request, $id) { $product = Product::find($id); $cart = Session::has('cart') ? Session::get('cart') : null; if(!$cart) { $cart = new Cart($cart); } $cart->add($product, $product->id); Session::put('cart', $cart); // dd($request->session()->get('cart')); return redirect()->route('get-index'); } Try this modified code; this works on me.
@MAHOSSAN1
@MAHOSSAN1 5 жыл бұрын
@@leonardvictorio5616 what was laravel version did you use ?
@MAHOSSAN1
@MAHOSSAN1 5 жыл бұрын
@@leonardvictorio5616 Thank you but the code you have , this is only increase the value once but when the ad to cart button clicked twice . Its showing errors Call to undefined method App\Cart::items()
@leonardvictorio5616
@leonardvictorio5616 5 жыл бұрын
@@MAHOSSAN1 I'm using Laravel 6. Regardless of the version, the codes should work the same.
@leonardvictorio5616
@leonardvictorio5616 5 жыл бұрын
@@MAHOSSAN1 Mine works perfectly fine, i can add multiple times if i want to and even when i click on the button twice. Check your functions on your controller, you must have missed something.
@irfiali199
@irfiali199 6 жыл бұрын
how to edit cart, have you video on that?
@irfiali199
@irfiali199 6 жыл бұрын
sorry, its last tutorial video, i skip that,
@yashonathreddy1810
@yashonathreddy1810 8 жыл бұрын
Iam getting an error saying Undefined Variable $products line 9 or 8 (whatever ) in shopping-cart.php
@academind
@academind 8 жыл бұрын
Maybe you're not passing it from your controller? Or a typo in the name (either in the view or in the controller)
@jatinparekh2094
@jatinparekh2094 5 жыл бұрын
hello sir, can you help me for solved "Invalid argument supplied for foreach()"
@CindyK9
@CindyK9 5 жыл бұрын
Put the foreach code inside another if statement that checks whether the $products is of type array? So @if(is_array($products) ...foreach code here... @endif. Hope it helps
@haritong3687
@haritong3687 3 жыл бұрын
@@CindyK9 I have the same error could you please help?
@CindyK9
@CindyK9 3 жыл бұрын
@@haritong3687 check if the variable in your foreach code is actually of type array or not. I found out that mine was not an array but an object. Check if $product isof type array like Jatin Parekh described above
@haritong3687
@haritong3687 3 жыл бұрын
@@CindyK9 Thank you finally solved it.
@FaisalArif77
@FaisalArif77 8 жыл бұрын
Awesome tutorials as always. Following your angular2 CLi tutorials also, I have a query to ask you. how to reduce /remove specific item from shopping cart? i tried Session::forget('cart',['items'=>$id]) but it deleted my whole cart. can u please describe this functionality.? I am fan of your level of describing each and every thing. :) (y) good work . Keep it up.
@academind
@academind 8 жыл бұрын
I will shows this in one of the later videos :)
@FaisalArif77
@FaisalArif77 8 жыл бұрын
i have done this on my own by constantly searching working from 3 hours. :( u should check this our bro, in Cart.php file. public static function remove($item,$id){ if(Session::has('cart')){ $cart=Session::get('cart'); $products=$cart->items; if(array_key_exists($id,$products)){ if($products[$id]['qty']>1){ $cart->totalQty--; $cart->totalPrice=$cart->totalPrice-$item->price; $products[$id]['qty']--; $products[$id]['price']-=$item->price; }else { unset($products[$id]); $cart->totalQty--; $cart->totalPrice = $cart->totalPrice - $item->price; } } $newCart=new Cart($cart); $newCart->totalQty=$cart->totalQty; $newCart->totalPrice=$cart->totalPrice; $newCart->items=$products; return $newCart; } } // and using this as per add function but calling it as static. in productController $cart=Cart::remove($product,$product->id); Session::put('cart', $cart);
@FaisalArif77
@FaisalArif77 8 жыл бұрын
thanks for your efficient help dear :) Keeeeep it up. You just explore things in very beautifull way.
@academind
@academind 8 жыл бұрын
Thanks so much! :)
@mohdsuhailin8403
@mohdsuhailin8403 5 жыл бұрын
I am getting this error Undefined property: App\Cart::$items how to solve it?? plz reply
@danieldixon4347
@danieldixon4347 5 жыл бұрын
make it is define in the controller
@gabrielstarling526
@gabrielstarling526 8 жыл бұрын
Hey, im writting a bot for discord using node js, im currently writing it with notepad++ but so far i was only able to make him do simple things like respond to a command with a string, for example "!hi" would give you "hello there". I'd like to incorporate functions to it, for example, if i said "!list", i want it to give me a list from 1 to 10, which is easy in java using "for", but if i write the "for" in notepad++ and then run the bot with it it says "unexpected token 'for' " in my command prompt and the bot doesn't work... Could you tell me how i can incorporate java functions like that to a bot? Ps: thanks for the vids, they are awesome :)
@gonzalopolo9520
@gonzalopolo9520 8 жыл бұрын
ty again, I'm building my father's shop page, and this is just exactly what I need. I'd like to know if you will implement some kind of search bar, to wait for your explanation in the next videos, or look for it somewhere else Thank you again!
@academind
@academind 8 жыл бұрын
Hi Gonzalo, I'll focus on the checkout process next and thereafter I'll see what to add. I'm very happy that you're enjoying the videos! :)
@amjadiqbal5353
@amjadiqbal5353 6 жыл бұрын
your source code on github is totally blank , can you tell me the reason
@academind
@academind 6 жыл бұрын
Maybe you picked the wrong branch? Make sure to choose the correct one
@amjadiqbal5353
@amjadiqbal5353 6 жыл бұрын
one more thing , i was adding product on my product using ajax request without reloading the page , but ajax post request not work all the times , it send back an 500 internal server Error , thats why i try to copy your code , but your code is only adding one item on the cart , because session()->put() over riding my next product item , so that's why i am only getting 1 product in my cart every time
@FlaFans
@FlaFans 7 жыл бұрын
Hi Max, where is the project code? I downloaded gitHub but it is not complete!
@academind
@academind 7 жыл бұрын
It is - make sure to pick the right branch
@FlaFans
@FlaFans 7 жыл бұрын
hmmmm ... nice! I found! Could you make a playlist of a laravel classified website? Thank you from Brazil
@mikechannie
@mikechannie 7 жыл бұрын
This is a great tutorial. Im going to buy your tutorials on udemy soon. I have a problem as a lot of people here below. I am using laravel 5.3, but the amount of the shoppingcart is not increasing. Can you help ?
@academind
@academind 7 жыл бұрын
I'll be happy to welcome you on Udemy, too. There could be many reasons for this issue but that's why I do provide my code (link in video description, choose the right branch) for download. By comparing it to yours, you should be able to find out what goes wrong and what causes this behavior.
@yevgenletin5531
@yevgenletin5531 8 жыл бұрын
I have problem When I click shopping card happening server internal error:500
@mdhemelrana8282
@mdhemelrana8282 8 жыл бұрын
sir, please complete this series as soon as possible. i'm waitting your next videos. pls pls pls.....
@academind
@academind 8 жыл бұрын
I'll keep the videos coming, but it takes some time, sorry ;)
@TheAekalam
@TheAekalam 7 жыл бұрын
the quantity does not increment,,plz what is the wrong?
@nontonulang4852
@nontonulang4852 6 жыл бұрын
help me. how to remove item in cart ?
@abdelilahamanzou4698
@abdelilahamanzou4698 6 жыл бұрын
did you solve this issue
@pranavpawar7792
@pranavpawar7792 8 жыл бұрын
I'am getting the error as: Undefined index: title (View: C:\xampp\htdocs\Projects\laravel\project esources\views\shop\shopping-cart.blade.php).... Please Help!!!!
@Hal-co8wc
@Hal-co8wc 7 жыл бұрын
Did you add this"@extends('layouts.master')" above the page?
@sheerasai5948
@sheerasai5948 6 жыл бұрын
check your product model and see what you have named for the product title
@guruzone2288
@guruzone2288 7 жыл бұрын
Cant people hack with JavaScript and change price of product and get into payment page?
@academind
@academind 7 жыл бұрын
The frontend (JS) can only be tricked, that's why you should always validate/ check inputs on the backend, too.
@umerrasheed3
@umerrasheed3 5 жыл бұрын
video is edited suddenly start working as a Ajax request even he is call route directly
@alessagelespi1781
@alessagelespi1781 8 жыл бұрын
Very high quality lessons. I would like to see more new videos in your performance
@academind
@academind 8 жыл бұрын
There are plenty of videos to come, I'm happy that you're liking my content :)
@keithcarrillo8238
@keithcarrillo8238 6 жыл бұрын
If your cart quanity is not incrementing make sure you have all three things checked #1 the view is passing the id #2 do the same for the route they're both in his last video. #3 Make sure the product controller looks something like this in 5.5 or higher. namespace App\Http\Controllers; use App\Product; use Illuminate\Http\Request; use App\Http\Requests; use App\Cart; class ProductController extends Controller { public function getIndex() { $products = Product::all(); return view('shop.index')->with('products', $products); } public function getAddToCart(Request $request, $id){ $product = Product::find($id); $oldCart = $request->session()->has('cart') ? $request->session()->get('cart') : null; // ^^^ The session code was throwing my code off. I know now I can use $request->session()->has('cart') $cart = new Cart($oldCart); $cart->add($product, $product->id); $request->session()->put('cart', $cart); return redirect()->route('product.index'); } }
@arturofloresmontalvo9618
@arturofloresmontalvo9618 7 жыл бұрын
I have this error does anyone have the solution? Invalid argument supplied for foreach() (View: /var/www/html/TPShop/resources/views/shop/shopping-cart.blade.php)
@puji7563
@puji7563 4 жыл бұрын
Hello did you fix it?
@PerryPalmtree
@PerryPalmtree 6 жыл бұрын
Where is 'cart' defined and what is the actual value of that whole thing? {{Session::has('cart') ? Session::get('cart')->totalQty : ""}}
@Z00599
@Z00599 5 жыл бұрын
The cart defined in the productController, you have to use the Cart object as well
@ishraqemanjur5314
@ishraqemanjur5314 8 жыл бұрын
hey max ,can you provide the full source code of that project ??
@academind
@academind 8 жыл бұрын
You can find a link to the full source code in the video description.
@ishraqemanjur5314
@ishraqemanjur5314 8 жыл бұрын
in github link , its not full
@academind
@academind 8 жыл бұрын
Sure it is, make sure to pick the right branch.
@ishraqemanjur5314
@ishraqemanjur5314 8 жыл бұрын
tnx mate
@dumiduchannel5684
@dumiduchannel5684 8 жыл бұрын
I really like this tutorial, very helpful to me. thank you :) But I have problems when I implement it into laravel 5.3 But when I click add to cart button, totalQty not want to change, what's the solution? And I think I've been with that I did my model: public function add($item, $id) { $storedItem = ['qty' => 0, 'price' => $item->price, 'item' => $item]; if ($this->items) { if (array_key_exists($id, $this->items)){ $storedItem = $this->items[$id]; } } $storedItem['qty']++; $storedItem['price'] = $item->price * $storedItem['qty']; $this->items[$id] = $storedItem; $this->totalQty++; $this->totalPrice += $item->price; } my controller: public function getAddToCart (Request $ request, $ id) { $ Product = Product :: find ($ id); $ OldCart = Session :: has ( 'cart')? Session :: get ('cart'): null; $ Cart = new Cart ($ oldCart); $ Cart-> add ($ product, $ product-> id); $ Request-> session () -> put ('cart', $ cart); return redirect () -> route ('toko.index'); } and my header: {{Session :: has ( 'cart')? Session :: get ('cart') -> totalQty: ''}}
@sidheart514
@sidheart514 7 жыл бұрын
i think you forget to push your data to github i didn't find any file u have created its blank laravel 5.2
@sidheart514
@sidheart514 7 жыл бұрын
i already did
@shahrukh631
@shahrukh631 7 жыл бұрын
For all of those who are having trouble in items 'qty' increment, it is because of dd() function. I dont know why its working on laravel 5.2 but its certainly is not working on 5.4. For more details checkout this answer at stack stackoverflow.com/questions/23917409/laravel-session-data-not-sticking-across-page-loads Instead of dd(), do 1. temporarily comment out return statement 2. instead of dd() use var_dump or print_r 3. after you are satisfied that session is working, uncomment the return statement.
@amjadc
@amjadc 8 жыл бұрын
I spent 5 hours on only single error. Looked at the whole code and re wrote everything. In the end I found that I was only missing ')' this bracket =D
@academind
@academind 8 жыл бұрын
Always annoying things like these ;-) Happy to hear you were able to resolve it! :)
@vinodivv2917
@vinodivv2917 7 жыл бұрын
Invalid argument supplied for foreach() ...anyone help me............laravel 5.3
@howto05
@howto05 7 жыл бұрын
did you fix this?
@sultanworks3241
@sultanworks3241 4 жыл бұрын
@@howto05 i have same problem
@ethanwang4917
@ethanwang4917 6 жыл бұрын
Haha, I can get that feeling, each time the modified app directly and properly run, it likes I win the lottery
@noumanmayo2601
@noumanmayo2601 7 жыл бұрын
Invalid argument supplied for foreach() (View: C:\xampp\htdocs\shopping-car esources\views\shop\shopping-cart.blade.php)
@howto05
@howto05 7 жыл бұрын
did you fix this
@AhmedElhadyEG
@AhmedElhadyEG 8 жыл бұрын
Source Code not complete !
@academind
@academind 8 жыл бұрын
Yes it is, pick the right branch
@janardhanreddy6900
@janardhanreddy6900 6 жыл бұрын
please respond for comments Session value is not responding
@academind
@academind 6 жыл бұрын
You can always download my source code (link in video description, make sure to pick the right branch there). This should allow you to narrow down where your code differs and what's causing the issue
@shakinahazmansa
@shakinahazmansa 7 жыл бұрын
hey guys. if you guys have the same problem as me on increment quantity on the shopping cart, you could try to change the $oldCart and Session. somehow i dont know why or whats the reason of changing the codes make it work. try to view my codes and try to apply it okay. BTW im using Laravel 5.4. change in your ProductController.php the // is the codes from the tutorial i comment it so that you can know which one that i change. Good luck! public function getAddToCart(Request $request, $id){ $product = Product::find($id); $cart = Session::has('cart') ? Session::get('cart') : null; //$cart = new Cart($oldCart); if(!$cart) { $cart = new Cart($cart); } //$product = $product->id; $cart->add($product, $product->id); Session::put('cart', $cart); //$request->session()->put('cart', $cart); //var_dump($request->session()->get('cart')); return redirect()->route('products.index'); }
@rezagunawan231
@rezagunawan231 7 жыл бұрын
thanks it works
@joemelkinposadas2218
@joemelkinposadas2218 7 жыл бұрын
how to change need help pls reply;
@sitta241138
@sitta241138 6 жыл бұрын
thank it works (Laravel Framework 5.5.33)
@thereportserverid5196
@thereportserverid5196 8 жыл бұрын
Thank you so much for make awesome tutorial.
@academind
@academind 8 жыл бұрын
Great to hear you liked it!
@7footballvideos220
@7footballvideos220 6 жыл бұрын
you're amazing heeeeeeey, thanks maaaaaaaaaan
@jonarendra
@jonarendra 5 жыл бұрын
nice tutorial.. thanks...
@academind
@academind 5 жыл бұрын
Thank you Putu!
@janardhanreddy6900
@janardhanreddy6900 6 жыл бұрын
Great tutorial....
@academind
@academind 6 жыл бұрын
Thank you Janardhan :)
@GravityGamingCo
@GravityGamingCo 8 жыл бұрын
the model the cart model confused me a little bit on how you are storing everything. I know how sessions work and such but this is just confusing me. Get tutorial series as always though!
@academind
@academind 8 жыл бұрын
I hope the confusion will go away once you see in action a bit more. Basically the model simply is an abstraction of the shopping cart and should be able to handle new items as well existing shopping carts being passed into it.
@mehtabhabib
@mehtabhabib 8 жыл бұрын
#awesome... many thanks for the tutorials... you are doing an amazing job mate... :-)
@academind
@academind 8 жыл бұрын
Many, many thanks for those very kind words Mehtab, I'm happy that this is helpful to you! :)
@joemelkinposadas2218
@joemelkinposadas2218 7 жыл бұрын
I cant solve it :( and i'm so exhausted
@sultanworks3241
@sultanworks3241 4 жыл бұрын
ErrorException Invalid argument supplied for foreach() (View: F:\server\htdocs\yii\yumypizza esources\views\shop\shopping-cart.blade.php)
@sultanworks3241
@sultanworks3241 4 жыл бұрын
Help?
@sultanworks3241
@sultanworks3241 4 жыл бұрын
on line 15 @foreach($products as $product)
@moroccanfirst236
@moroccanfirst236 3 жыл бұрын
@if(!empty($products) @foreach($products as $product) //code here @endforech @endif
@yashonathreddy1810
@yashonathreddy1810 8 жыл бұрын
@foreach( $products as $product) {{ $product['qty'] }} {{ $product['item']['title'] }} {{ $product['price'] }} this is what iam doing in view
@pranavpawar7792
@pranavpawar7792 8 жыл бұрын
Hi, yashonath reddy.... I'am getting the error in shopping-cart.blade.php as follows: Undefined index: title (View: C:\xampp\htdocs\Projects\laravel\project esources\views\shop\shopping-cart.blade.php)..... Please See if you can solve it!!!!
@yashonathreddy1810
@yashonathreddy1810 8 жыл бұрын
check your database table and verify the column name "title"
@pranavpawar7792
@pranavpawar7792 8 жыл бұрын
Thanks for your response.... I have done as you said... but, the error still persists,I have also cross-checked with the code from the video.... but, still its not rectified... The error appears when I write the following code in shop.blade.php -> {{ $product['item']['title'] }}... see the 4th line of your code above... Please see again and thanks in advance
@yashonathreddy1810
@yashonathreddy1810 8 жыл бұрын
pranav pawar....I got to see what your doing in controller
@pranavpawar7792
@pranavpawar7792 8 жыл бұрын
ya surely.... I'am pasting the code here and see where I've mistaken. The code under ProductController.php is as follows:
@yashonathreddy1810
@yashonathreddy1810 8 жыл бұрын
public function getCart(){ if (Session::has('cart')){ return view('shop.shoppingcart'); } $oldCart = Session::get('cart'); $cart = new Cart($oldCart); return view('shop.shoppingcart', ['products' => $cart->items, 'totalPrice' => $cart->totalPrice]); } this is the method in controller
@Velasco622
@Velasco622 6 жыл бұрын
The number of items in my cart was sometimes not updating when adding a new product, but I fixed it by adding: Session::save(); to getAddToCart(), right after I call Session::put('cart', $cart); Apparently, Session::put() doesn't save right away: stackoverflow.com/questions/23917409/laravel-session-data-not-sticking-across-page-loads here's the entire function: public function getAddToCart(Request $request, $id) { $product = Product::find($id); $oldCart = Session::has('cart') ? Session::get('cart') : null; $cart = new Cart($oldCart); $cart->add($product, $product->id); Session::put('cart', $cart); Session::save(); return redirect('/products'); }
@pawan9702
@pawan9702 5 жыл бұрын
Thanks
@sauliussaulys8035
@sauliussaulys8035 6 жыл бұрын
to solve foreach problem delete $cart = new Cart($oldCart); from ProductControler.php and change $Cart to $oldCart
@sauliussaulys8035
@sauliussaulys8035 6 жыл бұрын
Great that helps
@sauliussaulys8035
@sauliussaulys8035 6 жыл бұрын
thx, broooooooo
@shahrukh631
@shahrukh631 7 жыл бұрын
As for all those having this error Undefined index: title Its because of foreach It should be like this foreach($products->items as $product) The rest of the code is same.
@haritong3687
@haritong3687 3 жыл бұрын
Im having an error to foreach please help
@joemelkinposadas2218
@joemelkinposadas2218 7 жыл бұрын
pls reply :(
@raginipatlolla3253
@raginipatlolla3253 6 жыл бұрын
please respond
@yoonastk3042
@yoonastk3042 7 жыл бұрын
when i click product..not increment cart item..my product name are so diffrent..plz help..
@FreeDarkDemon
@FreeDarkDemon 7 жыл бұрын
how do you delete a item from the car?
I built 10 web apps... with 10 different languages
14:23
Fireship
Рет қаралды 1,7 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Please stop using px for font-size.
15:18
Coder Coder
Рет қаралды 247 М.
You might not need useEffect() ...
21:45
Academind
Рет қаралды 177 М.
Laravel Language Switcher
27:58
Andre Madarang
Рет қаралды 88 М.
🤯 Express.js 5 is here (since a month already, actually)
9:58
Laravel "Add to Cart": With/Without Livewire [LIVE-CODING]
24:37
Laravel Daily
Рет қаралды 50 М.
7 ways to deal with CSS
6:23
Fireship
Рет қаралды 1,1 МЛН
I built the same app 10 times // Which JS Framework is best?
21:58
Fireship
Рет қаралды 2,6 МЛН
100+ Web Development Things you Should Know
13:18
Fireship
Рет қаралды 1,6 МЛН
⚡️NEWS | UNITED RUSSIA OFFICE AND ATMS BURNED DOWN | COMPLAINING TO PUTIN ABOUT GREF
9:14
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН