10 months ago

How do I count items in show page with relationships

Posted 10 months ago by Ibe

Hi there, im having a problem with the counts and I really don't know how to solve it.. So I would like to count all the items (commemorative) in the 'Jointly show' page. The commemoratives belong to a jointly, they are linked by id. Does anyone know how I can solve this?


  public function getJointlyShow($name){
    $jointlies = Jointly::whereName($name)->first();
    $count = Commemorative::count();
    return view('pages/jointly-show')->withJointlies($jointlies)->with('count', $count);;


    {{ $count }}

    @foreach ($jointlies->commemoratives->sortBy('country:name') as $commemoratives)




Please sign in or create an account to participate in this conversation.