laravel7 搜索关键字标红及手机号,身份证号隐藏

控制器代码
 public function index(Request $request)
    {
        //接受搜索关键字
        $word = $request->get('name');
        $start = $request->get('start');
        $end = $request->get('end');
        $paginsete = config('setting.paginate');
        $data = Register::where('name', 'like', "%$word%")->whereNotBetween('created_at', [$start, $end])->orderBy('id', 'desc')->paginate($paginsete);
        $where = [];
        $where['word'] = $word;
        $where['start'] = $start;
        $where['end'] = $end;
        return view('register.index', compact('data', 'where','word'));
    }
视图代码:
 @foreach($data as $item)
                <tr class="text-c">
                    <td><input type="checkbox" value="{{$item->id}}" name="id[]"></td>
                    <td>{{$item->id}}</td>
                    <td><u style="cursor:pointer" class="text-primary">{!!str_replace($where['word'], "<span style='color:red'>{$where['word']}</span>", $item->name) !!}</u></td>
                    <td>{{$item->Job_number}}</td>
                    <td>{{substr_replace($item->id_number,'****',6,8)}}</td>
                    <td>{{substr_replace($item->phone,'****',4,4)}}</td>
                    <td class="text-l">{{$item->Department}}</td>
                    <td>{{$item->created_at}}</td>
                    <td class="td-status"><span class="label label-success radius">
                        @if($item->status==0)
                                已就诊
                            @elseif($item->status==1)
                                未就诊
                            @else
                                未挂号
                            @endif
                    </span></td>
                    <td class="td-manage"><a style="text-decoration:none" onClick="member_stop(this,'10001')"
                                             href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a> <a
                            title="编辑" href="javascript:;" onclick="member_edit('编辑','member-add.html','4','','510')"
                            class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a
                            style="text-decoration:none" class="ml-5"
                            onClick="change_password('修改密码','change-password.html','10001','600','270')"
                            href="javascript:;" title="修改密码"><i class="Hui-iconfont">&#xe63f;</i></a> <a title="删除"  href="javascript:;" onclick="member_del(this,'1')" class="ml-5" style="text-decoration:none"><i
                                class="Hui-iconfont">&#xe6e2;</i></a></td>
                </tr>
            @endforeach

效果图:

laravel7 搜索关键字标红及手机号,身份证号隐藏

 

上一篇:如何获得用于Sony Xperia ZR的Android内核开发的mkbootimg?


下一篇:苹果的MACBOOK AIR (MBA)与SONY VAIO PRO 11/13之间