Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | namespace Adldap\Query; |
| 4 | |
| 5 | use Adldap\Models\Model; |
| 6 | use Illuminate\Support\Collection as BaseCollection; |
| 7 | |
| 8 | class Collection extends BaseCollection |
| 9 | { |
| 10 | /** |
| 11 | * {@inheritdoc} |
| 12 | */ |
| 13 | protected function valueRetriever($value) |
| 14 | { |
| 15 | if ($this->useAsCallable($value)) { |
| 16 | return $value; |
| 17 | } |
| 18 | |
| 19 | return function ($item) use ($value) { |
| 20 | if ($item instanceof Model) { |
| 21 | return $item->getFirstAttribute($value); |
| 22 | } |
| 23 | |
| 24 | return data_get($item, $value); |
| 25 | }; |
| 26 | } |
| 27 | } |