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?
This is my current solution and was wondering if someone possibly knew a better way.
$user_id = DB::table('users')->where('username', $user_input)->first()->id;
using the model. just like this
User::where('username','John') -> first();
// or use like
User::where('username','like','%John%') -> first();
User::where('username','like','%John') -> first();
User::where('username','like','Jo%') -> first();
Use middleware for this purpose and ...READ MORE
Use order by like this:
return User::orderBy('name', 'DESC')
You can update the cache object ...READ MORE
You can use it in middleware. ...READ MORE
First you have to go to ...READ MORE
Named route is used to give specific ...READ MORE
This is simple you just need to ...READ MORE
Named routing is another amazing feature of ...READ MORE
One of the methods it provides ...READ MORE
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.