Category : filter

I’m using Symfony5 and ApiPlatform I’m trying to sort user through their product property which is a ManyToOne property pointing to the Product entity. To do so I’ve implemented User.php as follow : /** * @ApiResource( * attributes={ * "normalization_context"={"groups"={"user:read", "user:list"}}, * "order"={"someotherfield.start": "ASC"} * }, * collectionOperations={ * "get"={ * "mehtod"="GET", * "security"="is_granted(‘ROLE_CLIENT’) or ..

Read more

I’m trying to create a custom filter using symfony and api platform : $parameterName = $queryNameGenerator->generateParameterName($property); $queryBuilder ->andWhere(sprintf(‘o.address LIKE :%s’, $parameterName)) ->orWhere(sprintf(‘o.email LIKE :%s’, $parameterName)) ->orWhere(sprintf(‘o.firstName LIKE :%s’, $parameterName)) ->orWhere(sprintf(‘o.lastName LIKE :%s’, $parameterName)) ->orWhere(sprintf(‘o.city LIKE :%s’, $parameterName)) ->orWhere(sprintf(‘o.phone LIKE :%s’, $parameterName)) ->setParameter($parameterName, ‘%’.$value.’%’); the dd($queryBuilder->getDQL()) give : The search by address doesn’t work if i ..

Read more

I’m trying to create a custom search filter to an abstract class, i want to be able to search by one keyword . The search filter code : public function getDescription(string $resourceClass): array { $reader = new AnnotationReader(); $annotation = $reader->getClassAnnotation(new ReflectionClass(new $resourceClass), SearchAnnotation::class); $description[‘search’] = [ ‘property’ => ‘search’, ‘type’ => ‘string’, ‘required’ => ..

Read more

I use abstract class to create inheritance . * @ORMInheritanceType("JOINED") * @ORMDiscriminatorColumn(name="status", type="string") * @ORMDiscriminatorMap({ * "ContactAcquereur" = "ContactAcquereur", * "ContactNegociateur" = "ContactNegociateur", * "ContactVendeur" = "ContactVendeur", * }) */ abstract class AbstractContact implements InterfaceContact i create a status params in the parent class and i use this param to get the type of the ..

Read more

I’ve an Symfony 4 Api Project which has to filter their Result by an RQL String. Request: localhost/api?q=altProductId=in=(456) The altProductId is not part of database. It is added by the controller. The Output is a JSONResponse like: Response: { “data”: [ {“altProductId”: 123}, {“altProductId”: 456}, {“altProductId”: 789} ] } And it should be for the ..

Read more