41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Teamer\Profile\Availability;
|
|
|
|
use App\Entity\Availability;
|
|
use App\Entity\User;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
|
|
class AddController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly EntityManagerInterface $entityManager,
|
|
private readonly LoggerInterface $logger
|
|
) {
|
|
}
|
|
|
|
#[Route('/teamer/profile/availability/add/{id}', name: 'app_teamer_profile_availability_add')]
|
|
#[IsGranted('ROLE_TEAMER')]
|
|
public function index(Availability $availability): Response
|
|
{
|
|
/** @var User $user */
|
|
$user = $this->getUser();
|
|
$teamer = $user->getTeamer();
|
|
|
|
$teamer->addAvailability($availability);
|
|
$this->entityManager->flush();
|
|
|
|
$this->logger->info('Add availability', [
|
|
'teamer_id' => $teamer->getId(),
|
|
'teamer_name' => (string) $teamer,
|
|
'availability' => (string) $availability,
|
|
]);
|
|
|
|
return $this->redirectToRoute('app_teamer_profile_availability_index');
|
|
}
|
|
} |