mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
adds custom fields as an example in label settings
This commit is contained in:
parent
88a84e9350
commit
5cbcac28b1
|
@ -6,6 +6,7 @@ use App\Models\Asset;
|
||||||
use App\Models\AssetModel;
|
use App\Models\AssetModel;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
use App\Models\CustomFieldset;
|
||||||
use App\Models\Labels\Label;
|
use App\Models\Labels\Label;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
use App\Models\Manufacturer;
|
use App\Models\Manufacturer;
|
||||||
|
@ -26,6 +27,21 @@ class LabelsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function show(string $labelName)
|
public function show(string $labelName)
|
||||||
{
|
{
|
||||||
|
$data = explode(';', Setting::getSettings()->label2_fields);
|
||||||
|
$fields = str_replace('=', ' ', $data);
|
||||||
|
|
||||||
|
$custom_fields= [];
|
||||||
|
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
|
||||||
|
$parts = explode('_', $field, 2);
|
||||||
|
|
||||||
|
$key = trim($parts[0]);
|
||||||
|
$value = trim($parts[1]);
|
||||||
|
|
||||||
|
$custom_fields["_".$value] = $key ;
|
||||||
|
}
|
||||||
|
// dd($custom_fields);
|
||||||
$labelName = str_replace('/', '\\', $labelName);
|
$labelName = str_replace('/', '\\', $labelName);
|
||||||
$template = Label::find($labelName);
|
$template = Label::find($labelName);
|
||||||
|
|
||||||
|
@ -65,6 +81,11 @@ class LabelsController extends Controller
|
||||||
$exampleAsset->model->category->id = 999999;
|
$exampleAsset->model->category->id = 999999;
|
||||||
$exampleAsset->model->category->name = trans('admin/labels/table.example_category');
|
$exampleAsset->model->category->name = trans('admin/labels/table.example_category');
|
||||||
|
|
||||||
|
|
||||||
|
foreach($custom_fields as $key => $value){
|
||||||
|
$exampleAsset->{$key} = "{{$value}}" ;
|
||||||
|
}
|
||||||
|
|
||||||
$settings = Setting::getSettings();
|
$settings = Setting::getSettings();
|
||||||
if (request()->has('settings')) {
|
if (request()->has('settings')) {
|
||||||
$overrides = request()->get('settings');
|
$overrides = request()->get('settings');
|
||||||
|
|
Loading…
Reference in a new issue