rename UserSettings to UserSetting
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20260825211700 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE TABLE user_setting (id INT AUTO_INCREMENT NOT NULL, label VARCHAR(255) NOT NULL, value VARCHAR(255) NOT NULL, user_id_id INT NOT NULL, INDEX IDX_C779A6929D86650F (user_id_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`');
|
||||||
|
$this->addSql('ALTER TABLE user_setting ADD CONSTRAINT FK_C779A6929D86650F FOREIGN KEY (user_id_id) REFERENCES `user` (id)');
|
||||||
|
$this->addSql('ALTER TABLE user_settings DROP FOREIGN KEY `FK_5C844C59D86650F`');
|
||||||
|
$this->addSql('DROP TABLE user_settings');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE TABLE user_settings (id INT AUTO_INCREMENT NOT NULL, user_id_id INT NOT NULL, label VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, value VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, INDEX IDX_5C844C59D86650F (user_id_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
|
||||||
|
$this->addSql('ALTER TABLE user_settings ADD CONSTRAINT `FK_5C844C59D86650F` FOREIGN KEY (user_id_id) REFERENCES user (id)');
|
||||||
|
$this->addSql('ALTER TABLE user_setting DROP FOREIGN KEY FK_C779A6929D86650F');
|
||||||
|
$this->addSql('DROP TABLE user_setting');
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
"watch": "encore dev --watch",
|
"watch": "encore dev --watch",
|
||||||
"dev": "concurrently --names server,assets,scheduler \"frankenphp run\" \"npm run watch\" \"frankenphp php-cli bin/console messenger:consume scheduler_scheduler_weather -vv\"",
|
"dev": "concurrently --names server,assets,scheduler \"frankenphp run\" \"npm run watch\" \"frankenphp php-cli bin/console messenger:consume scheduler_scheduler_weather -vv\"",
|
||||||
"build": "encore production --progress",
|
"build": "encore production --progress",
|
||||||
"scheduler": "frankenphp php-cli bin/console messenger:consume scheduler_scheduler_weather"
|
"dev_scheduler": "frankenphp php-cli bin/console messenger:consume scheduler_scheduler_weather"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource/noto-sans": "^5.3.0",
|
"@fontsource/noto-sans": "^5.3.0",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use App\Entity\Settings;
|
|||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
|
||||||
use App\Entity\Task;
|
use App\Entity\Task;
|
||||||
use App\Entity\UserSettings;
|
use App\Entity\UserSetting;
|
||||||
use App\Form\TaskType;
|
use App\Form\TaskType;
|
||||||
use App\Repository\TaskRepository;
|
use App\Repository\TaskRepository;
|
||||||
use App\Service\TaskRecommendationService;
|
use App\Service\TaskRecommendationService;
|
||||||
@@ -204,7 +204,7 @@ final class TaskController extends AbstractController
|
|||||||
return $this->redirectToRoute('app_task_index');
|
return $this->redirectToRoute('app_task_index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserSettings(string $label): Settings{
|
public function getUserSetting(string $label): Settings{
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
$settings = $user->getSettings();
|
$settings = $user->getSettings();
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\UserSettings;
|
use App\Entity\UserSetting;
|
||||||
use App\Form\UserSettings1Type;
|
use App\Form\UserSetting1Type;
|
||||||
use App\Repository\UserSettingsRepository;
|
use App\Repository\UserSettingRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -12,21 +12,21 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
#[Route('/user/settings')]
|
#[Route('/user/settings')]
|
||||||
final class UserSettingsController extends AbstractController
|
final class UserSettingController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route(name: 'app_user_settings_index', methods: ['GET'])]
|
#[Route(name: 'app_user_settings_index', methods: ['GET'])]
|
||||||
public function index(UserSettingsRepository $userSettingsRepository): Response
|
public function index(UserSettingRepository $UserSettingRepository): Response
|
||||||
{
|
{
|
||||||
return $this->render('user_settings/index.html.twig', [
|
return $this->render('user_settings/index.html.twig', [
|
||||||
'user_settings' => $userSettingsRepository->findAll(),
|
'user_settings' => $UserSettingRepository->findAll(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/new', name: 'app_user_settings_new', methods: ['GET', 'POST'])]
|
#[Route('/new', name: 'app_user_settings_new', methods: ['GET', 'POST'])]
|
||||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
$userSetting = new UserSettings();
|
$userSetting = new UserSetting();
|
||||||
$form = $this->createForm(UserSettings1Type::class, $userSetting);
|
$form = $this->createForm(UserSetting1Type::class, $userSetting);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
@@ -43,7 +43,7 @@ final class UserSettingsController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/{id}', name: 'app_user_settings_show', methods: ['GET'])]
|
#[Route('/{id}', name: 'app_user_settings_show', methods: ['GET'])]
|
||||||
public function show(UserSettings $userSetting): Response
|
public function show(UserSetting $userSetting): Response
|
||||||
{
|
{
|
||||||
return $this->render('user_settings/show.html.twig', [
|
return $this->render('user_settings/show.html.twig', [
|
||||||
'user_setting' => $userSetting,
|
'user_setting' => $userSetting,
|
||||||
@@ -51,9 +51,9 @@ final class UserSettingsController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/{id}/edit', name: 'app_user_settings_edit', methods: ['GET', 'POST'])]
|
#[Route('/{id}/edit', name: 'app_user_settings_edit', methods: ['GET', 'POST'])]
|
||||||
public function edit(Request $request, UserSettings $userSetting, EntityManagerInterface $entityManager): Response
|
public function edit(Request $request, UserSetting $userSetting, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
$form = $this->createForm(UserSettings1Type::class, $userSetting);
|
$form = $this->createForm(UserSetting1Type::class, $userSetting);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
@@ -69,7 +69,7 @@ final class UserSettingsController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/{id}', name: 'app_user_settings_delete', methods: ['POST'])]
|
#[Route('/{id}', name: 'app_user_settings_delete', methods: ['POST'])]
|
||||||
public function delete(Request $request, UserSettings $userSetting, EntityManagerInterface $entityManager): Response
|
public function delete(Request $request, UserSetting $userSetting, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
if ($this->isCsrfTokenValid('delete'.$userSetting->getId(), $request->getPayload()->getString('_token'))) {
|
if ($this->isCsrfTokenValid('delete'.$userSetting->getId(), $request->getPayload()->getString('_token'))) {
|
||||||
$entityManager->remove($userSetting);
|
$entityManager->remove($userSetting);
|
||||||
+12
-12
@@ -38,14 +38,14 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||||||
private ?Settings $settings = null;
|
private ?Settings $settings = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection<int, UserSettings>
|
* @var Collection<int, UserSetting>
|
||||||
*/
|
*/
|
||||||
#[ORM\OneToMany(targetEntity: UserSettings::class, mappedBy: 'user_id', orphanRemoval: true)]
|
#[ORM\OneToMany(targetEntity: UserSetting::class, mappedBy: 'user_id', orphanRemoval: true)]
|
||||||
private Collection $userSettings;
|
private Collection $UserSetting;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->userSettings = new ArrayCollection();
|
$this->UserSetting = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,26 +143,26 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection<int, UserSettings>
|
* @return Collection<int, UserSetting>
|
||||||
*/
|
*/
|
||||||
public function getUserSettings(): Collection
|
public function getUserSetting(): Collection
|
||||||
{
|
{
|
||||||
return $this->userSettings;
|
return $this->UserSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addUserSetting(UserSettings $userSetting): static
|
public function addUserSetting(UserSetting $userSetting): static
|
||||||
{
|
{
|
||||||
if (!$this->userSettings->contains($userSetting)) {
|
if (!$this->UserSetting->contains($userSetting)) {
|
||||||
$this->userSettings->add($userSetting);
|
$this->UserSetting->add($userSetting);
|
||||||
$userSetting->setUserId($this);
|
$userSetting->setUserId($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeUserSetting(UserSettings $userSetting): static
|
public function removeUserSetting(UserSetting $userSetting): static
|
||||||
{
|
{
|
||||||
if ($this->userSettings->removeElement($userSetting)) {
|
if ($this->UserSetting->removeElement($userSetting)) {
|
||||||
// set the owning side to null (unless already changed)
|
// set the owning side to null (unless already changed)
|
||||||
if ($userSetting->getUserId() === $this) {
|
if ($userSetting->getUserId() === $this) {
|
||||||
$userSetting->setUserId(null);
|
$userSetting->setUserId(null);
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Repository\UserSettingsRepository;
|
use App\Repository\UserSettingRepository;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: UserSettingsRepository::class)]
|
#[ORM\Entity(repositoryClass: UserSettingRepository::class)]
|
||||||
class UserSettings
|
class UserSetting
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
@@ -22,7 +22,7 @@ class UserSettings
|
|||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
private ?string $value = null;
|
private ?string $value = null;
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'userSettings')]
|
#[ORM\ManyToOne(inversedBy: 'UserSetting')]
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
private ?User $user_id = null;
|
private ?User $user_id = null;
|
||||||
|
|
||||||
@@ -3,13 +3,13 @@
|
|||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Entity\UserSettings;
|
use App\Entity\UserSetting;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class UserSettings1Type extends AbstractType
|
class UserSetting1Type extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
@@ -26,7 +26,7 @@ class UserSettings1Type extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => UserSettings::class,
|
'data_class' => UserSetting::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
use App\Entity\UserSettings;
|
use App\Entity\UserSetting;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class UserSettingsType extends AbstractType
|
class UserSettingType extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ class UserSettingsType extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => UserSettings::class,
|
'data_class' => UserSetting::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-6
@@ -2,22 +2,22 @@
|
|||||||
|
|
||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
use App\Entity\UserSettings;
|
use App\Entity\UserSetting;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @extends ServiceEntityRepository<UserSettings>
|
* @extends ServiceEntityRepository<UserSetting>
|
||||||
*/
|
*/
|
||||||
class UserSettingsRepository extends ServiceEntityRepository
|
class UserSettingRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
public function __construct(ManagerRegistry $registry)
|
public function __construct(ManagerRegistry $registry)
|
||||||
{
|
{
|
||||||
parent::__construct($registry, UserSettings::class);
|
parent::__construct($registry, UserSetting::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @return UserSettings[] Returns an array of UserSettings objects
|
// * @return UserSetting[] Returns an array of UserSetting objects
|
||||||
// */
|
// */
|
||||||
// public function findByExampleField($value): array
|
// public function findByExampleField($value): array
|
||||||
// {
|
// {
|
||||||
@@ -31,7 +31,7 @@ class UserSettingsRepository extends ServiceEntityRepository
|
|||||||
// ;
|
// ;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// public function findOneBySomeField($value): ?UserSettings
|
// public function findOneBySomeField($value): ?UserSetting
|
||||||
// {
|
// {
|
||||||
// return $this->createQueryBuilder('u')
|
// return $this->createQueryBuilder('u')
|
||||||
// ->andWhere('u.exampleField = :val')
|
// ->andWhere('u.exampleField = :val')
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
{% extends 'base.html.twig' %}
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
{% block title %}Edit UserSettings{% endblock %}
|
{% block title %}Edit UserSetting{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>Edit UserSettings</h1>
|
<h1>Edit UserSetting</h1>
|
||||||
|
|
||||||
{{ include('user_settings/_form.html.twig', {'button_label': 'Update'}) }}
|
{{ include('user_settings/_form.html.twig', {'button_label': 'Update'}) }}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{% extends 'base.html.twig' %}
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
{% block title %}UserSettings index{% endblock %}
|
{% block title %}UserSetting index{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>UserSettings index</h1>
|
<h1>UserSetting index</h1>
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{% extends 'base.html.twig' %}
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
{% block title %}New UserSettings{% endblock %}
|
{% block title %}New UserSetting{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>Create new UserSettings</h1>
|
<h1>Create new UserSetting</h1>
|
||||||
|
|
||||||
{{ include('user_settings/_form.html.twig') }}
|
{{ include('user_settings/_form.html.twig') }}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{% extends 'base.html.twig' %}
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
{% block title %}UserSettings{% endblock %}
|
{% block title %}UserSetting{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>UserSettings</h1>
|
<h1>UserSetting</h1>
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user