PHP code example of ciebit / legislation

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

    

ciebit / legislation example snippets




use Ciebit\Legislation\Documents\Factories\Law as LawFactory;
use Ciebit\Legislation\Documents\Storages\Databases\Sql;

$lawFactory = new Factory();
$lawFactory->setTitle('Law 12.345/2020')
    ->setDateTime(new DateTime('2020-02-06'))
    ->setStatus(Status::ACTIVE())
    ->setNumber(12345)
    ->setSlug('law-2020')
    ->setDescription('Defines rules for the construction of public schools.');

$law = $lawFactory->create();

$storage = new Sql(new PDO(/** your settings */));
$id = $storage->store($law);



use Ciebit\Legislation\Documents\Storages\Databases\Sql;
use Ciebit\Legislation\Documents\Decree;
use Ciebit\Legislation\Documents\Status;

$storage = new Sql(new PDO(/** your settings */));
$documentCollection = $storage
    ->addFilterByType('=', Decree::class)
    ->addFilterByStatus(Status::ACTIVE())
    ->find();

foreach($documentCollection as $decree) {
    echo "{$decree->getTitle()}" . PHP_EOL;
}