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')]
public function home(): Response
{
// return $this->redirectToRoute('task_view');
return $this->render('simple.html.twig', [
'text' => 'Welcome!'
]);
return $this->redirectToRoute('snip_index');
}
}

View File

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

View File

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

View File

@ -8,10 +8,6 @@
<div class="collapse navbar-collapse" id="navbar">
<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") %}
<li class="nav-item">
<a class="nav-link" href="{{ path('snip_index') }}">My snips</a>