我要检查特定的ID是否具有密码。
在控制器中查看用户功能
public function viewUser(){
$users = User::orderBy('user_id','ASC')->get();
return view('admin.user.view_user')->with(compact('users'));
}
在viewuser.blade.php
<div class="container">
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Actual Password</h4>
</div>
<div class="modal-body">
<p><?php if(!empty($User->actual_password)) echo "Actual Password:"." $User->actual_password " ; else echo "No Password" ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
但不起作用
答案 0 :(得分:0)
请检查密码是否隐藏在模型中
protected $hidden = ['password', 'remember_token' ];
actual_password!?您是否自己选择了字段名称?如果不!将其更改为“密码”
您可以按如下所示在刀片中使用php
@if($user->actual_password == null)
<p>your text..</p>
@else
<p>Actual Password: {{ $user->actual_password }}</p>
@endif
请注意,变量区分大小写 因此$ User不等于$ user