title: PHP/Laravel 9 Call to undefined method
body: <p>I have a problem with my check function for data validation and i get the error</p>
  <pre><code>Call to undefined method App\Models\Product::check()
  </code></pre>
  <p>I use the Laravel framework for programming.</p>
  <p>These are the methods, that i use for storing and updating my data.</p>
  <pre><code>public function store(Product $product)
      {
          Product::create($product-&gt;check())-&gt;save();
  
          return redirect('/');
      }
  
  public function update(Product $product)
      {
          $product-&gt;update($this-&gt;check());
  
          return redirect('/');
      }
  </code></pre>
  <p>This is my validation Function. all are in the same controller.</p>
  <pre><code>protected function check()
      {
          if (request()-&gt;Produkt == 'Kuhli' || request()-&gt;Produkt == 'Warmi')
          {
              switch (request()-&gt;Produkt) {
                  case 'Kuhli':
                      $data = Validation::where('id', '=', '1')-&gt;get();
                      $PHmax = $data[0]-&gt;PHmax;
                      $PHmin = $data[0]-&gt;PHmin;
                      $Wassermax = $data[0]-&gt;Wassermax;
                      $Wassermin = $data[0]-&gt;Wassermin;
                      $Dichtemax = $data[0]-&gt;Dichtemax;
                      $Dichtemin = $data[0]-&gt;Dichtemin;
                      return request()-&gt;validate([
                          'LieferNr' =&gt; ['required', 'min:5', 'max:5'],
                          'Produkt' =&gt; 'required',
                          'PH' =&gt; ['required', 'numeric', &quot;min:$PHmin&quot;, &quot;max:$PHmax&quot;],
                          'Wasser' =&gt; &quot;required|numeric|min:$Wassermin|max:$Wassermax&quot;,
                          'Dichte' =&gt; &quot;required|numeric|min:$Dichtemin|max:$Dichtemax&quot;,
                          'Bearbeiter' =&gt; 'required',
                      ]);
                  case 'Warmi':
                      $data = Validation::where('Produkt', '=', 'Warmi')-&gt;get();
                      $PHmax = $data[0]-&gt;PHmax;
                      $PHmin = $data[0]-&gt;PHmin;
                      $Wassermax = $data[0]-&gt;Wassermax;
                      $Wassermin = $data[0]-&gt;Wassermin;
                      $Dichtemax = $data[0]-&gt;Dichtemax;
                      $Dichtemin = $data[0]-&gt;Dichtemin;
                      return request()-&gt;validate([
                          'LieferNr' =&gt; ['required', 'min:5', 'max:5'],
                          'Produkt' =&gt; 'required',
                          'PH' =&gt; ['required', 'numeric', &quot;min:$PHmin&quot;, &quot;max:$PHmax&quot;],
                          'Wasser' =&gt; &quot;required|numeric|min:$Wassermin|max:$Wassermax&quot;,
                          'Dichte' =&gt; &quot;required|numeric|min:$Dichtemin|max:$Dichtemax&quot;,
                          'Bearbeiter' =&gt; 'required',
                      ]);
              }
          } else {
              echo('Produktname ist falsch');
              return redirect()-&gt;back();
          }
      }
  </code></pre>
  <p>those are my uses</p>
  <pre><code>use App\Models\Validation;
  use Illuminate\Http\Request;
  use App\Models\Product;
  use PhpParser\Node\Stmt\If_;
  </code></pre>
  <p>I dont know why I get this error and would be glad if I could get any help.</p>