定制 adrianmejias/laravel-states 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adrianmejias/laravel-states

最新稳定版本:v1.2.5

Composer 安装命令:

composer require adrianmejias/laravel-states

包简介

Laravel States is a bundle for Laravel, providing abbreviation, name and country code for US states.

README 文档

README

Laravel States is a bundle for Laravel, providing abbreviation, name and country code for US states.

Currently, I only have US states but additional states from other countries could be added using the country code column.

Please not that this is for Laravel 5 only.

Installation

Add adrianmejias/laravel-states to composer.json.

"adrianmejias/laravel-states": "~1.0"

Run composer update to pull down the latest version of Country List.

Edit app/config/app.php and add the provider and filter

'providers' => [
    AdrianMejias\States\StatesServiceProvider::class,
]

Now add the alias.

'aliases' => [
    'States' => AdrianMejias\States\StatesFacade::class,
]

Model

You can start by publishing the configuration. This is an optional step, it contains the table name and does not need to be altered. If the default name states suits you, leave it. Otherwise run the following command

$ php artisan vendor:publish

Next generate the migration file:

$ php artisan states:migration
$ composer dump-autoload

It will generate the <timestamp>_setup_states_table.php migration and the StatesSeeder.php seeder. To make sure the data is seeded insert the following code in the database/seeds/DatabaseSeeder.php

$this->call(StatesSeeder::class);

You may now run it with the artisan migrate command:

$ php artisan migrate --seed

After running this command the filled states table will be available.

Example

Example blade formatting:

@foreach(States::whereCountryCode('US')->get() as $state)
    {{ $state->name }} {{ $state->country_code }}<br>
@endforeach

Should result in:

Alabama US<br>
Arkansas US<br>
Arizona US<br>
...

统计信息

  • 总下载量: 293.19k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固