├── .gitignore
├── src
├── TagsinputExtension.php
├── TagsinputServiceProvider.php
└── Tagsinput.php
├── .editorconfig
├── README.md
├── composer.json
├── resources
└── assets
│ ├── tagsinput.min.css
│ └── tagsinput.min.js
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | phpunit.phar
3 | /vendor
4 | composer.phar
5 | composer.lock
6 | *.project
7 | .idea/
--------------------------------------------------------------------------------
/src/TagsinputExtension.php:
--------------------------------------------------------------------------------
1 | = 7`
12 | * laravel-admin `~1.6`
13 |
14 | 安装方式
15 | -
16 | 1.使用composer安装扩展包
17 | ```shell
18 | composer require namet/laravel-admin-tagsinput -vvv
19 | ```
20 | 2.发布静态资源
21 | ```shell
22 | php artisan vendor:publish --tag=laravel-admin-tagsinput
23 | ```
24 |
25 | 3.在控制器中使用`tagsinput`方法
26 | ```php
27 | // app/Admin/Controllers/GoodsController
28 |
29 | protected function form()
30 | {
31 | $form = new Form(new GoodsCate);
32 |
33 | $form->text('name', '属性名');
34 | $form->switch('nullable', '可空')->default(1);
35 | $form->tagsinput('values', '可选值');
36 | return $form;
37 | }
38 | ```
39 |
40 | LICENSE
41 | -
42 | MIT
43 |
44 |
45 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "namet/laravel-admin-tagsinput",
3 | "description": "tagsinput for laravel-admin Form",
4 | "type": "library",
5 | "keywords": ["laravel-admin", "extension", "jquery", "bootstrap", "tagsinput"],
6 | "homepage": "https://github.com/namet117/laravel-admin-tagsinput",
7 | "license": "MIT",
8 | "authors": [
9 | {
10 | "name": "namet",
11 | "email": "namet117@163.com"
12 | }
13 | ],
14 | "require": {
15 | "php": ">=7.0.0",
16 | "encore/laravel-admin": "~1.6"
17 | },
18 | "require-dev": {
19 | "phpunit/phpunit": "~6.0"
20 | },
21 | "autoload": {
22 | "psr-4": {
23 | "Namet\\Tagsinput\\": "src/"
24 | }
25 | },
26 | "extra": {
27 | "laravel": {
28 | "providers": [
29 | "Namet\\Tagsinput\\TagsinputServiceProvider"
30 | ]
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/TagsinputServiceProvider.php:
--------------------------------------------------------------------------------
1 | views()) {
21 | $this->loadViewsFrom($views, 'laravel-admin-tagsinput');
22 | }
23 |
24 | if ($this->app->runningInConsole() && $assets = $extension->assets()) {
25 | $this->publishes(
26 | [$assets => public_path('vendor/namet/laravel-admin-tagsinput')],
27 | 'laravel-admin-tagsinput'
28 | );
29 | }
30 |
31 | Admin::booting(function () {
32 | Form::extend('tagsinput', Tagsinput::class);
33 | });
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/resources/assets/tagsinput.min.css:
--------------------------------------------------------------------------------
1 | .bootstrap-tagsinput{background-color:#fff;border:1px solid #ccc;display:inline-block;padding:4px 6px;color:#555;vertical-align:middle;max-width:100%;line-height:22px;cursor:text;width:100%}.bootstrap-tagsinput input{border:none;box-shadow:none;outline:none;background-color:transparent;padding:0 6px;margin:0;width:auto;max-width:inherit}.bootstrap-tagsinput.form-control input::-moz-placeholder{color:#777;opacity:1}.bootstrap-tagsinput.form-control input:-ms-input-placeholder{color:#777}.bootstrap-tagsinput.form-control input::-webkit-input-placeholder{color:#777}.bootstrap-tagsinput input:focus{border:none;box-shadow:none}.bootstrap-tagsinput .tag{margin-right:2px;color:white}.bootstrap-tagsinput .tag [data-role="remove"]{margin-left:8px;cursor:pointer}.bootstrap-tagsinput .tag [data-role="remove"]:after{content:"x";padding:0 2px}.bootstrap-tagsinput .tag [data-role="remove"]:hover{box-shadow:inset 0 1px 0 rgba(255, 255, 255, .2), 0 1px 2px rgba(0, 0, 0, .05)}.bootstrap-tagsinput .tag [data-role="remove"]:hover:active{box-shadow:inset 0 3px 5px rgba(0, 0, 0, .125)}
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Jens Segers
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/src/Tagsinput.php:
--------------------------------------------------------------------------------
1 | initPlainInput();
23 |
24 | $this->prepend('')
25 | ->defaultAttribute('type', 'text')
26 | ->defaultAttribute('data-role', 'tagsinput')
27 | ->defaultAttribute('id', $this->id)
28 | ->defaultAttribute('name', $this->elementName ?: $this->formatName($this->column))
29 | ->defaultAttribute('value', old($this->column, $this->value()))
30 | ->defaultAttribute('class', 'form-control '.$this->getElementClassString())
31 | ->defaultAttribute('placeholder', $this->getPlaceholder());
32 |
33 | $this->addVariables([
34 | 'prepend' => $this->prepend,
35 | 'append' => $this->append,
36 | ]);
37 |
38 | $this->script = <<