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

Posted 1 month ago by abduljakul-salsalani

this is in my blade file where I display my results

                $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  ;

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

                        <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')

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


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

Reply to

Use Markdown with GitHub-flavored code blocks.