title: How to show selected value in dropdown using Laravel after validation from request?
body: <p>Hi guys i'm new using laravel and I have somo problems when use a request to validate fields:</p>
  
  <ol>
  <li>Controller has two model, and load device information to dropdown:</li>
  </ol>
  
  <pre><code>    use App\Channel;  //channel model
      use App\Device;   //device model
      public function create()
      {
          return view('partials.channels.create',[
              'channel' =&gt; new Channel,
              'devices' =&gt; Device::latest()
          ]);
      }
      public function store(SaveChannelRequest $request)
      {
          Channel::create($request-&gt;validated());
          return redirect()-&gt;route('channels.index');
      }
  </code></pre>
  
  <ol>
  <li>Request "SaveChannelReques" has some rules to add information on database, validations work fine but when return error I can't load the dropdown:</li>
  </ol>
  
  <pre><code>    public function rules()
      {
          $bypass = $this-&gt;channel-&gt;id ?? "";
          $rules = [
              'channel' =&gt; 'required|unique:channels,channel,'.$bypass.',id',
              'name' =&gt; 'required|unique:channels,name,'.$bypass.',id',
              'device' =&gt; 'required',
              'description' =&gt; 'required',
              'latitude' =&gt; 'nullable',
              'longitude' =&gt; 'nullable',
              'elevation' =&gt; 'nullable',
              'field1' =&gt; 'nullable',
          ];
          return $rules;
      }
  </code></pre>
  
  <ol start="2">
  <li>View:</li>
  </ol>
  
  <pre><code>&lt;form class="bg-white shadow rounded py-3 px-4" method="POST" action="{{ route('channels.store') }}"&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="device"&gt;{{ __('Device') }}&lt;/label&gt;
      &lt;select id="device" name="device" class="form-control @error('device') is-invalid @enderror" autocomplete="device"&gt;
          &lt;option value="" selected &gt;@lang('Choose')...&lt;/option&gt;
          @foreach($devices as $device)
              &lt;option value="{{ old('device', $device-&gt;name) }}"&gt;{{ old('device', $device-&gt;name) }}&lt;/option&gt;
          @endforeach
      &lt;/select&gt;
      @error('device')
      &lt;span class="invalid-feedback" role="alert"&gt;
          &lt;strong&gt;{{ $message }}&lt;/strong&gt;
      &lt;/span&gt;
      @enderror
  &lt;/div&gt;
  &lt;div class="form-row"&gt;
      &lt;div class="form-group col-md-6"&gt;
          &lt;label for="channel"&gt;{{ __('Channel') }}&lt;/label&gt;
          &lt;input id="channel" type="text" class="form-control bg-light shadow-sm @error('channel') is-invalid @enderror" name="channel" value="{{ old('channel', $channel-&gt;channel) }}" autocomplete="channel" autofocus&gt;
          @error('channel')
          &lt;span class="invalid-feedback" role="alert"&gt;
              &lt;strong&gt;{{ $message }}&lt;/strong&gt;
          &lt;/span&gt;
          @enderror
      &lt;/div&gt;
      &lt;div class="form-group col-md-6"&gt;
          &lt;label for="name"&gt;{{ __('Name') }}&lt;/label&gt;
          &lt;input id="name" type="text" class="form-control bg-light shadow-sm @error('name') is-invalid @enderror" name="name" value="{{ old('name', $channel-&gt;name) }}" autocomplete="name" autofocus&gt;
          @error('name')
          &lt;span class="invalid-feedback" role="alert"&gt;
              &lt;strong&gt;{{ $message }}&lt;/strong&gt;
          &lt;/span&gt;
          @enderror
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <ol start="3">
  <li>Images</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/8r4x3.png" rel="nofollow noreferrer">On page load is ok</a></p>
  
  <p><a href="https://i.stack.imgur.com/pzpa8.png" rel="nofollow noreferrer">Validation fields is ok</a></p>
  
  <p><a href="https://i.stack.imgur.com/Uq84s.png" rel="nofollow noreferrer">No load data after validation request</a></p>