I am binding an employee model into a Blade
template, and want to place the result of an eager load relation into a field.
In my controller I build the collection for the page as:
$employee = User::with('country', 'activeOrganisationRole')->first();
My form open statement is:
{!! Form::model($employee, ['route' => ['employee.role', $employee->uuid], 'method' => 'POST']) !!}
So I want to populate $employee->country->name
into an input Laravel Collective form::text
statement, but I cannot get the country name to load. All other fields on the form load perfectly from the parent collection.
My Country field is:
<div class="form-group">
<label for="phone" class="control-label">Country</label>
{!! Form::text('country', null, ['id'=>'country', 'placeholder' => 'Country', 'class' => 'form-control']) !!}
</div>
The above country field loads the entire relation result into the input. What is the correct syntax for injecting $employee->country->name
into this input?
By the way , this works perfectly, but I have learned nothing by doing this way!
<label for="title" class="control-label">Country</label>
<input id="country" class="form-control" value="{!! $employee->country->country !!}" readonly>