PHPackages                             danharrin/squire - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. danharrin/squire

Abandoned → [https://github.com/squirephp/squire#upgrading-from-1x](/?search=https%3A%2F%2Fgithub.com%2Fsquirephp%2Fsquire%23upgrading-from-1x)Library[Database &amp; ORM](/categories/database)

danharrin/squire
================

A library of static Eloquent models for common fixture data.

v1.3.0(5y ago)01.1kMITPHPPHP ^7.2|^8.0

Since Jan 11Pushed 5y ago1 watchersCompare

[ Source](https://github.com/squirephp/legacy)[ Packagist](https://packagist.org/packages/danharrin/squire)[ Docs](https://github.com/squirephp/squire)[ GitHub Sponsors](https://github.com/danharrin)[ RSS](/packages/danharrin-squire/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Laravel Squire v1.x 📜
=====================

[](#laravel-squire-v1x-)

NOTICE: This v1.x package has been deprecated in favour of [v2.x](https://github.com/squirephp/squire) and is no longer maintained. [Learn more.](https://github.com/squirephp/squire#upgrading-from-1x)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#notice-this-v1x-package-has-been-deprecated-in-favour-of-v2x-and-is-no-longer-maintained-learn-more)

[![CI status](https://github.com/squirephp/legacy/workflows/run-tests/badge.svg)](https://github.com/squirephp/legacy/actions)

Squire is a library of static Eloquent models for fixture data that is commonly needed in web applications, such as countries, currencies and airports. It's built on top of [Caleb Porzio's Sushi package](https://github.com/calebporzio/sushi).

Common use cases for Squire include:

- Populating dropdown options, such as a country selector on an address form.
- Attaching extra data to other models in your app, such as airport information to a `Flight` model. See the section on [model relationships](#model-relationships).

Contents
--------

[](#contents)

- [Installing Squire](#installing-squire)
- [Using a model](#using-a-model)
- [Available models](#available-models)
    - [`Squire\Models\Airline`](#squiremodelsairline)
    - [`Squire\Models\Airport`](#squiremodelsairport)
    - [`Squire\Models\Continent`](#squiremodelscontinent)
    - [`Squire\Models\Counties\GbCounty`](#squiremodelscountiesgbcounty)
    - [`Squire\Models\Country`](#squiremodelscountry)
    - [`Squire\Models\Currency`](#squiremodelscurrency)
    - [`Squire\Models\Region`](#squiremodelsregion)
- [Model relationships](#model-relationships)
- [Column customisation](#column-customisation)
- [Contributing](#contributing)

Installing Squire
-----------------

[](#installing-squire)

You can use Composer to install Squire into your application.

```
composer require danharrin/squire

```

No additional setup is required.

Using a model
-------------

[](#using-a-model)

You can interact with a Squire model just like you would any other Eloquent model, except that it only handles read-only operations.

```
use Squire\Models\Country;

Country::all(); // Get information about all countries.

Country::find('us'); // Get information about the United States.

Country::where('name', 'like', 'a%')->get(); // Get information about all countries beginning with the letter "a".
```

Available models
----------------

[](#available-models)

### `Squire\Models\Airline`

[](#squiremodelsairline)

Column NameDescriptionExample`alias`Alternative name of the airline.`EasyJet Airline``call_sign`Call sign of the airline.`EASY``code_iata`[IATA code](https://en.wikipedia.org/wiki/List_of_airline_codes) of the airline.`u2``code_icao`[ICAO code](https://en.wikipedia.org/wiki/List_of_airline_codes) of the airline.`ezy``country_id`[ISO 3166-1 alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the airline.`gb``name`Name of the airline.`easyJet`Relationship nameModel`country`[`Squire\Models\Country`](#squiremodelscountry)`continent`[`Squire\Models\Continent`](#squiremodelscontinent)### `Squire\Models\Airport`

[](#squiremodelsairport)

Column NameDescriptionExample`code_gps`GPS code of the airport.`ayse``code_iata`[IATA code](https://en.wikipedia.org/wiki/IATA_airport_code) of the airport.`nis``code_icao`Local code of the airport.`sbi``municipality`Municipality of the airport.`Simberi Island``name`Name of the airport.`Simberi Airport``region_id`[ISO 3166-2 region code](https://en.wikipedia.org/wiki/ISO_3166-2) of the airport.`pg-nik``type`Type of airport.`small_airport`Relationship nameModel`country`[`Squire\Models\Country`](#squiremodelscountry)`region`[`Squire\Models\Region`](#squiremodelsregion)### `Squire\Models\Continent`

[](#squiremodelscontinent)

Column NameDescriptionExample`code`Two letter continent code.`na``name`Continent name.`North America`Relationship nameModel`countries`[`Squire\Models\Country`](#squiremodelscountry)`regions`[`Squire\Models\Region`](#squiremodelsregion)### `Squire\Models\Counties\GbCounty`

[](#squiremodelscountiesgbcounty)

Column NameDescriptionExample`code`[ISO 3166-2 county code](https://en.wikipedia.org/wiki/ISO_3166-2).`gb-ess``name`County name.`Essex``region_id`[ISO 3166-2 region code](https://en.wikipedia.org/wiki/ISO_3166-2) of the county.`gb-eng`Relationship nameModel`region`[`Squire\Models\Region`](#squiremodelsregion)### `Squire\Models\Country`

[](#squiremodelscountry)

Column NameDescriptionExample`calling_code`[E.164](https://en.wikipedia.org/wiki/E.164) country calling code.`1``capital_city`Capital city of the country.`Washington``code_2`[ISO 3166-1 alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).`us``code_3`[ISO 3166-1 alpha-3 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3).`usa``continent_id`Two letter continent code of the country.`na``currency_id`[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) alphabetic currency code of the country.`usd``flag`Unicode flag of the country.`🇺🇸``name`Country name.`United States`Relationship nameModel`airlines`[`Squire\Models\Airline`](#squiremodelsairline)`airports`[`Squire\Models\Airport`](#squiremodelsairport)`continent`[`Squire\Models\Continent`](#squiremodelscontinent)`currency`[`Squire\Models\Currency`](#squiremodelscurrency)`regions`[`Squire\Models\Region`](#squiremodelsregion)### `Squire\Models\Currency`

[](#squiremodelscurrency)

Column NameDescriptionExample`code_alphabetic`[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) alphabetic currency code.`usd``code_numeric`[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) numeric currency code.`840``decimal_digits`Number of decimal digits to use when formatting this currency.`2``name`Currency name.`US Dollar``name_plural`Plural currency name.`US Dollars``rounding`The formatting precison of this currency.`0``symbol`International currency symbol.`$``symbol_native`Native currency symbol.`$`Relationship nameModel`countries`[`Squire\Models\Country`](#squiremodelscountry)### `Squire\Models\Region`

[](#squiremodelsregion)

Column NameDescriptionExample`code`[ISO 3166-2 region code](https://en.wikipedia.org/wiki/ISO_3166-2).`us-ny``country_id`[ISO 3166-1 alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).`us``name`Region name.`New York`Relationship nameModel`airports`[`Squire\Models\Airport`](#squiremodelsairport)`continent`[`Squire\Models\Continent`](#squiremodelscontinent)`country`[`Squire\Models\Country`](#squiremodelscountry)`gbCounties`[`Squire\Models\County\GbCounty`](#squiremodelscountiesgbcounty)Model relationships
-------------------

[](#model-relationships)

Implementing an Eloquent relationship between a model in your app and a Squire model is very simple. There are a couple of approaches you could take.

### Using inheritance

[](#using-inheritance)

The simplest option is to create a new model in your app, and let it extend the Squire model. Your new app model will now behave like the original Squire model, except you can register new methods and customise it to your liking:

```
