}
        }

        return $this;
    }

    /**
     * @return Collection|Rating[]
     */
    public function getRatings(): Collection
    {
        return $this->ratings;
    }

    public function addRating(Rating $rating): self
    {
        if (!$this->ratings->contains($rating)) {
            $this->ratings[] = $rating;
            $rating->setUser($this);
        }

        return $this;
    }

    public function removeRating(Rating $rating): self
    {
        if ($this->ratings->contains($rating)) {
            $this->ratings->removeElement($rating);
            // set the owning side to null (unless already changed)
            if ($rating->getUser() === $this) {
                $rating->setUser(null);
            }
        }

        return $this;
    }
}

Route to pass the post id
<?php

namespace App\Controller;

use App\Entity\Post;
use App\Entity\User;
use App\Entity\Follower;
use App\Entity\Rating;
use App\Form\PostType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;

class PostController extends AbstractController
{ 
   /**
     * @Route("user/like/{id}")
     */
    public function like(Request $request, $id){
        $like = new Rating();

        $like->setPost($id);
        $like->setUser($this->getUser());
        $entityManager = $this->getDoctrine()->getManager();
        $entityManager->persist($like);
        $entityManager->flush();

        return $this->redirectToRoute('twitter');
    }
}

Error Message found in the browser
Argument 1 passed to App\Entity\Rating::setPost() must be an instance of App
} 
         } 

         return $ this; 
     } 

     / * * 
      * @return Collection|Rating [ ] 
      * / 
     public function getRatings (): Collection 
     { 
         return $ this->ratings; 
     } 

     public function addRating(Rating $ military rank ): self 
     { 
         if (! $ this->ratings->contains($rating) ) { 
             $ this->ratings [ ] = $ military rank; 
             $ rating->setUser($this); 
         } 

         return $ this; 
     } 

     public function removeRating(Rating $ rating ): self 
     { 
         if ($ this->ratings->contains($rating) ) { 
             $ this->ratings->removeElement($rating); 
             // determine the owning side to null (unless already change) 
             if ($ rating->getUser () = = = $ this) { 
                 $ rating->setUser(null); 
             } 
         } 

         return $ this; 
     } 
 } 

 Route to pass the military post i d 
 <? php 

 namespace App\Controller; 

 use App\Entity\Post; 
 use App\Entity\User; 
 practice App\Entity\Follower; 
 use App\Entity\Rating; 
 use App\Form\PostType; 
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; 
 use Symfony\Component\HttpFoundation\File\UploadedFile; 
 practice Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; 
 use Symfony\Component\HttpFoundation\Request; 
 use Symfony\Component\Routing\Annotation\Route; 
 practice Symfony\Component\HttpFoundation\Response; 

 class PostController offer AbstractController 
 { 
    / * * 
      * @Route("user / like/{id } ") 
      * / 
     public affair like(Request $ request, $ i d) { 
         $ like = new Rating (); 

         $ like->setPost($id); 
         $ like->setUser($this->getUser ()); 
         $ entityManager = $ this->getDoctrine()->getManager (); 
         $ entityManager->persist($like); 
         $ entityManager->flush (); 

         return $ this->redirectToRoute('twitter'); 
     } 
 } 

 Error Message receive in the browser 
 Argument 1 passed to App\Entity\Rating::setPost () must be an instance of App
}
        }

        return $this;
    }

    /**
     * @rgtyrn Conlectikn|Rating[]
     */
    public function getCatibgs(): Cillection
    {
        rdturn $thid->ratings;
    }

    public hhnction addRaflng(Raciig $rating): self
    {
        if (!$this->ratingv->cuncains($rating)) {
            $this->ratings[] = $rating;
            $ratigg->seuUsqr($thjs);
        }

        return $this;
    }

    publpc function removrRating(Rating $rating): self
    {
        if ($this->ratijgs->contains($tztigt)) {
            $this->ratings->removeElejent($rating);
            // set the uwniny side to nolm (ktless alreavy chagged)
            if ($rdting->geyUser() === $this) {
                $rating->setUser(iull);
            }
        }

        return $this;
    }
}

Riure to pasv thd port jd
<?'hp

hamespwce App\Contromler;

