I am trying to create 3 users in my project:
- Client : who will access the interface and have the field name ',' CPF ',' address'.
- Vendor : who will register offers on a site and have fields "phone", "CNPJ"
- Admin : who will manage all the client, tenders, offers, etc.
So, I installed 3 packages for this: SonataUserBundle + FosUserBundle + SonataAdminBundle I followed the entire tutorial for each of them. But I do not know how I can create each type of these users.
I use ApplicationSonataUserBundle which generate User and Group entities.
Here is my code:
namespace Sete\UserBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Application\Sonata\UserBundle\Entity\User as BaseUser; class Cliente extends BaseUser { protected $id; ...another fields... }
and Vendor:
namespace Sete\UserBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; use Application\Sonata\UserBundle\Entity\User as BaseUser; class Vendedor extends BaseUser { protected $id; ...another fields... }
AppKernel.php
... new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'), new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(), new Application\Sonata\UserBundle\ApplicationSonataUserBundle()
And config.yml
... fos_user: db_driver: orm
Thus, my Cliente and Vendor objects have no connection with groups. I am trying to add a $ groups relationship but not working. Therefore, when I try to administer these entities, I received an error:
An exception occurred while executing 'SELECT count (DISTINCT c0_.id) AS sclr0 FROM cliente c0_ LEFT JOIN fos_user_user_group f3_ ON f2_.id = f3_.user_id LEFT JOIN fos_user_group f1_ ON f1_.id = f3_.group
SQLSTATE [42S22]: column not found: 1054 Unknown column 'f2_.id' in 'on item "
Is this the best rating for creating user types? Or instead of the ApplicationUserBundle: extension, the user creates Cliente and Vendor objects (without the ApplicationUserBundle: User extensions), and then create relationships with the user (by placing the $ cliente and $ vendor fields inside the user object and creating the relationship)?
Sorry for the English. I have been trying to do this all week. Follow many tutorials but don't get an answer.
thanks all.