PHP code example of wiserwebsolutions / laravel-lobbyist
1. Go to this page and download the library: Download wiserwebsolutions/laravel-lobbyist 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/ */
wiserwebsolutions / laravel-lobbyist example snippets
use WiserWebSolutions\Lobbyist\Facades\Lobbyist;
// Uses the LegiScan default driver (nationwide coverage).
$ca = Lobbyist::state('CA');
$bills = $ca->bills(); // BillCollection
$bill = $ca->bill('AB1'); // Bill (lookup by number)
// Uses the PA driver if laravel-palegis is installed, else the LegiScan default.
$pa = Lobbyist::state('PA');
$votes = $pa->votes(); // VoteCollection
$house = $pa->representatives(); // LegislatorCollection, House only
$senate = $pa->senators(); // LegislatorCollection, Senate only
$all = $pa->legislators(); // LegislatorCollection, both chambers
$pa = Lobbyist::state('PA');
$pa->chambers(); // ChamberCollection (House, then Senate)
$pa->chambers()->first()->bills(); // BillCollection, House only
$pa->chambers()->first()->votes(); // VoteCollection, House only
$pa->chambers()->first()->representatives(); // LegislatorCollection, House only
$pa->session(); // Session — the most recent non-prior, non-sine-die session
use WiserWebSolutions\Lobbyist\Contracts\Capability;
use WiserWebSolutions\Lobbyist\Contracts\Providers\BillLookup;
$driver = Lobbyist::state('CA'); // LegiScan
if ($driver->supports(Capability::GetBill)) {
$bill = $driver->bill(1132030); // Bill
}
// or type-check the segregated interface directly:
if ($driver instanceof BillLookup) {
$bill = $driver->bill('AB1');
}
$ca = Lobbyist::state('CA');
$ca->billText(1132030); // BillText — the most recent version
$ca->billTextHistory(1132030); // BillTextCollection — every version
$text = $ca->billText(1132030);
$text->type; // e.g. "Enrolled"
$text->url; // link to view/download this version
$text->content; // the document's bytes, if the driver fetched them — otherwise null
$bill = $ca->bill(1132030);
$bill->texts(); // BillTextCollection — every version, oldest first
$bill->text(); // BillText — the most recent version; never null
$bill->text()->toHTML(); // link to the HTML rendering (throws if unavailable)
$bill->text()->toPDF(); // link to the PDF rendering (throws if unavailable)
$bill->text()->toString(); // the literal text (throws unless content was fetched)
$this->app->resolving('lobbyist', function ($manager) {
$manager->extend('pa', fn () => new PaDriver(/* ... */));
});