Category : datetime

Im serializeing an object that contains DateTimeImmutable fields (creadted_ad, updated_at). When using a serialization object as dependecnyc injection it’s all good. But then i’m writing an unit tests and my first problem is that serializer doesn’t see the @Groups (after serialization there are fields taht are restricted by @Group annotation,btw. its working well with symfony ..

Read more

Hello im triying to get on my dashboard only the most recent articles but isnt working i did this function public function PostsRecientes(){ return $this->getEntityManager() ->createQuery(‘ SELECT post FROM App:Posts post WHERE post.fechaPublicacion > CURRENT_DATE()’) ->getResult(); } and this in my dashboardcontroller /** * @Route("/", name="dashboard") */ public function index(PaginatorInterface $paginator, Request $request): Response { ..

Read more

After a "composer update" on my Symfony porject, I have this error inside my repository: class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, User::class); } public function countOnlineUsers(): int { return $this->createQueryBuilder(‘u’) ->select(‘count(u) as userOnline’) ->where(‘u.lastSeenDate >= :time’) ->setParameter(‘time’, (new DateTime())->modify(‘-15 minutes’)) ->getQuery() ->getSingleScalarResult() ; } I use new DateTime() ..

Read more

I wrote a method within Doctrine to prevent overlapping of new dates that I want to add. I have startDate and endDate there: |———————|——————| | startDate | endDate | |———————|——————| | 07-11-2020 | 13-11-2020 | |———————|——————| | 14-11-2020 | 21-11-2020 | |———————|——————| When I input 4-11 to 15-11 / Exception is thrown as it should ..

Read more

I have a method to return results from db from startDate to endDate passing in like parameters in postman. Everything seems to be working fine but it returns all results from database. I think that problem could be with parameters.. public function getInvoices($fromDate = null, $toDate = null) { $query = $this->entityManager->getRepository(Invoice::class) ->createQueryBuilder(‘ur’) ->select(‘ur’) ->orderBy(‘ur.invoiceDate’, ..

Read more