Add Wanted Vehicle list

This commit is contained in:
Xbird
2022-10-07 21:10:20 +00:00
parent 2f53709b3c
commit bb78e7e802
13 changed files with 256 additions and 2 deletions

View File

@@ -0,0 +1,115 @@
<?php
namespace App\Entity;
use App\Entity\Document;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Repository\WantedvehicleRepository;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=WantedvehicleRepository::class)
*/
class Wantedvehicle extends Document
{
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Versioned
*/
private $type;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Gedmo\Versioned
*/
private $numberplate;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Gedmo\Versioned
*/
private $model;
/**
* @ORM\Column(type="text", length=65535, nullable=true)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Gedmo\Versioned
*/
private $color;
public function __construct(User $user)
{
parent::__construct($user);
$this->setNeedLegalAccess(true);
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getNumberplate(): ?string
{
return $this->numberplate;
}
public function setNumberplate(?string $numberplate): self
{
$this->numberplate = $numberplate;
return $this;
}
public function getModel(): ?string
{
return $this->model;
}
public function setModel(?string $model): self
{
$this->model = $model;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(?string $color): self
{
$this->color = $color;
return $this;
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Form;
use App\Form\DocumentType;
use App\Entity\Wantedvehicle;
use App\Form\Type\ContentType;
use App\Form\Type\VehicleType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class WantedvehicleType extends DocumentType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder
->add('type', VehicleType::class)
->add('numberplate', null, ['label' => 'form_label_numberplate'])
->add('model', null, ['label' => 'form_label_model'])
->add('color', null, ['label' => 'form_label_color'])
->add('content', ContentType::class, ['label' => 'form_label_informations', 'required' => false])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Wantedvehicle::class,
]);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Repository;
use App\Entity\Wantedvehicle;
use Doctrine\Persistence\ManagerRegistry;
use App\Repository\Tools\DocumentRepositoriesExtension;
/**
* @method Wantedvehicle|null find($id, $lockMode = null, $lockVersion = null)
* @method Wantedvehicle|null findOneBy(array $criteria, array $orderBy = null)
* @method Wantedvehicle[] findAll()
* @method Wantedvehicle[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class WantedvehicleRepository extends DocumentRepositoriesExtension
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Wantedvehicle::class);
$this->fields = ['type', 'numberplate','model', 'content', 'color']; //with title, list fields we can search in
}
}