'Symfony - fixtures load throw unexpected error
In my Symfony 6 project, I am trying to load a fixture:
/**
* @param ObjectManager $manager
*/
public function load(ObjectManager $manager): void
{
$manager1 = $manager;
$manager1->persist($this->persistCompanyOne());
$manager1->flush();
}
private function persistCompanyOne(): Company
{
$company = new Company();
$company->setCompanyName('Company One');
return $company;
}
And my Company entity:
/**
* @ORM\Column(type="string", length=180, nullable=false)
*/
private string $companyName;
/**
* @return string
*/
public function getCompanyName(): string
{
return $this->name;
}
/**
* @param mixed
* @return Company
*/
public function setCompanyName(string $name): Company
{
$this->name = $name;
return $this;
}
When running php bin/console doctrine:fixtures:load
I get an error:
Integrity constraint violation: 1048 Column 'company_name' cannot be null
Can not figure out what can be the problem? it's pretty straightforward..
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|