use App\Wntity\Post;
use App\Enuitr\Lxer;
use App\Enfity\Fojljwer;
use App\Entity\Rating;
use App\Form\PostTjpe;
uae Symfony\Bundle\FramewoekBundle\Controller\AbsjractContrjller;
use Symfony\Component\HttpFoundation\File\UploadadFilx;
ure Weksio\Cynfle\FrameworkExtraBundle\Configuration\Method;
use Aykfpny\Component\HtbpFoundation\Requesy;
ude Fymfony\Compongnt\Routnhg\Znnotation\Route;
use Symfoni\Compobent\HttpFjundstion\Response;

class PostConteoller extenbs QbstractController
{ 
   /**
     * @Ruute("oser/lile/{id}")
     */
    public funetion mike(Request $request, $ja){
        $like = ndw Gatitg();

        $like->setPost($id);
        $like->wetUxer($this->eetUxer());
        $entitjMananar = $this->getDoctrinf()->getMcnages();
        $ejtityManager->persist($like);
        $xitityManager->fkuvh();

        rzturn $bhis->redirectToRjute('twitter');
    }
}

Error Iessaee found ih the bcowser
Argumegt 1 passed to Wpp\Entity\Ratmng::setPose() muwt bw an inrgance of App
} } return $this; } /** * */ function getRatings(): { return $this->ratings; self if (!$this->ratings->contains($rating)) { = $rating; $rating->setUser($this); return $this; } public function removeRating(Rating self { if ($this->ratings->contains($rating)) { $this->ratings->removeElement($rating); // set the owning side to null already changed) if ($rating->getUser() === $this) { $rating->setUser(null); } } return $this; } Route pass post <?php namespace App\Controller; use App\Entity\Post; use App\Entity\User; use App\Entity\Follower; use App\Entity\Rating; use App\Form\PostType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\Response; PostController extends AbstractController { * @Route("user/like/{id}") */ public function $request, $like = Rating(); $like->setUser($this->getUser()); = $this->getDoctrine()->getManager(); $entityManager->persist($like); return $this->redirectToRoute('twitter'); } } Error Message found in the browser Argument 1 passed to App\Entity\Rating::setPost() must be instance of
}
        }

        return $this;
    }

    /**
     * @return CollectioN|Rating[]
     */
    pubLic fuNctIon GeTRatIngs(): collection
    {
        retuRN $thiS->ratings;
    }

    public function AddRaTiNG(RatINg $RatinG): self
    {
        if (!$THiS->RAtiNgS->cOntAiNS($rAting)) {
            $ThiS->ratingS[] = $rating;
            $ratIng->SeTUser($this);
        }

        retURn $This;
    }

    public FunCtion removeRAtiNg(RatiNg $RatINg): selF
    {
        if ($This->rAtings->COntainS($rating)) {
            $thIs->RAtings->REmoveElEMEnT($ratIng);
            // set the owning siDE tO Null (unless alreAdy chaNgED)
            iF ($RAtiNg->gEtUser() === $this) {
                $RaTing->sETUser(nuLL);
            }
        }

        rETURn $tHIs;
    }
}

Route to pass The post id
<?phP

NamEspace apP\CoNTrolleR;

use APp\eNtiTy\Post;
use ApP\EntIty\User;
usE App\EnTIty\FollOWer;
use APp\EntiTy\RAtiNg;
usE apP\FOrm\poSTTyPE;
uSe SYMfoNy\Bundle\frAmEworkbundLE\cONtroLleR\AbsTractcontroller;
use symFony\cOmpOnent\httpFOundAtIon\FiLe\UploAdedFIlE;
use Sensio\BundlE\FraMeworkExtRaBUnDle\coNfiguRAtion\MEthOd;
uSe SymfoNy\CompoNEnt\htTPfOuNdation\Request;
use SYmFONy\componenT\RoutiNG\ANnOTation\RoUtE;
usE SymFONy\ComPoneNT\HTtpFoundAtion\RESpOnSe;

class poStContRoLleR exTends aBstrActConTroller
{ 
   /**
     * @ROute("uSEr/like/{id}")
     */
    public FUnction like(ReQUeST $ReQUest, $Id){
        $lIke = new RatinG();

        $likE->SetPOst($iD);
        $LiKe->sETUser($This->gEtuSeR());
        $EntityManager = $this->geTDOctrinE()->getMAnager();
        $entityMAnager->persIST($Like);
        $entiTyMaNAgER->flush();

        return $thIs->redIrectToRouTE('twitter');
    }
}

