title: Laravel 5 Validation in controller
body: <p>I have 2 methods in my Controller and I need to validate it but I don't know how.</p>
  
  <p>1st method which should allow all image extensions:</p>
  
  <pre><code>public function testing(Request $request) {
      if($request-&gt;hasFile('img')) {
          $image = Input::file('img');
          $filename = time() . '.' . $image-&gt;getClientOriginalExtension();
          $path = public_path('images/' . $filename);
          Image::make($image-&gt;getRealPath())-&gt;resize(200, 200)-&gt;save($path);
          $file = $request-&gt;file('img');
          return ['url' =&gt; url('images/' . $filename)];
      }
  }
  </code></pre>
  
  <p>2nd method which should only allow 1 word and if there is space, trim it into 1 word:</p>
  
  <pre><code>public function postDB(Request $request) {
      $newName = $request-&gt;input('newName');
      $websites = new Website();
      $websites-&gt;name = $newName;
      $websites-&gt;save();
      return redirect('template')-&gt;with('status', 'Website has been saved successfully!');
  }
  </code></pre>