Skip to content

Commit e6683f0

Browse files
committed
Initial Commit
0 parents  commit e6683f0

File tree

11 files changed

+333
-0
lines changed

11 files changed

+333
-0
lines changed

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/json-field-for-backpack.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
All notable changes to the package will be documented in this file.
4+
5+
## 0.1.0 - 2020-10-29
6+
7+
### Added
8+
- Initial Commit

composer.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "ziming/json-field-for-backpack",
3+
"description": "A Json Editor Field for Backpack",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "ziming",
8+
"email": "[email protected]"
9+
},
10+
{
11+
"name": "vesper8"
12+
},
13+
{
14+
"name": "stephanus-stuff"
15+
}
16+
],
17+
"homepage": "https://github.com/ziming/json-field-for-backpack",
18+
"keywords": ["Laravel", "Backpack", "Backpack for Laravel", "Addon", "Admin Panel", "Json", "Field"],
19+
"require": {
20+
"backpack/crud": "^4.1.0"
21+
},
22+
"autoload": {
23+
"psr-4": {
24+
"Ziming\\JsonFieldForBackpack\\": "src/"
25+
}
26+
},
27+
"extra": {
28+
"laravel": {
29+
"providers": [
30+
"Ziming\\JsonFieldForBackpack\\AddonServiceProvider"
31+
]
32+
}
33+
}
34+
}

license.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License (MIT)
2+
3+
Copyright (c)
4+
5+
> Permission is hereby granted, free of charge, to any person obtaining a copy
6+
> of this software and associated documentation files (the "Software"), to deal
7+
> in the Software without restriction, including without limitation the rights
8+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
> copies of the Software, and to permit persons to whom the Software is
10+
> furnished to do so, subject to the following conditions:
11+
>
12+
> The above copyright notice and this permission notice shall be included in
13+
> all 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,
17+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
> THE SOFTWARE.

readme.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Json Field for Backpack 4
2+
3+
[![Latest Version on Packagist][ico-version]][link-packagist]
4+
[![Total Downloads][ico-downloads]][link-downloads]
5+
6+
This package provides a ```json``` field type for the [Backpack for Laravel](https://backpackforlaravel.com/) administration panel.
7+
8+
## Screenshots
9+
10+
## Installation
11+
12+
Via Composer
13+
14+
``` bash
15+
composer require ziming/json-field-for-backpack
16+
```
17+
18+
## Usage
19+
20+
Inside your custom CrudController:
21+
22+
```php
23+
$this->crud->addField([
24+
'name' => 'column_name',
25+
'type' => 'json_editor',
26+
'modes' => ['form', 'tree', 'code'], // Optional. 1st item will be the default mode
27+
28+
// Optional. default json value in php array style.
29+
30+
// If there is an actual value in the json column, it will do an
31+
// array_merge_recursive. With the json column values replacing the
32+
// ones with the same keys
33+
'default' => [], // Optional. default json value in php array style.
34+
'view_namespace' => 'json-field-for-backpack::fields',
35+
]);
36+
```
37+
38+
Notice the ```view_namespace``` attribute - make sure that is exactly as above, to tell Backpack to load the field from this _addon package_, instead of assuming it's inside the _Backpack\CRUD package_.
39+
40+
41+
## Overwriting
42+
43+
If you need to change the field in any way, you can easily publish the file to your app, and modify that file any way you want. But please keep in mind that you will not be getting any updates.
44+
45+
**Step 1.** Copy-paste the blade file to your directory:
46+
```bash
47+
# create the fields directory if it's not already there
48+
mkdir -p resources/views/vendor/backpack/crud/fields
49+
50+
# copy the blade file inside the folder we created above
51+
cp -i vendor/ziming/addon/src/resources/views/fields/json.blade.php resources/views/vendor/backpack/crud/fields/json.blade.php
52+
```
53+
54+
**Step 2.** Remove the vendor namespace wherever you've used the field:
55+
```diff
56+
$this->crud->addField([
57+
- 'view_namespace' => 'json-field-for-backpack::fields'
58+
]);
59+
```
60+
61+
**Step 3.** Uninstall this package. Since it only provides one file - ```json.blade.php```, and you're no longer using that file, it makes no sense to have the package installed:
62+
63+
```bash
64+
composer remove ziming/json-field-for-backpack
65+
```
66+
67+
## Change log
68+
69+
Please see the [changelog](changelog.md) for more information on what has changed recently.
70+
71+
72+
## Security
73+
74+
If you discover any security related issues, please email [the author](composer.json) instead of using the issue tracker.
75+
76+
## Credits
77+
78+
- [ziming](https://github.com/adoptavia) - Created the initial field type
79+
- [vesper8](https://github.com/vesper8) - Polished & fixed bugs in the field type to allow multiple instances of the field
80+
- [stephanus-stuff](https://github.com/stephanus-stuff) - For updating the field type to be compatible with Backpack 4.0 and 4.1
81+
- [Cristian Tabacitu](https://github.com/tabacitu) - For being the creator of Backpack.
82+
- [josdejong](https://github.com/josdejong) - For creating [jsoneditor](https://github.com/josdejong/jsoneditor)
83+
84+
- [All Contributors][link-contributors]
85+
86+
## License
87+
88+
MIT. Please see the [license file](license.md) for more information.
89+
90+
[ico-version]: https://img.shields.io/packagist/v/ziming/json-field-for-backpack.svg?style=flat-square
91+
[ico-downloads]: https://img.shields.io/packagist/dt/ziming/json-field-for-backpack.svg?style=flat-square
92+
93+
[link-packagist]: https://packagist.org/packages/ziming/json-field-for-backpack
94+
[link-downloads]: https://packagist.org/packages/ziming/json-field-for-backpack
95+
[link-author]: https://github.com/ziming
96+
[link-contributors]: ../../contributors

src/AddonServiceProvider.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Ziming\JsonFieldForBackpack;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class AddonServiceProvider extends ServiceProvider
8+
{
9+
/**
10+
* Perform post-registration booting of services.
11+
*
12+
* @return void
13+
*/
14+
public function boot()
15+
{
16+
$this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'json-field-for-backpack');
17+
}
18+
}

0 commit comments

Comments
 (0)