承接 binarycabin/options 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

binarycabin/options

最新稳定版本:1.0.0

Composer 安装命令:

composer require binarycabin/options

包简介

Class-based select options for Laravel

README 文档

README

Build Status StyleCI Latest Stable Version Total Downloads

Class-based select options for Laravel.

This package makes it easy to store a static list of array items. This is useful in form select-list building.

Installation

composer require binarycabin/options

Usage

Generate Permissions

php artisan make:option CLASSNAME

ie:

php artisan make:option County

This will create a new file located at: /app/Options/Country.php

Edit your array

In your generated option file, edit the array in the getArray method to include the available option items:

public function getArray(){
  return [
    'US' => 'United States of America',
    'CA' => 'Canada',
  ];
}

Display the option

foreach(\App\Options\County::get('---') as $optionKey => $optionValue)
{
  echo '<option value="{{ $optionKey }}">{{ $optionValue }}</option>'
}

or using something like anahkiasen/former:

{!! Former::select()->options(\App\Options\County::get('---')) !!}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

统计信息

  • 总下载量: 245
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-05