如何在锚标签数据值中设置图像URL

时间:2018-05-17 15:21:36

标签: laravel image anchor

我正在进行一个laravel项目。我的表显示了一些值,如果我点击眼睛图标查看,那么该表的更多细节显示在模态中。但我不知道如何传递图像源锚标签数据值。

@foreach ($employees as $employee)
            <tr class="post{{$employee->id}}">
                <td>{{ $no++ }}</td>
                <td>{{ $employee->name}}</td>
                <td>{{ $employee->bank->name}}</td>
                <td>{{ $employee->bankbranch->location}}</td>
                <td><img alt="Smiley face" height="50" width="70" src="{{url('images',$employee->image)}}"/></td>
                <td>{{ $employee->created_at}}</td>
                <td>
                    <a href="#" class="show-modal btn btn-info btn-sm"  data-id="{{$employee->id}}" data-bank_id="{{$employee->bank->name}}" data-bankbranch_id="{{$employee->bankbranch->location}}" data-salary="{{$employee->salary}}" data-qincentive="{{$employee->qincentive}}" data-fbonus="{{$employee->fbonus}}" data-hrent="{{$employee->hrent}}" data-ename="{{$employee->ename}}" data-ephone="{{$employee->ephone}}" data-relationship="{{$employee->relationship}}" data-gender="{{$employee->gender}}" data-religion="{{$employee->religion}}" data-bgroup="{{$employee->bgroup}}" data-mstatus="{{$employee->mstatus}}"  data-transportallowance="{{$employee->transportallowance}}" data-eaddress="{{$employee->eaddress}}">
                        <i class="fa fa-eye"></i>
                </a>
                </td>
                </tr>
                @endforeach 

1 个答案:

答案 0 :(得分:1)

您只需将src更改为src=“{{$employee->image}}”,前提是图片网址存储在该变量中。如果没有,那么你需要像src=“{{‘/images/’ . {{$employee->image}}”

那样进行连接