title: Undefined variable: photos (View: C:\wamp64\www\couture\resources\views\upload.blade.php)
body: <p>i want to fix the undifined variable $photos
  upload.blade.php</p>
  <pre><code>@extends('layouts.app')
  @section('content')
          &lt;h1&gt;voir les modeles&lt;/h1&gt;
              &lt;form action=&quot;/upload&quot; method=&quot;POST&quot; enctype=&quot;multipart/form-data&quot;&gt;
                  @csrf
                  &lt;input type=&quot;file&quot; name=&quot;image&quot;&gt;
                  &lt;input type=&quot;submit&quot; name=&quot;Upload&quot;&gt;
              &lt;/form&gt;
          &lt;/hr&gt;
          &lt;ul&gt;
              @foreach ($photos as $photo)
              &lt;li&gt; {{ $photo-&gt;name }}&lt;img src=&quot;{{ asset('storage/images/', $photo-&gt;name) }}&quot;&gt;&lt;/li&gt;
  
              @endforeach
          &lt;/ul&gt;
  @endsection
  </code></pre>
  <p>here is the controler photo<code>enter code here</code></p>
  <p>PhotoController</p>
  <pre><code> &lt;?php
  
  namespace App\Http\Controllers;
  
  use App\Models\Photo;
  use Illuminate\Http\Request;
  
  class PhotoController extends Controller
  {
      public function create()
      {
          $photos = Photo::all();
          return view('upload', compact('photos'));
      }
      public function store(Request $request)
      {
  
          // dd($request-&gt;file());
          $size = $request-&gt;file('image')-&gt;getSize();
          $name = $request-&gt;file('image')-&gt;getClientOriginalName();
  
          $request-&gt;file('image')-&gt;storeAs('public/images/', $name);
          $photo = new Photo();
          $photo-&gt;name = $name;
          $photo-&gt;size = $size;
          $photo-&gt;save();
  
          return redirect()-&gt;back();
       }
  }
  
  
  
  
  
  
  enter code here
  </code></pre>