1. Go to this page and download the library: Download patel/chatbot-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Chatbot\Security\ChatbotUserInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
class Admin implements ChatbotUserInterface
{
#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserQuestion::class)]
private Collection $questions;
public function __construct()
{
$this->questions = new ArrayCollection();
}
public function getQuestions(): Collection
{
return $this->questions;
}
}
namespace App\Entity;
use Chatbot\Entity\ChatbotUserQuestion as BaseQuestion;
use Chatbot\Security\ChatbotUserInterface;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: 'chatbot_user_question')]
class UserQuestion extends BaseQuestion
{
#[ORM\ManyToOne(targetEntity: Admin::class, inversedBy: 'questions')]
#[ORM\JoinColumn(nullable: false)]
private ChatbotUserInterface $user;
public function getUser(): ChatbotUserInterface
{
return $this->user;
}
public function setUser(ChatbotUserInterface $user): static
{
$this->user = $user;
return $this;
}
}
declare(strict_types=1);
namespace App\Repository;
use App\Entity\UserQuestion;
use Chatbot\Repository\UserQuestionRepositoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<ClientNote>
*/
class UserQuestionRepository extends ServiceEntityRepository implements UserQuestionRepositoryInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, UserQuestion::class);
}
}