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),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -42,4 +42,30 @@
|
|||
<h3 class="mb-3">Delete Account</h3>
|
||||
<button class="btn btn-danger">Delete Account</button>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<h1>Offers</h1>
|
||||
{% if offers|length > 0 %}
|
||||
<div class="card-deck d-flex justify-content-around justify-content-sm-around justify-content-md-between flex-wrap">
|
||||
{% for offer in offers %}
|
||||
<a href="./offer/{{ offer.id }}" class="mb-5">
|
||||
<div class="card offer h-100">
|
||||
{% if offer.photoFilename %}
|
||||
<img class="card-img-top" src="{{ asset('uploads/photos/' ~ offer.photofilename) }}" />
|
||||
{% endif %}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ offer.title }}</h5>
|
||||
<p class="card-text">{{ offer.description }}</p>
|
||||
</div>
|
||||
<div class="card-footer offer-footer">
|
||||
<p class="username"><i class="fas fa-user mt-3"></i> {{ offer.byUser }}</p>
|
||||
<p class="zip"><i class="fas fa-map-marker-alt mt-3"></i> {{ offer.zipCode }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-warning" role="alert">There are currently no active offers.</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
Reference in a new issue