title: Laravel controller won't let me passing data as a json for with the error : Call to a member function withData() on string
body: <p>hi guys im stuck here i dont know whay i cant send json data with a laravel controller.</p>
  
  <p>controller : </p>
  
  <pre><code>        $data =  DB::table('users')
          -&gt;where('id','=',$id)
          -&gt;get();
  
          // dd($data);Working perfectly
          return '/medcine/homeMS'-&gt;withData(json_encode($data));//error in this line
  </code></pre>
  
  <p>my route :</p>
  
  <pre><code>Route::get('/medcine/homeMS', function () {
  return view('auth.medcine.homeMS');
  })-&gt;middleware('verified')-&gt;middleware('medcineMS');
  </code></pre>
  
  <p>and in my blade i added this line :</p>
  
  <pre><code>        &lt;div data={{$data}} &gt;&lt;/div&gt;
  </code></pre>