I am currently building a package for ConcreteCMS to give users an access to an invoice list.
I use this Doctrine entity to store invoices:
/**
* @Entity
* @Table(name="CommunityStoreSi3bEcommerceUserInvoices")
*/
class UserInvoice {
/**
* @Id
* @Column(type="integer")
* @GeneratedValue
*/
protected ?int $id;
/**
* @ManyToOne(targetEntity="ConcreteCoreUserUser", nullable=false)
*/
protected ?User $user;
/**
* @Column(nullable=true)
* @ManyToOne(targetEntity="ConcretePackageCommunityStoreSrcCommunityStoreOrderOrder")
*/
protected ?Order $order;
/**
* @Column(type="text", nullable=false)
*/
protected ?string $invoice_uid;
/**
* @Column(type="datetime", nullable=false)
*/
protected ?DateTime $created_at;
And on my controller, I do this to get invoices from the current user:
$invoices = $em->getRepository(UserInvoice::class)->findBy(['user' => $u]);
With $u
being an instance of ConcreteCoreUserUser
. Yet, I get this error message from Doctrine:
An exception occurred while executing 'SELECT t0.id AS id_1, t0.user AS user_2, t0.order AS order_3, t0.invoice_uuid AS invoice_uuid_4, t0.created_at AS created_at_5 FROM CommunityStoreSi3bEcommerceUserInvoices t0 WHERE t0.user = ?' with params [{"error":"","uID":2,"uName":"QuentinD","uGroups":{"2":2,"3":3,"1":1},"superUser":false,"uTimezone":null}]: Object of class ConcreteCoreUserUser could not be converted to string
Trying to work around this with findBy(['user' => $u->getUserID()])
I get a TypeError Cannot assign string to property UserInvoice::$user of type ?ConcreteCoreUserUser
.
Do you have any idea why ?
user26333271 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3