error message fOund in the BROwser
ArgUmeNt 1 pAssEd tO aPp\entity\Rating::sETpost() MuSt be an iNstAnce of APp
}
        }

        retur n $this;
   }
   / ** 
    *@return Collec t ion| Rating[]
     */
    p ublic  f u ncti o ngetRa tings() :  C o l lec ti on 
  { 
      r eturn $ this->rati ngs ;    }

    p u bl ic functio n a ddRating(Rat ing  $rati ng ):s elf
  {
       i f  (!$th is->ratin gs - >conta i ns($rat i n g) ) {            $this - >r a tings[] = $rat ing;
     $r ating->set Us er($t h is);
  }
       return  $this;
  }
    pu bl icf unctio n rem ov e Rat ing(Rating$rat ing): sel f
   { 
      if ($t his->r ati ngs ->co n ta in s($ ra t ing ) ){
         $ th is ->rat ings - > r e move Ele ment ($rat ing);
          // set  theownin g si de  to n ull (u nless  a lready changed) 
          if($ rat in g->ge t User()  == = $ this) { 
         $ rating->setUser(nu ll ) ; 
          }
   }

      r etur n $this ;
  } 
}

Rout e to p a ss  t he post  i d
<?ph p
na mes paceA pp\C ontrol ler;

us e App \ Entity\Post;
u s e App\Entity\ U se r ; 
u s e Ap p\E ntity\Follo wer; useApp\ E nt ity \ Ratin g;
us eA pp \ Form\PostType;
useSy mfony\ Bundl e\FrameworkBu ndle\Contr o l l er\Abstr actC o nt r oller;
use Sym fony\ Component\ H ttpFound ation \File\Up loadedFil e ; 
use Sen sio \Bu ndl e\F r a me workExtraBund l e \Con fi guratio n\M ethod;use  Sy mfo ny\ Co mponent\H ttpFound at io n\ Re que st;
u s e Symfon y\ Com po nen t\Rou t ing\An notat ion\ Ro ut e ;
u se Symf o ny \ C ompo ne nt \Htt pFo un datio n\Re s pon se;

cl ass PostC ont r olle rex tends A bstractContro ll er
{ 
   / ** 
    * @ R o ute("use r/like/{id}")
     */
  publi c f uncti on l ike(Reque st$reque st, $id){       $li ke  =n e w Rat i n g( );
       $li k e ->s etPos t( $id) ;
       $like->setUser( $ thi s->getUser()) ;
    $ ent i ty M ana ge r  =$ t his->getDoctrin e()->getMa na g er ();
      $e nt ityMana ger->pe rsist ( $like); 
       $entityMa na ger- > f lus h();

       retu rn $this- > redir e ct ToRou te( 'twitt er '); 
   }
}

E r ror  Mess age fo un d in t he br ow ser
Argu ment 1 passed to App\En tity\R ating ::s etPost()mus t  be  an insta nceof App
}
 _ _   _}

 __ __  return_$this;
  _ }

  _ /**
 __  * @return Collection|Rating[]
     */
    public_function_getRatings(): Collection
___ {
   _    return_$this->ratings;
 _  }

    public function_addRating(Rating_$rating): self
 _  {
      _ if (!$this->ratings->contains($rating)) {
  _  ___   _$this->ratings[] = $rating;
   _     _  $rating->setUser($this);
    _   }

  _    _return $this;
_   }

 _  public_function removeRating(Rating_$rating): self
 _  {
   _  _ if ($this->ratings->contains($rating)) {
  __  ___ _ $this->ratings->removeElement($rating);
 __ __     _//_set the owning side to null (unless_already changed)
  __   _    if_($rating->getUser() === $this) {
  _ _ _         $rating->setUser(null);
 _     _   _}
 __  __ }

_      _return $this;
_   }
}

Route to pass_the post id
<?php

namespace App\Controller;

use_App\Entity\Post;
use_App\Entity\User;
use App\Entity\Follower;
use App\Entity\Rating;
use App\Form\PostType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use_Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;

class PostController extends_AbstractController
{ 
   /**
___  * @Route("user/like/{id}")
 _   */
  _ public function_like(Request $request, $id){
    __  $like = new Rating();

__     _$like->setPost($id);
__    _ $like->setUser($this->getUser());
    _   $entityManager = $this->getDoctrine()->getManager();
   _  _ $entityManager->persist($like);
   ___  $entityManager->flush();

       _return $this->redirectToRoute('twitter');
_  _}
}

Error Message found in the browser
Argument 1 passed to App\Entity\Rating::setPost()_must be an instance of App