PHP code example of letkode / orm-toolkit-bundle

1. Go to this page and download the library: Download letkode/orm-toolkit-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/ */

    

letkode / orm-toolkit-bundle example snippets


// config/bundles.php
return [
    Letkode\OrmToolkitBundle\LetkodeOrmToolkitBundle::class => ['all' => true],
];

use Letkode\OrmToolkitBundle\Trait\Entity\UuidTrait;

#[ORM\Entity]
class Product
{
    use UuidTrait;
}

$entity->setTranslation('es', 'name', 'Producto');
$entity->getTranslation('es', 'name'); // 'Producto'

$entity->setParameter('color', 'red');
$entity->getParameter('color'); // 'red'
$entity->setParameters(['size' => 'L'], force: false); // recursive merge

use Letkode\QueryFilterBundle\Request\FilterQueryRequest;

$repo->save($entity);
$repo->remove($entity);
$repo->findByUuid($uuid);           // returns T|null
$repo->findOrFailByUuid($uuid);     // throws EntityNotFoundException
$repo->paginate($qb, $query, sortable: ['name'], searchable: ['name', 'email']);
// $query is a Letkode\QueryFilterBundle\Request\FilterQueryRequest

$qb = $this->createQueryBuilder('c')->join('c.person', 'p');

$repo->paginate(
    $qb,
    $query,
    sortable:   ['createdAt', 'p.lastName'],
    searchable: ['p.firstName', 'p.lastName', 'p.email'],
);

$this->addTranslatedOrderBy($qb, 'p', 'name', $locale, 'ASC');
$this->addTranslatedSearch($qb, 'p', 'name', $searchTerm, $locale);

$email = new Email('  [email protected]  '); // '[email protected]'
$slug  = new Slug('My Product Name');        // 'my-product-name'