change offering to offer in frontend

This commit is contained in:
Jannis Portmann 2021-05-05 22:11:24 +02:00
parent 845c3880f4
commit c3e56756cb
8 changed files with 55 additions and 55 deletions

View file

@ -26,25 +26,25 @@ class OfferController extends AbstractController
}
#[Route('/', name: 'homepage')]
public function index(Environment $twig, OfferingRepository $offeringRepository): Response
public function index(Environment $twig, OfferingRepository $offerRepository): Response
{
return new Response($twig->render('app/index.html.twig', [
'offerings' => $offeringRepository->findAll(),
'offers' => $offerRepository->findAll(),
]));
}
#[Route('/new', name: 'new_listing')]
public function new_listing(Request $request, string $photoDir): Response
#[Route('/new', name: 'new_offer')]
public function newOffer(Request $request, string $photoDir): Response
{
$offering = new Offering();
$form = $this->createForm(OfferingFormType::class, $offering);
$offer = new Offering();
$form = $this->createForm(OfferingFormType::class, $offer);
$user = $this->getUser();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$offering->setByUser($user);
$offering->setCreatedAt(new \DateTime());
$offer->setByUser($user);
$offer->setCreatedAt(new \DateTime());
if ($photo = $form['photo']->getData()) {
$filename = bin2hex(random_bytes(6)).'.'.$photo->guessExtension();
@ -53,30 +53,30 @@ class OfferController extends AbstractController
} catch (FileException $e) {
// unable to upload the photo, give up
$this->addFlash("error", "There was an error uploading the photo: ".$e);
return $this->redirectToRoute('new_listing');
return $this->redirectToRoute('new_offer');
}
$offering->setPhotoFilename($filename);
$offer->setPhotoFilename($filename);
}
$this->entityManager->persist($offering);
$this->entityManager->persist($offer);
$this->entityManager->flush();
$this->addFlash("success", "Successfully added the new offering!");
$this->addFlash("success", "Successfully added the new offer!");
return $this->redirectToRoute('homepage');
}
return $this->render('app/new_listing.html.twig', [
return $this->render('app/new_offer.html.twig', [
'user' => $this->getUser(),
'offering_form' => $form->createView(),
'offer_form' => $form->createView(),
]);
}
#[Route('/offer/{id}', name: 'show_offer')]
public function show_offer(Offering $offering, WishRepository $wishRepository): Response
public function show_offer(Offering $offer, WishRepository $wishRepository): Response
{
return $this->render('app/offer.html.twig', [
'offer' => $offering,
'wishes' => $wishRepository->findByUser($offering->getByUser()),
'offer' => $offer,
'wishes' => $wishRepository->findByUser($offer->getByUser()),
]);
}
}