title: Form submission and receipt on the same page (Laravel, php, blade)
body: <p>I don't understand why this doesn't work. Help!!!
  I need the entered value to be displayed in input after sending.</p>
  <p>TestController.php</p>
  <pre><code>class TestController extends Controller {
  
  public function form(Request $request) {
      if ($request-&gt;isMethod('get')) {
          echo 'REQUEST GET';                      
          return view('test');  
      }
      
      if ($request-&gt;isMethod('post')) {
          $text = $request-&gt;input('text');
          echo 'REQUEST POST';
          echo '&lt;br&gt;';
          echo $text;  
          return view('test', ['text', $text]);
      }
  }
  </code></pre>
  <p>test.blade.php</p>
  <pre><code>    &lt;div class=&quot;container&quot;&gt;
      &lt;div class=&quot;col-sm-offset-0 col-sm-12 {{ $CONTAINER_SETTINGS-&gt;OFFSET_MD }} {{ $CONTAINER_SETTINGS-&gt;WIDTH_MD }}&quot;&gt;
          &lt;div class=&quot;panel panel-default&quot;&gt;
              &lt;div id=&quot;header&quot; class=&quot;panel-heading&quot;&gt;
                  &lt;h4&gt;&lt;i class=&quot;fa fa-btn fa-users&quot;&gt;&lt;/i&gt;Test&lt;/h4&gt;
              &lt;/div&gt;
  
              &lt;div class=&quot;panel-body&quot;&gt;
  
                  &lt;form action=&quot;{{ url('test') }}&quot; method=&quot;POST&quot;&gt;
                      {{ csrf_field() }}
                      @if(isset($text))
                      &lt;input type=&quot;text&quot; name=&quot;text&quot; value=&quot;{{ $text }}&quot;&gt;                                      
                      @else
                      &lt;input type=&quot;text&quot; name=&quot;text&quot; &gt;                                      
                      @endif
                      &lt;input type=&quot;submit&quot;&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>web.php (routes)</p>
  <pre><code>Route::get('test', 'TestController@form');
  Route::post('test', 'TestController@form');
  </code></pre>
  <p><a href="https://i.stack.imgur.com/UUEEn.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p><a href="https://i.stack.imgur.com/4T0Sy.png" rel="nofollow noreferrer">enter image description here</a></p>