Я не могу передать результат БД в представление. Если я отлаживаю его на стороне контроллера, все в порядке, поэтому запрос БД работает нормально, но когда я пытаюсь получить переменную в поле зрения, он говорит, что переменная не определена.
Контроллер:
$records = DB::table('records')
->join('call_charges', function($join)
{
$join->on('records.inbound_originating_address_region', '=', 'call_charges.RateDestination')
->on('records.inbound_originating_address_type', '=', 'call_charges.RateType');
})
->join('phone_types', 'records.inbound_originating_address_type', '=', 'phone_types.phone_type_id')
->orderBy('records.inbound_initiated_utc', 'asc')
->get();
return View::make( 'records.index' )->with( 'records', $records );
Вид:
@extends('app')
@section('content')
@if (Auth::check())
<h2>Call records</h2>
@if ( !$records->count() )
No call records to view!
@else
<table class="table table-striped table-hover table-condensed table-bordered">
<thead>
<tr>
<th>Time</th>
<th>Out call</th>
<th>Duration</th>
<th>Cost</th>
<th>Billable</th>
<th>Country</th>
<th>Type</th>
<th>Caller</th>
<th>Receiver</th>
</tr>
</thead>
<tbody>
@foreach( $records as $record )
<tr>
<td>{{ $record->inbound_initiated_utc }}</td>
@if ( $record->is_in_call == 1 )
<td class="success">Yes</td>
@else
<td class="warning">No</td>
@endif
<td>{{ $record->inbound_duration }}</td>
<td>{{ $record->session_total_charges }}</td>
<td>0</td>
<td>{{ $record->inbound_originating_address_region }}</td>
<td>{{ $record->inbound_originating_address_type }}</td>
<td>{{ $record->inbound_originating_address }}</td>
<td>{{ $record->inbound_destination_address }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
@endif
@unless (Auth::check())
You are not signed in. Please sign in <a href='/auth/login'>here</a>
@endunless
@endsection