title: Laravel - old() helper function failed in Laravel child category select dropdown
body: <p>Currently, I am working a project select option dropdown for child category</p>
  
  <p>The select option dropdown is a foreign key from another table</p>
  
  <p>GoalController</p>
  
  <pre><code>public function create()
  {
       $categories = GoalType::with('children')-&gt;whereNull('parent_id')-&gt;get();
      $goal = new Goal();
  
      return view('goals.create')
      -&gt;with('goal', $goal)
              -&gt;with('categories', $categories)
              ;
  }
  </code></pre>
  
  <p>Goal model</p>
  
  <pre><code>class Goal extends Model
  {
  protected $fillable = [
                'id',
                'goal_type_id',
        'goal_title
            ];
      public function goaltype()
      {
         return $this-&gt;belongsTo('App\Models\GoalType','goal_type_id');
      }
  
  }
  </code></pre>
  
  <p>GoalType model</p>
  
  <pre><code>class GoalType extends Model
  {
      protected $fillable = [
                'name',
                'parent_id',
            ];
  
     public function children()
     {
       return $this-&gt;hasMany('App\Models\GoalType', 'parent_id');
     }
  
     public function parent()
     {
       return $this-&gt;hasOne(App\Models\GoalType::class, 'id', 'parent_id');
     }
  
  }
  </code></pre>
  
  <p>view</p>
  
  <pre><code>              &lt;select id="goal_type" class="form-control @error('goal_type_id') is-invalid @enderror" name="goal_type_id"&gt;
                &lt;option value=""&gt;Select Goal Type&lt;/option&gt;
  
                  @foreach ($categories as $category)
                    @if ($category-&gt;children)
                      @foreach ($category-&gt;children as $child)
                      @unless($child-&gt;name === 'Job Fundamentals')
                        &lt;option value="{{ $child-&gt;id }}" {{ $child-&gt;id == old('category_id', $goal-&gt;goal_type_id) ? 'selected' : '' }}&gt;&amp;nbsp;&amp;nbsp;{{ $child-&gt;name }}&lt;/option&gt;
                      @endunless
                      @endforeach
                    @endif
                  @endforeach
                &lt;/select&gt;
  </code></pre>
  
  <p>In the view blade above, I tried to apply old() helper function to the select option dropdown so that it will retain its value if there is validation error after submit.</p>
  
  <p>I observed that it didn't work. The data in the dropdown is cleared.</p>
  
  <p>How do I get this resolved?</p>
  
  <p>Thank you</p>