My problem is the next in a voyager project I'm working on. I have an enterprise
table and a users
table.
I need to add a select input in the edit view of users
table - but this view is in vendor\tcg\voyager\resources\views\users\edit-add.blade.php
I tried to add the select like:
<div class="form-group">
<label for="enterprise">Enterprises</label>
<select name="enterprise_id" id="inputEnterprise_id" class="form-control">
@foreach ($enterprises as $enterprise)
<option value="{{$enterprise['id']}}">{{$enterprise['name']}}</option>
@endforeach
</select>
</div>
I wrote the controller so it gets the data from the table. But, when I go to voyager and I try to edit some user, I have an exception error where says that the $enterprises
var is not defined.
My edit()
function in controller:
public function edit()
{
$enterprises = Enterprise::all();
return view('users.edit-add',compact('enterprises'));
}
Can someone tell me what the bug is?