show offers on user page
This commit is contained in:
parent
b5d7281d77
commit
b3500b630a
3 changed files with 36 additions and 9 deletions
|
@ -6,6 +6,7 @@ use App\Entity\Wish;
|
|||
use App\Entity\User;
|
||||
use App\Form\WishFormType;
|
||||
|
||||
use App\Repository\OfferingRepository;
|
||||
use App\Repository\WishRepository;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
@ -25,10 +26,13 @@ class UserController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/user', name: 'user_page')]
|
||||
public function user(): Response
|
||||
public function user(OfferingRepository $offeringRepository): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
return $this->render('user/index.html.twig', [
|
||||
'user' => $this->getUser(),
|
||||
'user' => $user,
|
||||
'offers' => $offeringRepository->findByUser($user),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -71,7 +75,7 @@ class UserController extends AbstractController
|
|||
public function deleteWish(Wish $wish): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
|
||||
$user->removeWish($wish);
|
||||
$this->entityManager->persist($wish);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -22,19 +22,16 @@ class OfferingRepository extends ServiceEntityRepository
|
|||
// /**
|
||||
// * @return Offering[] Returns an array of Offering objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
public function findByUser($user)
|
||||
{
|
||||
return $this->createQueryBuilder('o')
|
||||
->andWhere('o.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->andWhere('o.byUser = :val')
|
||||
->setParameter('val', $user)
|
||||
->orderBy('o.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Offering
|
||||
|
|
Reference in a new issue