change homepage route
This commit is contained in:
parent
19d2bfbcc3
commit
d10ef764bc
7 changed files with 80 additions and 64 deletions
|
@ -29,7 +29,7 @@ class DashboardController extends AbstractDashboardController
|
|||
|
||||
public function configureMenuItems(): iterable
|
||||
{
|
||||
yield MenuItem::linktoRoute('Back to the website', 'fas fa-arrow-left', 'homepage');
|
||||
yield MenuItem::linktoRoute('Back to the website', 'fas fa-arrow-left', 'offers');
|
||||
yield MenuItem::linktoDashboard('Dashboard', 'fa fa-home');
|
||||
yield MenuItem::linkToCrud('User', 'fas fa-user', User::class);
|
||||
yield MenuItem::linkToCrud('Offering', 'fas fa-seedling', Offering::class);
|
||||
|
|
|
@ -19,4 +19,10 @@ class AppController extends AbstractController
|
|||
{
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
#[Route('/', name: 'homepage')]
|
||||
public function index(Environment $twig, OfferingRepository $offerRepository): Response
|
||||
{
|
||||
return new Response($twig->render('app/index.html.twig'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class OfferController extends AbstractController
|
|||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
#[Route('/', name: 'homepage')]
|
||||
#[Route('/offers', name: 'offers')]
|
||||
public function index(Environment $twig, OfferingRepository $offerRepository): Response
|
||||
{
|
||||
return new Response($twig->render('app/index.html.twig', [
|
||||
|
@ -62,7 +62,7 @@ class OfferController extends AbstractController
|
|||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash("success", "Successfully added the new offer!");
|
||||
return $this->redirectToRoute('homepage');
|
||||
return $this->redirectToRoute('offers');
|
||||
}
|
||||
|
||||
return $this->render('app/new_offer.html.twig', [
|
||||
|
@ -75,6 +75,7 @@ class OfferController extends AbstractController
|
|||
public function show_offer(Offering $offer, WishRepository $wishRepository): Response
|
||||
{
|
||||
return $this->render('app/offer.html.twig', [
|
||||
'user' => $this->getUser(),
|
||||
'offer' => $offer,
|
||||
'wishes' => $wishRepository->findByUser($offer->getByUser()),
|
||||
]);
|
||||
|
|
|
@ -1,35 +1,20 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Hello OfferController!{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<style>
|
||||
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
|
||||
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
|
||||
</style>
|
||||
|
||||
{% for message in app.flashes('success') %}
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="example-wrapper">
|
||||
<h1>Hello! ✅</h1>
|
||||
|
||||
<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 %}
|
||||
This friendly message is coming from:
|
||||
<ul>
|
||||
<li>Your controller at <code><a href="{{ '/home/thisfro/repos/plant-exchange/src/Controller/OfferController.php'|file_link(0) }}">src/Controller/OfferController.php</a></code></li>
|
||||
<li>Your template at <code><a href="{{ '/home/thisfro/repos/plant-exchange/templates/offer/index.html.twig'|file_link(0) }}">templates/offer/index.html.twig</a></code></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,6 +1,10 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
{% if offer.byUser == user %}
|
||||
<div class="alert alert-info" role="alert">This is your offer!</div>
|
||||
{% endif %}
|
||||
|
||||
<h1 class="mb-3">{{ offer.title }}</h1>
|
||||
|
||||
<div class="offer d-flex flex-wrap justify-content-around">
|
||||
|
@ -11,10 +15,14 @@
|
|||
<h3>Description</h3>
|
||||
<p>{{ offer.description }}</p>
|
||||
<h3>From</h3>
|
||||
<p>{{ offer.byUser }} in {{ offer.zipCode }}</p>
|
||||
<p>{% if offer.byUser == user %}Me{% else %}{{ offer.byUser }}{% endif %} in {{ offer.zipCode }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if offer.byUser == user %}
|
||||
<a href="#" class="btn btn-info"><i class="fas fa-pen"></i></a>
|
||||
<a href="#" class="btn btn-danger"><i class="fas fa-trash-alt"></i></a>
|
||||
{% else %}
|
||||
<h3>Wishes</h3>
|
||||
<p>{{ offer.byUser }} would like some of the following in return:</p>
|
||||
<div class="mb-3">
|
||||
|
@ -31,4 +39,5 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
<button class="btn btn-primary">Offer trade</button>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -40,7 +40,7 @@
|
|||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href=" {{ path('homepage') }} "><i class="fas fa-seedling"></i> Offers</a>
|
||||
<a class="nav-link" href=" {{ path('offers') }} "><i class="fas fa-seedling"></i> Offers</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" data-toggle="dropdown"role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-user"></i> User</a>
|
||||
|
|
|
@ -1,20 +1,35 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Hello OfferController!{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<style>
|
||||
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
|
||||
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
|
||||
</style>
|
||||
|
||||
<div class="example-wrapper">
|
||||
<h1>Hello {{ controller_name }}! ✅</h1>
|
||||
{% for message in app.flashes('success') %}
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
This friendly message is coming from:
|
||||
<ul>
|
||||
<li>Your controller at <code><a href="{{ '/home/thisfro/repos/plant-exchange/src/Controller/OfferController.php'|file_link(0) }}">src/Controller/OfferController.php</a></code></li>
|
||||
<li>Your template at <code><a href="{{ '/home/thisfro/repos/plant-exchange/templates/offer/index.html.twig'|file_link(0) }}">templates/offer/index.html.twig</a></code></li>
|
||||
</ul>
|
||||
</div>
|
||||
<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="{{ path('show_offer', {'id': 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