title: Where to implement the logic for a simple calculator using Laravel
body: <p>I want to make a simple Laravel calculator, but I'm not sure where to define my class and where to use the functions. Do I define my class as a Model? And where do I calculate the result? Do I do it in the controller?</p>
  
  <p>Say I made a class somewhere</p>
  
  <pre><code>class Calculator
  {//other methods here...
      public function add($a, $b)
      {
          return $a + $b;
      }
  }
  </code></pre>
  
  <p>And in a certain controller I should have something like this</p>
  
  <pre><code> $a= $request-&gt;input('first');
   $b= $request-&gt;input('second');
  </code></pre>
  
  <p>But where do I define a new Calculator and make the addition? Do I do it in the same controller as well?</p>
  
  <pre><code>$calc=new Calculator();
  $result=$calc-&gt;add($a,%b);
  </code></pre>
  
  <p>This obviously goes in the controller, but do I have to do the addition somewhere else and pass it to the controller?</p>
  
  <pre><code> return view('pages.result')-&gt;with('result',$result);
  </code></pre>