adds custom fields as an example in label settings

This commit is contained in:
Godfrey M 2024-02-14 16:53:38 -08:00
parent 88a84e9350
commit 5cbcac28b1
2 changed files with 22 additions and 1 deletions

View file

@ -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');

View file

@ -1,4 +1,4 @@
@extends('layouts/default') @extends('layouts/default')
{{-- Page title --}} {{-- Page title --}}
@section('title') @section('title')