Remove my snips from public snips

Remove home button and redirect to snip_index
This commit is contained in:
Tim 2023-04-06 21:18:57 +02:00
parent df708aa931
commit f20608082a
4 changed files with 5 additions and 10 deletions

View File

@ -11,9 +11,6 @@ class HomeController extends AbstractController
#[Route('/', name: 'home')] #[Route('/', name: 'home')]
public function home(): Response public function home(): Response
{ {
// return $this->redirectToRoute('task_view'); return $this->redirectToRoute('snip_index');
return $this->render('simple.html.twig', [
'text' => 'Welcome!'
]);
} }
} }

View File

@ -37,7 +37,7 @@ class SnipController extends AbstractController
public function public(): Response public function public(): Response
{ {
return $this->render('snip/index.html.twig', [ return $this->render('snip/index.html.twig', [
'snips' => $this->repository->findPublic(), 'snips' => $this->repository->findPublic($this->getUser()),
'title' => 'Public Snips' 'title' => 'Public Snips'
]); ]);
} }

View File

@ -50,11 +50,13 @@ class SnipRepository extends ServiceEntityRepository
return $qb->getQuery()->getResult(); return $qb->getQuery()->getResult();
} }
public function findPublic(): array public function findPublic(User $user): array
{ {
$qb = $this->createQueryBuilder('s'); $qb = $this->createQueryBuilder('s');
$qb->where('s.public = :public') $qb->where('s.public = :public')
->andWhere('s.createdBy != :user')
->setParameter('public', true) ->setParameter('public', true)
->setParameter('user', $user)
->orderBy('s.createdAt', 'DESC'); ->orderBy('s.createdAt', 'DESC');
return $qb->getQuery()->getResult(); return $qb->getQuery()->getResult();

View File

@ -8,10 +8,6 @@
<div class="collapse navbar-collapse" id="navbar"> <div class="collapse navbar-collapse" id="navbar">
<ul class="navbar-nav me-auto mb-2 mb-md-0"> <ul class="navbar-nav me-auto mb-2 mb-md-0">
<li class="nav-item">
<a class="nav-link" href="{{ path('home') }}">Home</a>
</li>
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %} {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="{{ path('snip_index') }}">My snips</a> <a class="nav-link" href="{{ path('snip_index') }}">My snips</a>