abduljakul-salsalani
4 months ago

I can't display this php statement inside my blade file from flatMap result in many2 many

Posted 4 months ago by abduljakul-salsalani

this is in my blade file where I display my results


@php
                $activityTypeId   =          $paper->id ;
                $activityCreator  =            $paper->pivot->display_name;
                $paperId          =         $paper->pivot->paper_id;

                        $route            =         `<a class="text-black" href="{{ route('papers.show',$paperId) }}"></a>` ;         

                        switch ($activityTypeId) {
                            case 1:
                            $activityTypePhrase = $activityCreator . " Activity 1 " .$route  ;
                            break;    

                            case 2 :
                            $activityTypePhrase = $activityCreator . " Activity 2".$route; 
                            break;
                        }

                   @endphp
                        <p class="text-black">{{  $activityTypePhrase }}</p>

from this query that this static function returns the results in a many to many relationship

public static function fetchActivitiesForAStudent(){

        if (auth()->check() == false) {
            abort(403, "Unauthorized");
        }

        $userId = auth()->id();

        $papers = Article::where('owner','=',$userId)->has('activityCreators')
                        ->with('activityCreators','activityTypes')
                        ->get();


        return $papers->flatMap->activityCreators ; 
        // return collect([$papers, $activity]) ;
        

    }

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