title: Shared data for GET and POST methods of one route in Laravel 5
body: <p>My projects POST routes usually makes the same view on its GET version routes.</p>
  
  <p>So POST route (controller) must pass the same data to the same view.</p>
  
  <p>Is there any way to tell Laravel in POST route add some data to the same data which GET route passes?</p>
  
  <p>I think it's me that is on the wrong way and there must be a better way.</p>
  
  <p>For example see the following common data that both GET and POST methods pass to the view. In this example there is no much data but usually there are.</p>
  
  <pre><code>/**
   * @Route('/cp/users')
   *
   * @return \Response
   */
  public function getUsers() {
      $users = User::all();
      $roles = ["admin", "personnel"];
      return view('cp.users', ['users' =&gt; $users, 'roles' =&gt; $roles]);
  }
  
  /**
   * @Route('/cp/users') POST
   * @param \Illuminate\Http\Request $request
   *
   * @return \Illuminate\Support\MessageBag
   */
  public function postUsers(Request $request) {
      $users = User::all();
      $roles = ["admin", "personnel"];
      $rules = [
          'name'     =&gt; 'required',
          'surname'  =&gt; 'required',
          'email'    =&gt; 'required|email|unique:users',
          'password' =&gt; 'required|min:6',
          'role'     =&gt; 'required|in:admin,personnel'
      ];
      $validator = Validator::make((array)$request, $rules);
      if ($validator-&gt;fails()) {
          return view('cp.users', ['errors' =&gt; $validator-&gt;errors(), 'users' =&gt; $users, 'roles' =&gt; $roles]);
      }
      return view('cp.users', ['users' =&gt; $users, 'roles' =&gt; $roles]);
  }
  </code></pre>
  
  <p>I do it this way:</p>
  
  <pre><code>/**
   * @Route('/cp/users') POST
   * @param \Illuminate\Http\Request $request
   *
   * @return \Illuminate\Support\MessageBag
   */
  public function postUsers(Request $request) {
      $rules = [
          'name'     =&gt; 'required',
          'surname'  =&gt; 'required',
          'email'    =&gt; 'required|email|unique:users',
          'password' =&gt; 'required|min:6',
          'role'     =&gt; 'required|in:admin,personnel'
      ];
      $validator = Validator::make((array)$request, $rules);
      if ($validator-&gt;fails()) {
          View::share('errors', $validator-&gt;errors());
      }
      return $this-&gt;getUsers();
  }
  </code></pre>