PHP code example of jeyroik / extas-repositories-fields-uuid
1. Go to this page and download the library: Download jeyroik/extas-repositories-fields-uuid 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/ */
jeyroik / extas-repositories-fields-uuid example snippets
namespace example;
use extas\components\repositories\Repository;
use extas\components\Item;
use extas\components\THasId;
class Example extends Item
{
use THasId;
public function getUuid()
{
return $this->config['uuid'] ?? '';
}
protected function getSubjectForExtension() : string
{
return 'example';
}
}
class ExampleRepo extends Repository
{
protected string $name = 'example';
protected string $itemClass = Example::class;
}
use example\Example;
use example\ExampleRepo;
$example = new Example(['uuid' => '@uuid4']);
$repo = new ExampleRepo();
$created = $repo->create($example);
echo $created->getUuid(); // something like af29a3f4-f865-3a4a-8a87-dc8dc0b813cr