Support the ongoing development of Laravel.io →
Database Eloquent Laravel
Last updated 1 year ago.
0

As far as I'm aware find only returns one database row. What happens if you don't use pluck, what do you get? How do you know you are getting all registered names and ids? are you dding the result?

1

use where() instead of find()

$department = Department::where('id',$office->department_id)->pluck('name', 'id');

2
Solution selected by @marcio944

Sign in to participate in this thread!

LoadForge

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 Laravel.io - All rights reserved.