Proximity IDK? Feb 13, 2014 673 56 Jan 21, 2016 #1 I need some assistance with laravel This is my code Code: {{ User::orderBy('id', 'DESC')->limit(1)->first()->pluck('username') }} it shows the newest registerd user but it doesn't update when someone registers...
I need some assistance with laravel This is my code Code: {{ User::orderBy('id', 'DESC')->limit(1)->first()->pluck('username') }} it shows the newest registerd user but it doesn't update when someone registers...
RastaLulz fight teh power Staff member May 3, 2010 3,934 3,933 Jan 21, 2016 #2 You don't need to call first(), as pluck() will pick the first instance regardless, and they both call get(). pluck() will also limit the query to one as well, so all you need is: Code: {{ User::orderBy('id', 'DESC')->pluck('username') }} Upvote 0 Downvote
You don't need to call first(), as pluck() will pick the first instance regardless, and they both call get(). pluck() will also limit the query to one as well, so all you need is: Code: {{ User::orderBy('id', 'DESC')->pluck('username') }}
Proximity IDK? Feb 13, 2014 673 56 Jan 21, 2016 Thread starter #3 RastaLulz said: You don't need to call first(), as pluck() will pick the first instance regardless, and they both call get(). pluck() will also limit the query to one as well, so all you need is: Code: {{ User::orderBy('id', 'DESC')->pluck('username') }} Click to expand... Thanks @RastaLulz You can close this thread please. Upvote 0 Downvote
RastaLulz said: You don't need to call first(), as pluck() will pick the first instance regardless, and they both call get(). pluck() will also limit the query to one as well, so all you need is: Code: {{ User::orderBy('id', 'DESC')->pluck('username') }} Click to expand... Thanks @RastaLulz You can close this thread please.