我试图从 View(activate_id) 上的数据库中返回一个特定值,AdminController
但它什么也不返回。
网页.php
Route::get('/activate-id', 'AdminController@activateId')->middleware('role:admin');
管理员控制器.php
public function activateId(Request $request)
{
$by = DB::table('users')
->select('referrer')
->where('username', $request->username)
->first();
return view('activate_id')->with('by', $by);
}
activate_id.blade.php
<form method="post" action="/activate-user">
@csrf
<div class="input-group mb-3">
<div class="form-group">
<input id="fuser" type="text" class="form-control" name="username" placeholder="Username">
<p class="text-info" id="fdetails"></p>
</div>
</div>
<div class="input-group mb-3">
<div class="form-group">
<label for="recipient-name" class="control-label">Referrer</label>
<input type="text" class="form-control" name="by" id="recipient-name" value="{{$by}}" readonly>
</div>
</div>
<div class="col-12">
<button class="btn btn-outline-success"> Activate</button>
</div>
</form>