Laravel 7: Undefined variable in foreach loop

793 views Asked by At

I want to display to select the campus from the campuses table in my budget allocation create.blade.php template but it displays an error.

create.blade.php

<div class="form-group row">
          <label class="col-md-3">Campus</label>
          <div class="col-md-9">
            <select name="campus_id" class="form-control">
              <option value="">--- Select Campus ---</option>
              @foreach($campuses as $campus)
                {{ var_dump($campus) }}
                <option value="{{ $campus->campus_id }}">{{ $campus->campus_name }}</option>
              @endforeach
            </select>
          </div>
          <div class="clearfix"></div>
</div>
1

There are 1 answers

1
OMR On

in your controller you must send the data to the view using second paramter of the view ...

return view('admin.budgetallocation.create',$arr);