为什么我会遇到此错误:
语法错误,意外' - >' (T_OBJECT_OPERATOR)。
这是我的控制器, AuthController.php :
public function showRoles(Request $request) {
$users = User::all();
return view ('app.admin.assign-roles', compact('users'));
}
这是我将传递视图的地方, assign-roles.blade.php :
@extends('layouts.master')
@section('title' ,'Show Users');
@section('contents')
<div class="row">
<table class="table">
<thead class="thead-inverse">
<tr>
<th>User ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<form action="#" method="POST">
<th scope="row">{{$user->id}}</th>
<td>{{$user->name}}</td>
<td>{{$user->email}} <input type="hidden" name="email" value="{{$user->email}}"></td>
</form>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
@section('js')
{!!Html::script('assets/js/jquery.min.js')!!}
{!!Html::script('assets/js/bootstrap.min.js') !!}
@endsection
答案 0 :(得分:0)
我修改了代码。请参阅下文。
我将为您提供有关您在本课题中提到的错误的解决方案。错误是由于您在返回视图中使用压缩时未使用paginate函数。
<强> AuthController.php 强>
public function showRoles(Request $request) {
$users = User::all();
return view ('app.admin.assign-roles', compact('users'));
}
您的观点 assign-roles.blade.php
@extends('layouts.master')
@section('title' ,'Show Users');
@section('contents')
<div class="row">
<table class="table">
<thead class="thead-inverse">
<tr>
<th>User ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<form action="#" method="POST">
<th scope="row">{{ $user->id }}</th>
<td>{{ $user->name }}</td>
<td>{{ $user->email}} <input type="hidden" name="email" value="{{$user->email}}"></td>
</form>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
@section('js')
{!!Html::script('assets/js/jquery.min.js')!!}
{!!Html::script('assets/js/bootstrap.min.js') !!}
@endsection
仅在视图中进行了更改,它将正常工作。