mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Check that there is a company before trying to get name property
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
7eaf3174ab
commit
027afa71f1
|
@ -49,8 +49,12 @@ class Label implements View
|
||||||
->with('count', $this->data->get('count'));
|
->with('count', $this->data->get('count'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($template)) $template = LabelModel::find($settings->label2_template);
|
// If a specific template was set, use it, otherwise fall back to default
|
||||||
elseif (is_string($template)) $template = LabelModel::find($template);
|
if (empty($template)) {
|
||||||
|
$template = LabelModel::find($settings->label2_template);
|
||||||
|
} elseif (is_string($template)) {
|
||||||
|
$template = LabelModel::find($template);
|
||||||
|
}
|
||||||
|
|
||||||
$template->validate();
|
$template->validate();
|
||||||
|
|
||||||
|
@ -87,25 +91,36 @@ class Label implements View
|
||||||
$assetData->put('tag', $asset->asset_tag);
|
$assetData->put('tag', $asset->asset_tag);
|
||||||
|
|
||||||
if ($template->getSupportTitle()) {
|
if ($template->getSupportTitle()) {
|
||||||
$title = !empty($settings->label2_title) ?
|
|
||||||
str_ireplace('{COMPANY}', $asset->company->name, $settings->label2_title) :
|
if ($asset->company && !empty($settings->label2_title)) {
|
||||||
|
$title = str_replace('{COMPANY}', $asset->company->name, $settings->label2_title);
|
||||||
$settings->qr_text;
|
$settings->qr_text;
|
||||||
if (!empty($title)) $assetData->put('title', $title);
|
$assetData->put('title', $title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($template->getSupportLogo()) {
|
if ($template->getSupportLogo()) {
|
||||||
$logo = $settings->label2_asset_logo ?
|
|
||||||
(
|
$logo = null;
|
||||||
!empty($asset->company->image) ?
|
|
||||||
Storage::disk('public')->path('companies/'.e($asset->company->image)) :
|
// Should we be trying to use a logo at all?
|
||||||
null
|
if ($settings->label2_asset_logo='1') {
|
||||||
) :
|
|
||||||
(
|
// If we don't have a company image, fall back to the general site label image
|
||||||
!empty($settings->label_logo) ?
|
if (!empty($settings->label_logo)) {
|
||||||
Storage::disk('public')->path(''.e($settings->label_logo)) :
|
$logo = Storage::disk('public')->path('/'.e($settings->label_logo));
|
||||||
null
|
}
|
||||||
);
|
|
||||||
if (!empty($logo)) $assetData->put('logo', $logo);
|
// If we have a company logo, use that first
|
||||||
|
if (($asset->company) && ($asset->company->image!='')) {
|
||||||
|
$logo = Storage::disk('public')->path('companies/'.e($asset->company->image));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($logo)) {
|
||||||
|
$assetData->put('logo', $logo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($template->getSupport1DBarcode()) {
|
if ($template->getSupport1DBarcode()) {
|
||||||
|
|
Loading…
Reference in a new issue