mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge branch 'develop'
This commit is contained in:
commit
09eff88679
|
@ -838,6 +838,15 @@
|
||||||
"contributions": [
|
"contributions": [
|
||||||
"doc"
|
"doc"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "vcordes79",
|
||||||
|
"name": "vcordes79",
|
||||||
|
"avatar_url": "https://avatars1.githubusercontent.com/u/10672546?v=4",
|
||||||
|
"profile": "https://github.com/vcordes79",
|
||||||
|
"contributions": [
|
||||||
|
"code"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[](https://travis-ci.org/snipe/snipe-it) [](http://waffle.io/snipe/snipe-it) []() [](https://crowdin.com/project/snipe-it) [](https://gitter.im/snipe/snipe-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://hub.docker.com/r/snipe/snipe-it/) [](https://twitter.com/snipeyhead) [](https://zenhub.io) [](https://www.codacy.com/app/snipe/snipe-it?utm_source=github.com&utm_medium=referral&utm_content=snipe/snipe-it&utm_campaign=Badge_Grade)
|
[](https://travis-ci.org/snipe/snipe-it) [](http://waffle.io/snipe/snipe-it) []() [](https://crowdin.com/project/snipe-it) [](https://gitter.im/snipe/snipe-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://hub.docker.com/r/snipe/snipe-it/) [](https://twitter.com/snipeyhead) [](https://zenhub.io) [](https://www.codacy.com/app/snipe/snipe-it?utm_source=github.com&utm_medium=referral&utm_content=snipe/snipe-it&utm_campaign=Badge_Grade)
|
||||||
[](#contributors)
|
[](#contributors)
|
||||||
|
|
||||||
|
|
||||||
## Snipe-IT - Open Source Asset Management System
|
## Snipe-IT - Open Source Asset Management System
|
||||||
|
@ -68,7 +68,7 @@ Thanks goes to all of these wonderful people ([emoji key](https://github.com/ken
|
||||||
| [<img src="https://avatars2.githubusercontent.com/u/857740?v=3" width="110px;"/><br /><sub>Gil Rutkowski</sub>](http://FlashingCursor.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=flashingcursor "Code") | [<img src="https://avatars3.githubusercontent.com/u/129360?v=3" width="110px;"/><br /><sub>Desmond Morris</sub>](http://www.desmondmorris.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=desmondmorris "Code") | [<img src="https://avatars2.githubusercontent.com/u/52936?v=3" width="110px;"/><br /><sub>Nick Peelman</sub>](http://peelman.us)<br />[💻](https://github.com/snipe/snipe-it/commits?author=peelman "Code") | [<img src="https://avatars0.githubusercontent.com/u/53161?v=3" width="110px;"/><br /><sub>Abraham Vegh</sub>](https://abrahamvegh.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=abrahamvegh "Code") | [<img src="https://avatars0.githubusercontent.com/u/2818680?v=3" width="110px;"/><br /><sub>Mohamed Rashid</sub>](https://github.com/rashivkp)<br />[📖](https://github.com/snipe/snipe-it/commits?author=rashivkp "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/1509456?v=3" width="110px;"/><br /><sub>Kasey</sub>](http://hinchk.github.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=HinchK "Code") | [<img src="https://avatars2.githubusercontent.com/u/10522541?v=3" width="110px;"/><br /><sub>Brett</sub>](https://github.com/BrettFagerlund)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=BrettFagerlund "Tests") |
|
| [<img src="https://avatars2.githubusercontent.com/u/857740?v=3" width="110px;"/><br /><sub>Gil Rutkowski</sub>](http://FlashingCursor.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=flashingcursor "Code") | [<img src="https://avatars3.githubusercontent.com/u/129360?v=3" width="110px;"/><br /><sub>Desmond Morris</sub>](http://www.desmondmorris.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=desmondmorris "Code") | [<img src="https://avatars2.githubusercontent.com/u/52936?v=3" width="110px;"/><br /><sub>Nick Peelman</sub>](http://peelman.us)<br />[💻](https://github.com/snipe/snipe-it/commits?author=peelman "Code") | [<img src="https://avatars0.githubusercontent.com/u/53161?v=3" width="110px;"/><br /><sub>Abraham Vegh</sub>](https://abrahamvegh.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=abrahamvegh "Code") | [<img src="https://avatars0.githubusercontent.com/u/2818680?v=3" width="110px;"/><br /><sub>Mohamed Rashid</sub>](https://github.com/rashivkp)<br />[📖](https://github.com/snipe/snipe-it/commits?author=rashivkp "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/1509456?v=3" width="110px;"/><br /><sub>Kasey</sub>](http://hinchk.github.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=HinchK "Code") | [<img src="https://avatars2.githubusercontent.com/u/10522541?v=3" width="110px;"/><br /><sub>Brett</sub>](https://github.com/BrettFagerlund)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=BrettFagerlund "Tests") |
|
||||||
| [<img src="https://avatars2.githubusercontent.com/u/16108587?v=3" width="110px;"/><br /><sub>Jason Spriggs</sub>](http://jasonspriggs.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jasonspriggs "Code") | [<img src="https://avatars2.githubusercontent.com/u/1134568?v=3" width="110px;"/><br /><sub>Nate Felton</sub>](http://n8felton.wordpress.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=n8felton "Code") | [<img src="https://avatars2.githubusercontent.com/u/14036694?v=3" width="110px;"/><br /><sub>Manasses Ferreira</sub>](http://homepages.dcc.ufmg.br/~manassesferreira)<br />[💻](https://github.com/snipe/snipe-it/commits?author=manassesferreira "Code") | [<img src="https://avatars0.githubusercontent.com/u/15913949?v=3" width="110px;"/><br /><sub>Steve</sub>](https://github.com/steveelwood)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=steveelwood "Tests") | [<img src="https://avatars1.githubusercontent.com/u/3361683?v=3" width="110px;"/><br /><sub>matc</sub>](http://twitter.com/matc)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=matc "Tests") | [<img src="https://avatars3.githubusercontent.com/u/7405702?v=3" width="110px;"/><br /><sub>Cole R. Davis</sub>](http://www.davisracingteam.com)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=VanillaNinjaD "Tests") | [<img src="https://avatars2.githubusercontent.com/u/10167681?v=3" width="110px;"/><br /><sub>gibsonjoshua55</sub>](https://github.com/gibsonjoshua55)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gibsonjoshua55 "Code") |
|
| [<img src="https://avatars2.githubusercontent.com/u/16108587?v=3" width="110px;"/><br /><sub>Jason Spriggs</sub>](http://jasonspriggs.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jasonspriggs "Code") | [<img src="https://avatars2.githubusercontent.com/u/1134568?v=3" width="110px;"/><br /><sub>Nate Felton</sub>](http://n8felton.wordpress.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=n8felton "Code") | [<img src="https://avatars2.githubusercontent.com/u/14036694?v=3" width="110px;"/><br /><sub>Manasses Ferreira</sub>](http://homepages.dcc.ufmg.br/~manassesferreira)<br />[💻](https://github.com/snipe/snipe-it/commits?author=manassesferreira "Code") | [<img src="https://avatars0.githubusercontent.com/u/15913949?v=3" width="110px;"/><br /><sub>Steve</sub>](https://github.com/steveelwood)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=steveelwood "Tests") | [<img src="https://avatars1.githubusercontent.com/u/3361683?v=3" width="110px;"/><br /><sub>matc</sub>](http://twitter.com/matc)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=matc "Tests") | [<img src="https://avatars3.githubusercontent.com/u/7405702?v=3" width="110px;"/><br /><sub>Cole R. Davis</sub>](http://www.davisracingteam.com)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=VanillaNinjaD "Tests") | [<img src="https://avatars2.githubusercontent.com/u/10167681?v=3" width="110px;"/><br /><sub>gibsonjoshua55</sub>](https://github.com/gibsonjoshua55)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gibsonjoshua55 "Code") |
|
||||||
| [<img src="https://avatars2.githubusercontent.com/u/2809241?v=4" width="110px;"/><br /><sub>Robin Temme</sub>](https://github.com/zwerch)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zwerch "Code") | [<img src="https://avatars0.githubusercontent.com/u/6961695?v=4" width="110px;"/><br /><sub>Iman</sub>](https://github.com/imanghafoori1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=imanghafoori1 "Code") | [<img src="https://avatars1.githubusercontent.com/u/6551003?v=4" width="110px;"/><br /><sub>Richard Hofman</sub>](https://github.com/richardhofman6)<br />[💻](https://github.com/snipe/snipe-it/commits?author=richardhofman6 "Code") | [<img src="https://avatars0.githubusercontent.com/u/3697569?v=4" width="110px;"/><br /><sub>gizzmojr</sub>](https://github.com/gizzmojr)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gizzmojr "Code") | [<img src="https://avatars3.githubusercontent.com/u/404729?v=4" width="110px;"/><br /><sub>Jenny Li</sub>](https://github.com/imjennyli)<br />[📖](https://github.com/snipe/snipe-it/commits?author=imjennyli "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/869227?v=4" width="110px;"/><br /><sub>Geoff Young</sub>](https://github.com/GeoffYoung)<br />[💻](https://github.com/snipe/snipe-it/commits?author=GeoffYoung "Code") | [<img src="https://avatars3.githubusercontent.com/u/1068477?v=4" width="110px;"/><br /><sub>Elliot Blackburn</sub>](http://www.elliotblackburn.com)<br />[📖](https://github.com/snipe/snipe-it/commits?author=BlueHatbRit "Documentation") |
|
| [<img src="https://avatars2.githubusercontent.com/u/2809241?v=4" width="110px;"/><br /><sub>Robin Temme</sub>](https://github.com/zwerch)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zwerch "Code") | [<img src="https://avatars0.githubusercontent.com/u/6961695?v=4" width="110px;"/><br /><sub>Iman</sub>](https://github.com/imanghafoori1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=imanghafoori1 "Code") | [<img src="https://avatars1.githubusercontent.com/u/6551003?v=4" width="110px;"/><br /><sub>Richard Hofman</sub>](https://github.com/richardhofman6)<br />[💻](https://github.com/snipe/snipe-it/commits?author=richardhofman6 "Code") | [<img src="https://avatars0.githubusercontent.com/u/3697569?v=4" width="110px;"/><br /><sub>gizzmojr</sub>](https://github.com/gizzmojr)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gizzmojr "Code") | [<img src="https://avatars3.githubusercontent.com/u/404729?v=4" width="110px;"/><br /><sub>Jenny Li</sub>](https://github.com/imjennyli)<br />[📖](https://github.com/snipe/snipe-it/commits?author=imjennyli "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/869227?v=4" width="110px;"/><br /><sub>Geoff Young</sub>](https://github.com/GeoffYoung)<br />[💻](https://github.com/snipe/snipe-it/commits?author=GeoffYoung "Code") | [<img src="https://avatars3.githubusercontent.com/u/1068477?v=4" width="110px;"/><br /><sub>Elliot Blackburn</sub>](http://www.elliotblackburn.com)<br />[📖](https://github.com/snipe/snipe-it/commits?author=BlueHatbRit "Documentation") |
|
||||||
| [<img src="https://avatars1.githubusercontent.com/u/6357451?v=4" width="110px;"/><br /><sub>Tõnis Ormisson</sub>](http://andmemasin.eu)<br />[💻](https://github.com/snipe/snipe-it/commits?author=TonisOrmisson "Code") | [<img src="https://avatars0.githubusercontent.com/u/449411?v=4" width="110px;"/><br /><sub>Nicolai Essig</sub>](http://www.nicolai-essig.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thakilla "Code") | [<img src="https://avatars1.githubusercontent.com/u/14809698?v=4" width="110px;"/><br /><sub>Danielle</sub>](https://github.com/techincolor)<br />[📖](https://github.com/snipe/snipe-it/commits?author=techincolor "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/18545156?v=4" width="110px;"/><br /><sub>Lawrence</sub>](https://github.com/TheVakman)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=TheVakman "Tests") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3ATheVakman "Bug reports") | [<img src="https://avatars1.githubusercontent.com/u/22473767?v=4" width="110px;"/><br /><sub>uknzaeinozpas</sub>](https://github.com/uknzaeinozpas)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=uknzaeinozpas "Tests") [💻](https://github.com/snipe/snipe-it/commits?author=uknzaeinozpas "Code") | [<img src="https://avatars3.githubusercontent.com/u/422752?v=4" width="110px;"/><br /><sub>Ryan</sub>](https://github.com/Gelob)<br />[📖](https://github.com/snipe/snipe-it/commits?author=Gelob "Documentation") |
|
| [<img src="https://avatars1.githubusercontent.com/u/6357451?v=4" width="110px;"/><br /><sub>Tõnis Ormisson</sub>](http://andmemasin.eu)<br />[💻](https://github.com/snipe/snipe-it/commits?author=TonisOrmisson "Code") | [<img src="https://avatars0.githubusercontent.com/u/449411?v=4" width="110px;"/><br /><sub>Nicolai Essig</sub>](http://www.nicolai-essig.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thakilla "Code") | [<img src="https://avatars1.githubusercontent.com/u/14809698?v=4" width="110px;"/><br /><sub>Danielle</sub>](https://github.com/techincolor)<br />[📖](https://github.com/snipe/snipe-it/commits?author=techincolor "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/18545156?v=4" width="110px;"/><br /><sub>Lawrence</sub>](https://github.com/TheVakman)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=TheVakman "Tests") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3ATheVakman "Bug reports") | [<img src="https://avatars1.githubusercontent.com/u/22473767?v=4" width="110px;"/><br /><sub>uknzaeinozpas</sub>](https://github.com/uknzaeinozpas)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=uknzaeinozpas "Tests") [💻](https://github.com/snipe/snipe-it/commits?author=uknzaeinozpas "Code") | [<img src="https://avatars3.githubusercontent.com/u/422752?v=4" width="110px;"/><br /><sub>Ryan</sub>](https://github.com/Gelob)<br />[📖](https://github.com/snipe/snipe-it/commits?author=Gelob "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/10672546?v=4" width="110px;"/><br /><sub>vcordes79</sub>](https://github.com/vcordes79)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vcordes79 "Code") |
|
||||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||||
|
|
||||||
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
|
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Transformers\CustomFieldsTransformer;
|
use App\Http\Transformers\CustomFieldsTransformer;
|
||||||
use App\Models\CustomField;
|
use App\Models\CustomField;
|
||||||
use App\Models\CustomFieldset;
|
use App\Models\CustomFieldset;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Validator;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class CustomFieldsController extends Controller
|
class CustomFieldsController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -27,6 +30,81 @@ class CustomFieldsController extends Controller
|
||||||
$total = count($fields);
|
$total = count($fields);
|
||||||
return (new CustomFieldsTransformer)->transformCustomFields($fields, $total);
|
return (new CustomFieldsTransformer)->transformCustomFields($fields, $total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the given field
|
||||||
|
* @author [V. Cordes] [<volker@fdatek.de>]
|
||||||
|
* @param int $id
|
||||||
|
* @since [v4.1.10]
|
||||||
|
* @return View
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$this->authorize('show', CustomField::class);
|
||||||
|
if ($field = CustomField::find($id)) {
|
||||||
|
return (new CustomFieldsTransformer)->transformCustomField($field);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/custom_fields/message.field.invalid')), 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified field
|
||||||
|
*
|
||||||
|
* @author [V. Cordes] [<volker@fdatek.de>]
|
||||||
|
* @since [v4.1.10]
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$this->authorize('edit', CustomField::class);
|
||||||
|
$field = CustomField::findOrFail($id);
|
||||||
|
$data = $request->all();
|
||||||
|
|
||||||
|
$validator = Validator::make($data, $field->validationRules());
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', null, $validator->errors()));
|
||||||
|
}
|
||||||
|
|
||||||
|
$field->fill($data);
|
||||||
|
|
||||||
|
if ($field->save()) {
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('success', $field, trans('admin/custom_fields/message.field.update.success')));
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', null, $field->getErrors()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created field.
|
||||||
|
*
|
||||||
|
* @author [V. Cordes] [<volker@fdatek.de>]
|
||||||
|
* @since [v4.1.10]
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$this->authorize('create', CustomField::class);
|
||||||
|
$field = new CustomField;
|
||||||
|
|
||||||
|
$data = $request->all();
|
||||||
|
$validator = Validator::make($data, $field->validationRules());
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', null, $validator->errors()));
|
||||||
|
}
|
||||||
|
$field->fill($data);
|
||||||
|
|
||||||
|
if ($field->save()) {
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('success', $field, trans('admin/custom_fields/message.field.create.success')));
|
||||||
|
}
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', null, $field->getErrors()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function postReorder(Request $request, $id)
|
public function postReorder(Request $request, $id)
|
||||||
{
|
{
|
||||||
$fieldset = CustomFieldset::find($id);
|
$fieldset = CustomFieldset::find($id);
|
||||||
|
|
|
@ -431,7 +431,7 @@ class UsersController extends Controller
|
||||||
public function postBulkEdit(Request $request)
|
public function postBulkEdit(Request $request)
|
||||||
{
|
{
|
||||||
$this->authorize('update', User::class);
|
$this->authorize('update', User::class);
|
||||||
if ((!Input::has('ids')) || (count(Input::has('ids')) == 0)) {
|
if ((!Input::has('ids')) || (count(Input::input('ids')) == 0)) {
|
||||||
return redirect()->back()->with('error', 'No users selected');
|
return redirect()->back()->with('error', 'No users selected');
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ class CustomFieldsTransformer
|
||||||
{
|
{
|
||||||
|
|
||||||
$array = [
|
$array = [
|
||||||
|
'id' => $field->id,
|
||||||
'name' => e($field->name),
|
'name' => e($field->name),
|
||||||
'db_column_name' => e($field->db_column_name()),
|
'db_column_name' => e($field->db_column_name()),
|
||||||
'format' => e($field->format),
|
'format' => e($field->format),
|
||||||
|
|
|
@ -8,6 +8,7 @@ use App\Http\Traits\UniqueUndeletedTrait;
|
||||||
use ForceUTF8\Encoding;
|
use ForceUTF8\Encoding;
|
||||||
use EasySlugger\Utf8Slugger;
|
use EasySlugger\Utf8Slugger;
|
||||||
use Patchwork\Utf8;
|
use Patchwork\Utf8;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class CustomField extends Model
|
class CustomField extends Model
|
||||||
{
|
{
|
||||||
|
@ -29,8 +30,18 @@ class CustomField extends Model
|
||||||
"BOOLEAN" => "boolean",
|
"BOOLEAN" => "boolean",
|
||||||
];
|
];
|
||||||
|
|
||||||
public $rules = [
|
/**
|
||||||
"name" => "required|unique:custom_fields"
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'element',
|
||||||
|
'format',
|
||||||
|
'field_values',
|
||||||
|
'field_encrypted',
|
||||||
|
'help_text'
|
||||||
];
|
];
|
||||||
|
|
||||||
// This is confusing, since it's actually the custom fields table that
|
// This is confusing, since it's actually the custom fields table that
|
||||||
|
@ -160,7 +171,7 @@ class CustomField extends Model
|
||||||
public function getFormatAttribute($value)
|
public function getFormatAttribute($value)
|
||||||
{
|
{
|
||||||
foreach (self::$PredefinedFormats as $name => $pattern) {
|
foreach (self::$PredefinedFormats as $name => $pattern) {
|
||||||
if ($pattern === $value) {
|
if ($pattern === $value || $name === $value) {
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,4 +259,26 @@ class CustomField extends Model
|
||||||
|
|
||||||
return substr($long_slug, 0, 50) . '_' . $id;
|
return substr($long_slug, 0, 50) . '_' . $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get validation rules for custom fields to use with Validator
|
||||||
|
* @author [V. Cordes] [<volker@fdatek.de>]
|
||||||
|
* @param int $id
|
||||||
|
* @since [v4.1.10]
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
|
public function validationRules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"name" => "required|unique:custom_fields",
|
||||||
|
"element" => [
|
||||||
|
"required",
|
||||||
|
Rule::in(['text', 'listbox'])
|
||||||
|
],
|
||||||
|
'format' => [
|
||||||
|
Rule::in(array_merge(array_keys(CustomField::$PredefinedFormats), CustomField::$PredefinedFormats))
|
||||||
|
],
|
||||||
|
'field_encrypted' => "nullable|boolean"
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||||
'jobtitle',
|
'jobtitle',
|
||||||
'location_id',
|
'location_id',
|
||||||
'password',
|
'password',
|
||||||
'phone_number',
|
'phone',
|
||||||
'username',
|
'username',
|
||||||
'first_name',
|
'first_name',
|
||||||
'address',
|
'address',
|
||||||
|
@ -44,6 +44,7 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||||
'state',
|
'state',
|
||||||
'country',
|
'country',
|
||||||
'zip',
|
'zip',
|
||||||
|
'activated',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
|
|
@ -479,15 +479,15 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@endcan
|
@endcan
|
||||||
@can('view', \App\Models\Component::class)
|
@can('view', \App\Models\Consumable::class)
|
||||||
<li{!! (Request::is('consunmables*') ? ' class="active"' : '') !!}>
|
<li{!! (Request::is('consumables*') ? ' class="active"' : '') !!}>
|
||||||
<a href="{{ url('consumables') }}">
|
<a href="{{ url('consumables') }}">
|
||||||
<i class="fa fa-tint"></i>
|
<i class="fa fa-tint"></i>
|
||||||
<span>{{ trans('general.consumables') }}</span>
|
<span>{{ trans('general.consumables') }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@endcan
|
@endcan
|
||||||
@can('view', \App\Models\Components::class)
|
@can('view', \App\Models\Component::class)
|
||||||
<li{!! (Request::is('components*') ? ' class="active"' : '') !!}>
|
<li{!! (Request::is('components*') ? ' class="active"' : '') !!}>
|
||||||
<a href="{{ route('components.index') }}">
|
<a href="{{ route('components.index') }}">
|
||||||
<i class="fa fa-hdd-o"></i>
|
<i class="fa fa-hdd-o"></i>
|
||||||
|
|
|
@ -200,6 +200,18 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
||||||
|
|
||||||
/*--- Fields API ---*/
|
/*--- Fields API ---*/
|
||||||
|
|
||||||
|
Route::resource('fields', 'CustomFieldsController', [
|
||||||
|
'names' => [
|
||||||
|
'index' => 'api.customfields.index',
|
||||||
|
'show' => 'api.customfields.show',
|
||||||
|
'store' => 'api.customfields.store',
|
||||||
|
'update' => 'api.customfields.update',
|
||||||
|
'destroy' => 'api.customfields.destroy'
|
||||||
|
],
|
||||||
|
'except' => [ 'create', 'edit' ],
|
||||||
|
'parameters' => [ 'field' => 'field_id' ]
|
||||||
|
]);
|
||||||
|
|
||||||
Route::group(['prefix' => 'fields'], function () {
|
Route::group(['prefix' => 'fields'], function () {
|
||||||
Route::post('fieldsets/{id}/order',
|
Route::post('fieldsets/{id}/order',
|
||||||
[
|
[
|
||||||
|
@ -207,13 +219,6 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
||||||
'uses' => 'CustomFieldsController@postReorder'
|
'uses' => 'CustomFieldsController@postReorder'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
Route::get('/',
|
|
||||||
[
|
|
||||||
'as' => 'api.customfields.index',
|
|
||||||
'uses' => 'CustomFieldsController@index'
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}); // Fields group
|
}); // Fields group
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue