@extends('admin.layout')

@section('content')
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>新品评价</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <form method="GET" action="" accept-charset="UTF-8">

                                <div class="col-sm-4">
                                    <div class="input-group">
                                        <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入关键词"
                                               name="keyword" class="input-sm form-control">
                                        <span class="input-group-btn">
									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
								</span>
                                    </div>
                                </div>
                            </form>

                        </div>

                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                            <thead>
                            <tr>

                                <th class="sorting" data-sort="id"></th>
                                <th class="sorting" data-sort="user_id"> 用户姓名</th>
                                <th class="sorting" data-sort="newgoods_id"> 所属新品</th>
                                <th class="sorting"> 评分</th>
                                <th class="sorting" data-sort="content"> 评价内容</th>
                                <th class="sorting" data-sort="created_at"> 添加时间</th>


                                <th width="22%">相关操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @if(isset($list))
                                @foreach($list as $key => $item)
                                    <tr>

                                        <td>{{ $item->id }}</td>
                                        <td>{{ $item->user->username }}</td>
                                        <td>{{ $item->newgoods->title }}</td>
                                        <td>
                                            {{ $item->newgoods->comments_field_1 }}: {{$item->comments_field_1}}分<br/>
                                            {{ $item->newgoods->comments_field_2 }}: {{$item->comments_field_1}}分<br/>
                                            {{ $item->newgoods->comments_field_3 }}: {{$item->comments_field_1}}分<br/>
                                            {{ $item->newgoods->comments_field_4 }}: {{$item->comments_field_1}}分

                                        </td>
                                        <td>{{ mb_substr($item->content,0,10).'...' }}</td>
                                        <td>{{ $item->created_at }}</td>
                                        <td>
                                            <div class="btn-group">
                                                <button data-toggle="dropdown"
                                                        class="btn btn-warning btn-sm dropdown-toggle"
                                                        aria-expanded="false">
                                                    操作 <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu">


                                                    @if(role('Furniture/Newgoods/Comment/update'))
                                                        <li>
                                                            <a href="{{ U('Furniture/Newgoods/Comment/update',['id'=>$item->id])}}"
                                                               class="font-bold">回复</a></li>
                                                    @endif

                                                    @if(role('Furniture/Newgoods/Comment/destroy'))
                                                        <li class="divider"></li>
                                                        <li>
                                                            <a href="{{ U('Furniture/Newgoods/Comment/destroy',['id'=>$item->id])}}"
                                                               onclick="return confirm('你确定执行删除操作？');">删除</a></li>
                                                    @endif

                                                </ul>
                                            </div>
                                            @if(role('Furniture/Newgoods/Comment/view'))
                                                <button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Furniture/Newgoods/Comment/view',['id'=>$item->id])}}'});"
                                                        class="btn btn-primary ">查看
                                                </button>
                                            @endif


                                        </td>
                                    </tr>
                                @endforeach
                            @endif

                            </tbody>
                        </table>
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="dataTables_info" id="DataTables_Table_0_info"
                                     role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}
                                    条，共{{ $list->lastPage() }}页，总{{ $list->total() }}条。
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                    {!! $list->setPath('')->appends(Request::all())->render() !!}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection