Some Static Data
If you use the Moox application, install the package and run the unified Moox installer:
composer require moox/dataBefore importing static country data, add a REST Countries API key to your .env (see REST Countries API key below).
php artisan moox:installmoox:install publishes configs, runs migrations, and registers Filament plugins for Moox packages. For this package it can also run the Static Data custom installer (countries, languages, timezones, currencies from REST Countries) when that step is included in the install flow.
You do not need a separate package-specific install command when using moox:install. If static data is not imported during install, configure your API key and run the import command in REST Countries API key below.
Curious what the installer does? See the Moox installer docs or manual installation below.
Country, currency, language, and timezone data is imported from the REST Countries API. The API requires an authenticated API key.
- Sign up for a free API key at restcountries.com/sign-up.
- Add the key to your
.envfile:
REST_COUNTRIES_API_KEY=your_api_key_here- Optionally publish the package configuration:
php artisan vendor:publish --tag="data-config"The published config/rest-countries.php file also supports:
return [
'api_key' => env('REST_COUNTRIES_API_KEY'),
'base_url' => env('REST_COUNTRIES_BASE_URL', 'https://api.restcountries.com/countries/v5'),
'timeout' => (int) env('REST_COUNTRIES_TIMEOUT', 60),
'page_limit' => (int) env('REST_COUNTRIES_PAGE_LIMIT', 100),
];REST Countries offers a free plan with 500 API requests per month (quota resets on your billing anniversary). On the free plan, each list request can return at most 100 countries per page (page_limit defaults to 100).
A single moox:data:import-static run uses 3 REST Countries requests with the default settings: the API returns about 250 countries, paginated at 100 per request (offset 0, 100, 200). The import also makes one additional HTTP request to ApiCountries for language native names; that call is separate and does not count against your REST Countries quota.
At 3 requests per import, the free tier allows roughly 160 full imports per month if REST Countries is the only consumer of your quota.
After configuring your key, import static data (if not already done via moox:install) or refresh it later:
php artisan moox:data:import-static --syncCommitted JSON under database/data/codelists/ is loaded into static_* tables by:
php artisan moox:data:import-codelistsPass a scheme key to import one list (for example en10204, uncl7161, untdid1001).
Certificate kinds (EN 10204 inspection document types) are scheme en10204, JSON file database/data/codelists/certificate-kinds.json, model StaticCertificateKind. Codes are hyphenated (2-1, 2-2, 3-1, 3-2) because Laravel lang keys cannot contain dots; they correspond to EN 10204 types 2.1, 2.2, 3.1, and 3.2. A fifth code, undetermined, is for an inspection document whose kind could not be determined; it is not an EN 10204 type and is marked non-normative (is_normative is false in JSON and in the database) so evaluation can tell it apart from the four standard kinds. Labels ship in resources/lang/{en,de,cs}/enums/certificate-kinds.php. This package ships kinds only; resolving printed wording on an invoice to a kind is the consumer's concern. The Filament resource is registered with StaticCertificateKindPlugin. Hosts may attach extra Filament relation managers via config('static-certificate-kind.relation_managers') without adding printed spellings to this package. Further kinds are additional JSON rows plus matching lang keys.
Static Data for country, language, Timzones, and Currencies.
also see ==> https://filamentphp.com/docs/3.x/support/render-hooks
To include it in your frontend jsut use the livewire notation
<livewire:language-switch />
On default the component will assume the context is frontend. If thats not the chase provide the context withing the componenten.
After that the Resource is highly configurable.
To use the DataPanelProvider, you need to enable it in the config file:
'enable-panel' => true,now the panel will be available at /data
Moox Core features like Dynamic Tabs and Translatable Config. See the config file for more details, but as a quick example:
/*
|--------------------------------------------------------------------------
| Tabs
|--------------------------------------------------------------------------
|
| Define the tabs for the Resource table. They are optional, but
| pretty awesome to filter the table by certain values.
| You may simply do a 'tabs' => [], to disable them.
|
*/
'tabs' => [
'all' => [
'label' => 'trans//core::core.all',
'icon' => 'gmdi-filter-list',
'query' => [
[
'field' => 'deleted_at',
'operator' => '=',
'value' => null,
],
],
],
'published' => [
'label' => 'trans//core::core.published',
'icon' => 'gmdi-check-circle',
'query' => [
[
'field' => 'publish_at',
'operator' => '<=',
'value' => function () {
return now();
},
],
[
'field' => 'deleted_at',
'operator' => '=',
'value' => null,
],
],
],
'scheduled' => [
'label' => 'trans//core::core.scheduled',
'icon' => 'gmdi-schedule',
'query' => [
[
'field' => 'publish_at',
'operator' => '>',
'value' => function () {
return now();
},
],
[
'field' => 'deleted_at',
'operator' => '=',
'value' => null,
],
],
],
'draft' => [
'label' => 'trans//core::core.draft',
'icon' => 'gmdi-text-snippet',
'query' => [
[
'field' => 'publish_at',
'operator' => '=',
'value' => null,
],
[
'field' => 'deleted_at',
'operator' => '=',
'value' => null,
],
],
],
'deleted' => [
'label' => 'trans//core::core.deleted',
'icon' => 'gmdi-delete',
'query' => [
[
'field' => 'deleted_at',
'operator' => '!=',
'value' => null,
],
],
],
],
],All options for Tabs are explained in Moox Core docs.
The item also support 'item' types, means you are able to configure selectable types for your Entity. By default, we provide "Post" and "Page" as example. If you don't want to use types, just empty the array and the field and column become invisible.
/*
|--------------------------------------------------------------------------
| Item Types
|--------------------------------------------------------------------------
|
| This array contains the types of items entities. You can delete
| the types you don't need and add new ones. If you don't need
| types, you can empty this array like this: 'types' => [],
|
*/
'types' => [
'post' => 'Post',
'page' => 'Page',
],You can configure the user model used for displaying Authors. By default it is tied to App User:
/*
|--------------------------------------------------------------------------
| Author Model
|--------------------------------------------------------------------------
|
| This sets the user model that can be used as author. It should be an
| authenticatable model and support the morph relationship.
| It should have fields similar to Moox User or WpUser.
|
*/
'author_model' => \App\Models\User::class,You may probably use Moox User
'author_model' => \Moox\User\Models\User::class,or Moox Press User instead:
'author_model' => \Moox\Press\Models\WpUser::class,Note: If you use the Moox app, run php artisan moox:install instead—it installs all packages and runs their migrations in one go. The steps below are only for installing this package without the unified installer.
Instead of using moox:install, you can install this package manually step by step:
// Publish and run the migrations:
php artisan vendor:publish --tag="data-migrations"
php artisan migrate
// Publish the config file with:
php artisan vendor:publish --tag="data-config"Then configure your REST Countries API key and import static data as described in REST Countries API key.
Please see CHANGELOG for more information on what has changed recently.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.
