So typically if you have access to the id of a user in laravel you can run User::find($id), however say you don't have access to the user's id and only their username. Is there a better way than using DB::query to locate the user?
这是我目前的解决方案,我想知道是否有人知道更好的方法.
$user_id = DB::table('users')->where('username', $user_input)->first()->id;