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)
$legiscan = Lobbyist::state('CA');
$bill = $legiscan->bill(1132030);
$bill->votes(); // VoteCollection — every roll call taken on this bill
$bill->sponsors(); // LegislatorCollection — who introduced/co-sponsored it, primary sponsor(s) first
$bill->changeHash; // string|null — opaque hash that changes whenever the bill does
$bill->memo; // string|null — subject line of the sponsor's cosponsorship memo
$bill->memoUrl; // string|null — where that memo is published
$pa = Lobbyist::state('PA');
$pa->committeeAssignments(); // CommitteeAssignmentCollection — one entry per seat
$pa->committeeMeetings(); // CommitteeMeetingCollection — when committees next meet
$pa->chamberSessionDays(); // ChamberSessionDayCollection — when each chamber convenes
$legiscan->datasets(); // DatasetCollection — available archives, with a revision hash each
$legiscan->datasets()->changedSince($storedHashesBySessionId); // only the ones that changed
$archive = $legiscan->dataset($session); // DatasetArchive, downloaded and opened
$archive->bills(); // LazyCollection<Bill>
$archive->votes(); // LazyCollection<Vote> — each carrying its per-member positions
$archive->people(); // LazyCollection<Legislator>
$archive->counts(); // ['bills' => ..., 'votes' => ..., 'people' => ...]
$archive->delete(); // discard the local copy once you're done
use WiserWebSolutions\Lobbyist\Ai\Facades\LobbyistAi;
$bill = Lobbyist::state('CA')->bill('AB1');
LobbyistAi::summarizeBill($bill); // structured headline / summary / key_points, cached
LobbyistAi::classifyBill($bill); // controlled subjects + tags + impact
LobbyistAi::ask('What education bills are moving in PA this session?', 'PA'); // tool-using Q&A agent
LobbyistAi::search('cursive handwriting in schools', 'PA'); // semantic search, after indexing:
// php artisan lobbyist-ai:index PA
$this->app->resolving('lobbyist', function ($manager) {
$manager->extend('pa', fn () => new PaDriver(/* ... */));
});