Rename offering to offer
This commit is contained in:
		
							parent
							
								
									a7b4bf09e4
								
							
						
					
					
						commit
						f54f663fb0
					
				
					 12 changed files with 90 additions and 59 deletions
				
			
		|  | @ -35,7 +35,7 @@ widget.start() | |||
| 
 | ||||
| // Dsiplay Filename when uploading
 | ||||
| document.querySelector('.custom-file-input').addEventListener('change', function (e) { | ||||
|     var fileName = document.getElementById('offering_form_photo').files[0].name; | ||||
|     var fileName = document.getElementById('offer_form_photo').files[0].name; | ||||
|     var nextSibling = e.target.nextElementSibling | ||||
|     nextSibling.innerText = fileName | ||||
| }) | ||||
|  |  | |||
							
								
								
									
										31
									
								
								migrations/Version20220119172053.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								migrations/Version20220119172053.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| <?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 Version20220119172053 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('RENAME TABLE offering TO offer'); | ||||
|     } | ||||
| 
 | ||||
|     public function down(Schema $schema): void | ||||
|     { | ||||
|         // this down() migration is auto-generated, please modify it to your needs
 | ||||
|         $this->addSql('RENAME TABLE offer TO offering'); | ||||
|     } | ||||
| } | ||||
|  | @ -3,7 +3,7 @@ | |||
| namespace App\Controller\Admin; | ||||
| 
 | ||||
| use App\Entity\User; | ||||
| use App\Entity\Offering; | ||||
| use App\Entity\Offer; | ||||
| use App\Entity\Wish; | ||||
| use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; | ||||
| use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; | ||||
|  | @ -36,7 +36,7 @@ class DashboardController extends AbstractDashboardController | |||
|         yield MenuItem::linktoRoute('Back to the website', 'fas fa-arrow-left', 'offers'); | ||||
|         yield MenuItem::linktoDashboard('Dashboard', 'fa fa-home'); | ||||
|         yield MenuItem::linkToCrud('User', 'fas fa-user', User::class); | ||||
|         yield MenuItem::linkToCrud('Offering', 'fas fa-seedling', Offering::class); | ||||
|         yield MenuItem::linkToCrud('Offer', 'fas fa-seedling', Offer::class); | ||||
|         yield MenuItem::linkToCrud('Wish', 'fas fa-star', Wish::class); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ | |||
| 
 | ||||
| namespace App\Controller\Admin; | ||||
| 
 | ||||
| use App\Entity\Offering; | ||||
| use App\Entity\Offer; | ||||
| use App\Entity\User; | ||||
| 
 | ||||
| use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; | ||||
|  | @ -13,11 +13,11 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
| use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | ||||
| use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; | ||||
| 
 | ||||
| class OfferingCrudController extends AbstractCrudController | ||||
| class OfferCrudController extends AbstractCrudController | ||||
| { | ||||
|     public static function getEntityFqcn(): string | ||||
|     { | ||||
|         return Offering::class; | ||||
|         return Offer::class; | ||||
|     } | ||||
| 
 | ||||
|     public function configureFields(string $pageName): iterable | ||||
|  | @ -2,11 +2,11 @@ | |||
| 
 | ||||
| namespace App\Controller; | ||||
| 
 | ||||
| use App\Entity\Offering; | ||||
| use App\Form\OfferingFormType; | ||||
| use App\Entity\Offer; | ||||
| use App\Form\OfferFormType; | ||||
| use App\Form\OfferFilterFormType; | ||||
| 
 | ||||
| use App\Repository\OfferingRepository; | ||||
| use App\Repository\OfferRepository; | ||||
| use App\Repository\WishRepository; | ||||
| 
 | ||||
| use App\Service\PlzToCoordinate; | ||||
|  | @ -33,7 +33,7 @@ class OfferController extends AbstractController | |||
|     } | ||||
| 
 | ||||
|     #[Route('/offers', name: 'offers', options: ["sitemap" => true])]
 | ||||
