title: Laravel 5 if condition not working on last condition (else)
body: <p>I have a text field <code>status-text</code> that allows users to submit their statuses.</p>
  
  <p>I also have an image upload field to add a picture to the status.</p>
  
  <p>In my if condition, I am checking first to see if the input has any data, then I check if the input has an image AND validator doesn't fail, then I check if validator doesn't fail (to submit a status without an image), at the end I do an <code>else</code> which is supposed to be "if input doesn't have any data"</p>
  
  <p>The first 3 checks are working but the last <code>else</code> is not. Apparently the code is not reaching that final else for some reason.</p>
  
  <p>This is the view</p>
  
  <pre><code>@if (count($errors) &gt; 0)
          &lt;div class="alert alert-danger"&gt;
              &lt;ul&gt;
                  @foreach ($errors-&gt;all() as $error)
                      &lt;li&gt;{{ $error }}&lt;/li&gt;
                  @endforeach
              &lt;/ul&gt;
          &lt;/div&gt;
  @endif
  @include('partials/flash')
  &lt;div class="row"&gt;
          &lt;div class="col-md-12"&gt;
              {!! Form::open(['files' =&gt; true]) !!}
              &lt;div class="panel panel-default"&gt;
                  &lt;div class="panel-heading"&gt;Add New Status&lt;/div&gt;
  
                  &lt;div class="panel-body"&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label for="status-text"&gt;Write Something&lt;/label&gt;
                          &lt;textarea class="form-control" name="status-text" id="status-text"&gt;&lt;/textarea&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="panel-footer clearfix"&gt;
                      &lt;div class="row"&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;label for="file-upload" class="custom-file-upload"&gt;
                                  &lt;i class="fa fa-image"&gt;&lt;/i&gt;
                              &lt;/label&gt;
                              &lt;input id="file-upload" name="status_image_upload" type="file"&gt;
                          &lt;/div&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;button class="btn btn-info btn-sm pull-right"&gt;&lt;i class="fa fa-plus"&gt;&lt;/i&gt; Add Status&lt;/button&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
      &lt;/div&gt;
      {!! Form::close() !!}
  </code></pre>
  
  <p>And this is <code>FeedController@index</code></p>
  
  <pre><code>if($request-&gt;has('status-text')) {
          $text = Input::get('status-text');
  
          $rules = [
              'status-text' =&gt; 'required|string'
          ];
  
          $validator = Validator::make($request-&gt;all(), $rules);
  
          if($request-&gt;hasFile('status_image_upload') &amp;&amp; !$validator-&gt;fails()) {
              $image = $request-&gt;file('status_image_upload');
  
              $imageName = str_random(8) . '_' . $image-&gt;getClientOriginalName();
              //$imageFull = str_random(8) . '_' . $image-&gt;getClientOriginalName();
  
              $image-&gt;move('uploads/status_images', $imageName);
  
              $userStatus = new Status;
              $userStatus-&gt;status_text = $text;
              $userStatus-&gt;image_url = $imageName;
              $userStatus-&gt;type = 1;
              $userStatus-&gt;user_id = Auth::user()-&gt;id;
              $userStatus-&gt;save();
              flash('Your status has been posted');
  
              return redirect(route('feed'));
          } elseif(!$validator-&gt;fails()) {
              $userStatus = new Status;
              $userStatus-&gt;status_text = $text;
              $userStatus-&gt;user_id = Auth::user()-&gt;id;
              $userStatus-&gt;save();
              flash('Your status has been posted', 'success');
  
              return redirect(route('feed'));
          } else {
              $messages = $validator-&gt;errors();
              return redirect(route('feed'))-&gt;withErrors($messages);
          }
  </code></pre>
  
  <p>I have tried using <code>if($validator-&gt;fails())</code> - it didn't work.
  I have also tried returning a simple string <code>return 'field cannot be empty';</code> just to test it out, it doesn't work either.</p>
  
  <p>I have the same code running for <code>post_comment</code> and it works for the <code>else</code>, so if I leave the comment field empty and submit it, I get redirected to the feed page with an error message saying the field cannot be empty.</p>
  
  <p><strong>THIS WORKS</strong></p>
  
  <pre><code>if(Input::has('post_comment')) {
          $rules = [
              'comment-text' =&gt; 'required|string'
          ];
  
          $validator = Validator::make($request-&gt;all(), $rules);
  
          if(!$validator-&gt;fails()) {
              $status = Input::get('post_comment');
              $commentBox = Input::get('comment-text');
              $selectedStatus = Status::find($status);
  
              $selectedStatus-&gt;comments()-&gt;create([
                  'comment_text' =&gt; $commentBox,
                  'user_id' =&gt; Auth::user()-&gt;id,
                  'status_id' =&gt; $status
              ]);
  
              flash('Your comment has been posted', 'success');
  
              return redirect(route('feed'));
          } else {
              $messages = $validator-&gt;errors();
              return redirect(route('feed'))-&gt;withErrors($messages);
          }
      }
  </code></pre>
  
  <p>I am not sure what else to try.</p>