I have a eager loading relationship query.Like
$transactions = User::with(['point','children']->get();
Now I am adding a filter on my datatable
    ->addColumn('total', function($user){
        $sum = 0;
        $filtered = $user->map(function($user,&$sum) {
            $find = $user->children->filter(function($children) use($user) {
                return $children->id == $user->id;
            });
            $sum += $find->point->available;
            return $sum;
        });
        return $sum;
    })
Here if any user id matched with children id then sum of all mathced user available point value.
But I am getting error
[15:22:58] LOG.error: BadMethodCallException:
 Call to undefined method App\User::map() in
via Chebli Mohamed
 
Aucun commentaire:
Enregistrer un commentaire