Get the channels for a user on the dashboad.

This commit is contained in:
Dave Smith-Hayes 2024-12-14 09:37:30 -05:00
parent b9db0d97dc
commit 83cc9b194c
2 changed files with 13 additions and 5 deletions

View File

@ -37,10 +37,14 @@ class CreateChannelAction extends Controller
/** /**
* Should wrap this in a try/catch probably * Should wrap this in a try/catch probably
*/ */
if (!$this->channelRepository->create($channel, $user)) { try {
return $this->render('channel/create.twig')->withStatus(500); $channel = $this->channelRepository->create($channel, $user);
$this->session->getFlash()->add("success", "Created new channel.");
return $this->redirect("/dashboard", 302);
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
$this->session->getFlash()->add("error", "Unable to create new channel.");
return $this->render('channe/create.twig')->withStatus(500);
} }
$this->session->getFlash()->add("success", "Successfully created new channel.");
} }
} }

View File

@ -3,6 +3,7 @@
namespace Slovocast\Controller; namespace Slovocast\Controller;
use Odan\Session\SessionInterface; use Odan\Session\SessionInterface;
use Slovocast\Domain\Entity\User;
use Slovocast\Domain\Repository\Channel\ChannelRepositoryInterface; use Slovocast\Domain\Repository\Channel\ChannelRepositoryInterface;
use Slovocast\Domain\Repository\User\UserRepositoryInterface; use Slovocast\Domain\Repository\User\UserRepositoryInterface;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
@ -19,6 +20,9 @@ class DashboardPage extends Controller
{ {
// get the user details // get the user details
// get the channels // get the channels
return $this->render('dashboard.twig'); $userData = $this->session->get("user");
$user = User::fromArray($userData);
$channels = $this->channelRepository->getFromUser($user);
return $this->render('dashboard.twig', [ 'channel' => $channels ]);
} }
} }