title: ArgumentCountError Too few arguments to function App\Http\Controllers\Shop\CartController::addToCart()
body: <p>So this function is supposed to add the product into a cart, but i've been getting the error</p>
  <blockquote>
  <p>Too few arguments to function
  App\Http\Controllers\Shop\CartController::addToCart(), 0 passed in
  C:\xampp\htdocs\nerdS\vendor\laravel\framework\src\Illuminate\Routing\Controller.php
  on line 54 and exactly 1 expected</p>
  </blockquote>
  <p>I tried changing key words here and there on my controller, but nothing seems to do it. This is the the controller:</p>
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers\Shop;
  
  use App\Http\Controllers\Controller;
  use Illuminate\Http\Request;
  Use App\Models\Product;
  Use App\Models\Order;
  
  class CartController extends Controller {
      public function placeOrder() {
          if(session('id')){
              if(\Cart::count()){
              \App\Models\Order::store();
              return redirect('shop')-&gt;with('status', 'Thank you for buying!');
              }
                  return redirect('cart');
              }
              session(['place-order-process' =&gt; true]);
              return redirect('login')-&gt;with('status', 'To complete your order, please log in. Not a member yet? &lt;a href=&quot;'.url('signup') . '&quot;&gt; Join the club! &lt;/a&gt;');
          }
      
      public function deleteCart() {
          \Cart::destroy();
          return redirect('shop')-&gt;with('status', 'The cart is now empty.');
      }
      
      public function deleteItem($rowId) {
          \Cart::remove($rowId);
          return redirect('cart')-&gt;with('status', 'The item was deleted.');
      }
      
      public function updateCart(Request $request){
          \Cart::update($request-&gt;rowId, $request-&gt;quantity);
          $data = [
              'cart_count' =&gt;\Cart::count(),
              'cart_total' =&gt; \Cart::total(),
              'product_total' =&gt; \Cart::get($request-&gt;rowId)-&gt;total(),
          ];
          return json_encode($data);
      }
      
      public function displayCart() {
          \Cart::setGlobalTax(0);
          $data['items'] = \Cart::content();
          $data['total'] = \Cart::total();
          return view('cart.cart', $data);
      }
      
      public function addToCartByQty (Request $request){
          \App\Models\Product::addToCart($request-&gt;id, (int) $request-&gt;quantity);
          return \Cart::count();
      }
      
      public function addToCart ($id){
      \App\Models\Product::addToCart($id);
      return \Cart::count();
      }
  }
  </code></pre>
  <p>My model for products:</p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Database\Eloquent\Model;
  use Illuminate\Support\Facades\Storage;
  
  class Product extends Model {
      public function category() {
          return $this-&gt;belongsTo('App\Models\Category');
      }
      
      public static function deleteProduct($id){
          $product = self::findOrFail($id);
          Storage::disk('public')-&gt;delete($product-&gt;image);
          self::destroy($id);
          
      }
      
      public static function editProduct($request){
          $product = self::findOrFail($request-&gt;product);
          $product-&gt;name = $request-&gt;name;
          $product-&gt;slug = $request-&gt;slug;
          $product-&gt;price = $request-&gt;price;
          $product-&gt;description = $request-&gt;description;
          $product-&gt;category_id = $request-&gt;category;
          if ($request-&gt;image){
              Storage::disk('public')-&gt;delete($product-&gt;image);
              $product-&gt;image = $request-&gt;image-&gt;store('images/products', 'public');
              
          }
          $product-&gt;save();
      }
      
      public static function getProductById($id){
          return self::finOrFail($id);
      }
      
      public static function store($request){
          $product = new self();
          $product-&gt;name = $request-&gt;name;
          $product-&gt;slug = $request-&gt;slug;
          $product-&gt;price = $request-&gt;price;
          $product-&gt;description = $request-&gt;description;
          $product-&gt;category_id = $request-&gt;category;
          $product-&gt;image = $request-&gt;image-&gt;store('images/products', 'public');
          $product-&gt;save();
      }
      
      public static function getAll(){
          return self::orderBy('slug')-&gt;get();
      }
      
      public static function addToCart($id, $qty = 1){
          $product = self::findOrFail($id);
          
          \Cart::add([
              'id' =&gt; $product-&gt;id, 
              'name' =&gt; $product-&gt;name, 
              'qty' =&gt; $qty, 
              'price' =&gt; $product-&gt;price, 
              'weight' =&gt; 0
              ]);
      }
      public static function getProduct($cat, $pro){
          $product = self::where('slug', $pro)-&gt;firstOrFail();
          $product_cat = $product-&gt;category-&gt;slug;        
          //retun ($product_cat === $cat) ? $product_cat: false;
          abort_if($product_cat !== $cat, 404);
          return $product;
      }
      
      
      //use HasFactory;
  }
  </code></pre>
  <p>The page view:</p>
  <pre><code>@extends('template')
  @section('content')
  &lt;div class=&quot;row&quot;&gt;
      &lt;div class=&quot;col-md-7&quot;&gt;
          &lt;h1&gt; {{$product-&gt;name}} &lt;/h1&gt;
          &lt;p&gt;{{$product-&gt;descriprion}}&lt;/p&gt;
          &lt;p&gt; Only for: &amp;#8362; {{$product-&gt;price}}&lt;/p&gt;
          &lt;form id=&quot;add-to-cart&quot; method=&quot;post&quot; action=&quot;{{url('add-to-cart')}}&quot;&gt;
              @csrf
              &lt;div class=&quot;number&quot;&gt;
                  &lt;span class=&quot;minus&quot;&gt; - &lt;/span&gt;
                  &lt;input type=&quot;text&quot; value=&quot;1&quot; readonly/&gt;
                  &lt;span class=&quot;plus&quot;&gt; + &lt;/span&gt;
                  &lt;input type=&quot;hidden&quot; value=&quot;{{$product-&gt;id}}&quot;&gt;
                  &lt;button class=&quot;btn btn-primary&quot; type=&quot;submit&quot;&gt; Add &lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
          &lt;div class=&quot;col-md-5&quot;&gt;
              &lt;img src=&quot;{{asset('storage/' . $product-&gt;image)}}&quot;&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  @endsection
  </code></pre>
  <p>and my route:</p>
  <pre><code>Route::get('add-to-cart/{product_id}', 'App\Http\Controllers\Shop\CartController@addToCart');
  </code></pre>