|     public function showAll(Environment $twig, Request $request, OfferingRepository $offerRepository, PlzToCoordinate $plzconverter, DistanceCalculator $distanceCalculator): Response | ||||
|     public function showAll(Environment $twig, Request $request, OfferRepository $offerRepository, PlzToCoordinate $plzconverter, DistanceCalculator $distanceCalculator): Response | ||||
|     { | ||||
|         $form = $this->createForm(OfferFilterFormType::class); | ||||
|         $form->handleRequest($request); | ||||
|  | @ -74,8 +74,8 @@ class OfferController extends AbstractController | |||
|     #[Route('/new', name: 'new_offer')]
 | ||||
|     public function newOffer(Request $request, PlzToCoordinate $plzconverter, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response | ||||
|     { | ||||
|         $offer = new Offering(); | ||||
|         $form = $this->createForm(OfferingFormType::class, $offer); | ||||
|         $offer = new Offer(); | ||||
|         $form = $this->createForm(OfferFormType::class, $offer); | ||||
|         $user = $this->getUser();  | ||||
| 
 | ||||
|         $form->handleRequest($request); | ||||
|  | @ -110,7 +110,7 @@ class OfferController extends AbstractController | |||
|     } | ||||
| 
 | ||||
|     #[Route('/offer/{urlId}', name: 'show_offer')]
 | ||||
|     public function showOffer(Offering $offer, WishRepository $wishRepository, PlzToCoordinate $plzconverter, DistanceCalculator $distanceCalculator): Response | ||||
|     public function showOffer(Offer $offer, WishRepository $wishRepository, PlzToCoordinate $plzconverter, DistanceCalculator $distanceCalculator): Response | ||||
|     { | ||||
|         $distance = null; | ||||
|         $user = $this->getUser(); | ||||
|  | @ -144,9 +144,9 @@ class OfferController extends AbstractController | |||
|     } | ||||
| 
 | ||||
|     #[Route('/offer/edit/{urlId}', name: 'edit_offer')]
 | ||||
|     public function editOffer(Offering $offer, OfferingRepository $offerRepository, Request $request, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response | ||||
|     public function editOffer(Offer $offer, OfferRepository $offerRepository, Request $request, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response | ||||
|     { | ||||
|         $form = $this->createForm(OfferingFormType::class, $offer); | ||||
|         $form = $this->createForm(OfferFormType::class, $offer); | ||||
|         $user = $this->getUser(); | ||||
|         if ($offer->getByUser() === $user) | ||||
|         { | ||||
|  | @ -177,7 +177,7 @@ class OfferController extends AbstractController | |||
|     } | ||||
| 
 | ||||
|     #[Route('/offer/delete/{urlId}', name: 'delete_offer')]
 | ||||
|     public function deleteOffer(Offering $offer, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response | ||||
|     public function deleteOffer(Offer $offer, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response | ||||
|     { | ||||
|         $user = $this->getUser();  | ||||
| 
 | ||||
|  | @ -200,13 +200,13 @@ class OfferController extends AbstractController | |||
|     } | ||||
| 
 | ||||
|     #[Route('/myoffers', name: 'own_offers')]
 | ||||
|     public function ownOffers(OfferingRepository $offeringRepository): Response | ||||
|     public function ownOffers(OfferRepository $offerRepository): Response | ||||
|     { | ||||
|         $user = $this->getUser(); | ||||
| 
 | ||||
|         return $this->render('user/offers.html.twig', [ | ||||
|             'user' => $user, | ||||
|             'offers' => $offeringRepository->findByUser($user), | ||||
|             'offers' => $offerRepository->findByUser($user), | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -3,9 +3,9 @@ | |||
| namespace App\Controller; | ||||
| 
 | ||||
| use App\Entity\User; | ||||
| use App\Entity\Offering; | ||||
| use App\Entity\Offer; | ||||
| 
 | ||||
| use App\Repository\OfferingRepository; | ||||
| use App\Repository\OfferRepository; | ||||
| use App\Repository\WishRepository; | ||||
| 
 | ||||
| use Symfony\Bridge\Twig\Mime\TemplatedEmail; | ||||
|  | @ -20,7 +20,7 @@ use Symfony\Component\Routing\Annotation\Route; | |||
| class TradeController extends AbstractController | ||||
| { | ||||
|     #[Route('/trade/{urlId}', name: 'trade')]
 | ||||
|     public function sendEmail(MailerInterface $mailer, Offering $offer, OfferingRepository $offeringRepository, WishRepository $wishRepository): Response | ||||
|     public function sendEmail(MailerInterface $mailer, Offer $offer, OfferRepository $offerRepository, WishRepository $wishRepository): Response | ||||
|     { | ||||
|         $user = $this->getUser(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ use App\Entity\User; | |||
| use App\Form\WishFormType; | ||||
| use App\Form\ChangePasswordFormType; | ||||
| 
 | ||||
| use App\Repository\OfferingRepository; | ||||
| use App\Repository\OfferRepository; | ||||
| use App\Repository\WishRepository; | ||||
| 
 | ||||
| use Doctrine\ORM\EntityManagerInterface; | ||||
|  | @ -30,7 +30,7 @@ class UserController extends AbstractController | |||
|     } | ||||
| 
 | ||||
|     #[Route('/user', name: 'user_page')]
 | ||||
|     public function user(OfferingRepository $offeringRepository, Request $request, UserPasswordHasherInterface $passwordEncoder): Response | ||||
|     public function user(OfferRepository $offerRepository, Request $request, UserPasswordHasherInterface $passwordEncoder): Response | ||||
|     { | ||||
|         $user = $this->getUser(); | ||||
| 
 | ||||
|  | @ -64,23 +64,23 @@ class UserController extends AbstractController | |||
|     } | ||||
| 
 | ||||
|     #[Route('/user/offers', name: 'user_offers')]
 | ||||
|     public function userOffers(OfferingRepository $offeringRepository): Response | ||||
|     public function userOffers(OfferRepository $offerRepository): Response | ||||
|     { | ||||
|         $user = $this->getUser(); | ||||
| 
 | ||||
|         return $this->render('user/public.html.twig', [ | ||||
|             'user' => $user, | ||||
|             'offers' => $offeringRepository->findByUser($user), | ||||
|             'offers' => $offerRepository->findByUser($user), | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     #[Route('/user/{urlId}', name: 'user_public')]
 | ||||
|     public function show_user(User $user, OfferingRepository $offeringRepository, WishRepository $wishRepository): Response | ||||
|     public function show_user(User $user, OfferRepository $offerRepository, WishRepository $wishRepository): Response | ||||
|     { | ||||
|         return $this->render('user/public.html.twig', [ | ||||
|             'username' => $user->getUsername(), | ||||
|             'wishes' => $wishRepository->findByUser($user), | ||||
|             'offers' => $offeringRepository->findByUser($user), | ||||
|             'offers' => $offerRepository->findByUser($user), | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,15 +2,15 @@ | |||
| 
 | ||||
| namespace App\Entity; | ||||
| 
 | ||||
| use App\Repository\OfferingRepository; | ||||
| use App\Repository\OfferRepository; | ||||
| use Doctrine\ORM\Mapping as ORM; | ||||
| use Location\Coordinate; | ||||
| use Symfony\Component\Validator\Constraints as Assert; | ||||
| 
 | ||||
| /** | ||||
|  * @ORM\Entity(repositoryClass=OfferingRepository::class) | ||||
|  * @ORM\Entity(repositoryClass=OfferRepository::class) | ||||
|  */ | ||||
| class Offering | ||||
| class Offer | ||||
| { | ||||
|     /** | ||||
|      * @ORM\Id | ||||
|  | @ -20,7 +20,7 @@ class Offering | |||
|     private $id; | ||||
| 
 | ||||
|     /** | ||||
|      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="offerings") | ||||
|      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="offers") | ||||
|      * @ORM\JoinColumn(nullable=false) | ||||
|      */ | ||||
|     private $byUser; | ||||
|  | @ -51,9 +51,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface | |||
|     private $username; | ||||
| 
 | ||||
|     /** | ||||
|      * @ORM\OneToMany(targetEntity=Offering::class, mappedBy="byUser", orphanRemoval=true) | ||||
|      * @ORM\OneToMany(targetEntity=Offer::class, mappedBy="byUser", orphanRemoval=true) | ||||
|      */ | ||||
|     private $offerings; | ||||
|     private $offers; | ||||
| 
 | ||||
|     /** | ||||
|      * @ORM\OneToMany(targetEntity=Wish::class, mappedBy="byUser") | ||||
|  | @ -72,7 +72,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface | |||
| 
 | ||||
|     public function __construct() | ||||
|     { | ||||
|         $this->offerings = new ArrayCollection(); | ||||
|         $this->offers = new ArrayCollection(); | ||||
|         $this->wishes = new ArrayCollection(); | ||||
|     } | ||||
| 
 | ||||
|  | @ -185,29 +185,29 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @return Collection|Offering[] | ||||
|      * @return Collection|Offer[] | ||||
|      */ | ||||
|     public function getOfferings(): Collection | ||||
|     public function getOffers(): Collection | ||||
|     { | ||||
|         return $this->offerings; | ||||
|         return $this->offers; | ||||
|     } | ||||
| 
 | ||||
|     public function addOffering(Offering $offering): self | ||||
|     public function addOffer(Offer $offer): self | ||||
|     { | ||||
|         if (!$this->offerings->contains($offering)) { | ||||
|             $this->offerings[] = $offering; | ||||
|             $offering->setByUser($this); | ||||
|         if (!$this->offers->contains($offer)) { | ||||
|             $this->offers[] = $offer; | ||||
|             $offer->setByUser($this); | ||||
|         } | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function removeOffering(Offering $offering): self | ||||
|     public function removeOffer(Offer $offer): self | ||||
|     { | ||||
|         if ($this->offerings->removeElement($offering)) { | ||||
|         if ($this->offers->removeElement($offer)) { | ||||
|             // set the owning side to null (unless already changed)
 | ||||
|             if ($offering->getByUser() === $this) { | ||||
|                 $offering->setByUser(null); | ||||
|             if ($offer->getByUser() === $this) { | ||||
|                 $offer->setByUser(null); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ | |||
| 
 | ||||
| namespace App\Form; | ||||
| 
 | ||||
| use App\Entity\Offering; | ||||
| use App\Entity\Offer; | ||||
| use Symfony\Component\Form\AbstractType; | ||||
| use Symfony\Component\Form\Extension\Core\Type\FileType; | ||||
| use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
|  | @ -12,7 +12,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; | |||
| use Symfony\Component\Validator\Constraints\Image; | ||||
| use Symfony\Component\Validator\Constraints\NotBlank; | ||||
| 
 | ||||
| class OfferingFormType extends AbstractType | ||||
| class OfferFormType extends AbstractType | ||||
| { | ||||
|     public function buildForm(FormBuilderInterface $builder, array $options) | ||||
|     { | ||||
|  | @ -43,7 +43,7 @@ class OfferingFormType extends AbstractType | |||
|     public function configureOptions(OptionsResolver $resolver) | ||||
|     { | ||||
|         $resolver->setDefaults([ | ||||
|             'data_class' => Offering::class, | ||||
|             'data_class' => Offer::class, | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
|  | @ -2,25 +2,25 @@ | |||
| 
 | ||||
| namespace App\Repository; | ||||
| 
 | ||||
| use App\Entity\Offering; | ||||
| use App\Entity\Offer; | ||||
| use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||||
| use Doctrine\Persistence\ManagerRegistry; | ||||
| 
 | ||||
| /** | ||||
|  * @method Offering|null find($id, $lockMode = null, $lockVersion = null) | ||||
|  * @method Offering|null findOneBy(array $criteria, array $orderBy = null) | ||||
|  * @method Offering[]    findAll() | ||||
|  * @method Offering[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
|  * @method Offer|null find($id, $lockMode = null, $lockVersion = null) | ||||
|  * @method Offer|null findOneBy(array $criteria, array $orderBy = null) | ||||
|  * @method Offer[]    findAll() | ||||
|  * @method Offer[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||||
|  */ | ||||
| class OfferingRepository extends ServiceEntityRepository | ||||
| class OfferRepository extends ServiceEntityRepository | ||||
| { | ||||
|     public function __construct(ManagerRegistry $registry) | ||||
|     { | ||||
|         parent::__construct($registry, Offering::class); | ||||
|         parent::__construct($registry, Offer::class); | ||||
|     } | ||||
| 
 | ||||
|     // /**
 | ||||
|     //  * @return Offering[] Returns an array of Offering objects
 | ||||
|     //  * @return Offer[] Returns an array of Offer objects
 | ||||
|     //  */
 | ||||
|     public function findByUser($user) | ||||
|     { | ||||
|  | @ -45,7 +45,7 @@ class OfferingRepository extends ServiceEntityRepository | |||
|     } | ||||
| 
 | ||||
|     /* | ||||
|     public function findOneBySomeField($value): ?Offering | ||||
|     public function findOneBySomeField($value): ?Offer | ||||
|     { | ||||
|         return $this->createQueryBuilder('o') | ||||
|             ->andWhere('o.exampleField = :val') | ||||
|  | @ -2,7 +2,7 @@ | |||
| 
 | ||||
| namespace App\Service; | ||||
| 
 | ||||
| use App\Entity\Offering; | ||||
| use App\Entity\Offer; | ||||
| 
 | ||||
| use Psr\Log\LoggerInterface; | ||||
| use Symfony\Component\Filesystem\Exception\IOExceptionInterface; | ||||
|  | @ -18,7 +18,7 @@ class OfferPhotoHelper | |||
|         $this->filesystem = new Filesystem(); | ||||
|     } | ||||
| 
 | ||||
|     public function uploadOfferPhoto(string $photoDir, UploadedFile $photo, Offering $offer) | ||||
|     public function uploadOfferPhoto(string $photoDir, UploadedFile $photo, Offer $offer) | ||||
|     { | ||||
|         $filename = uniqid().'.'.$photo->guessExtension(); | ||||
|         try { | ||||
|  |  | |||
		Reference in a new issue