snipe-it/app/Presenters/AssetModelPresenter.php

96 lines
1.9 KiB
PHP
Raw Normal View History

<?php
namespace App\Presenters;
use App\Helpers\Helper;
/**
* Class AssetModelPresenter
* @package App\Presenters
*/
class AssetModelPresenter extends Presenter
{
2017-02-10 18:43:30 -08:00
/**
* Formatted note for this model
* @return string
*/
public function note()
{
$Parsedown = new \Parsedown();
if ($this->model->note) {
return $Parsedown->text($this->model->note);
}
}
public function eolText()
{
2016-12-29 14:02:18 -08:00
if ($this->eol) {
return $this->eol.' '.trans('general.months');
}
return '';
}
/**
* Pretty name for this model
* @return string
*/
public function modelName()
{
2017-10-26 21:50:39 -07:00
$name = '';
if ($this->model->manufacturer) {
$name .= $this->model->manufacturer->name.' ';
2017-10-26 21:50:39 -07:00
}
$name .= $this->name;
if ($this->model_number) {
2017-10-26 21:50:39 -07:00
$name .=" (#".$this->model_number.')';
}
return $name;
}
/**
* Standard url for use to view page.
* @return string
*/
public function nameUrl()
{
2016-12-29 14:02:18 -08:00
return (string) link_to_route('models.show', $this->name, $this->id);
}
/**
* Generate img tag to this models image.
* @return string
*/
public function imageUrl()
{
2016-12-29 14:02:18 -08:00
if (!empty($this->image)) {
2020-03-27 15:35:29 -07:00
return '<img src="' . url('/') . '/uploads/models/' . $this->image . '" alt="'.$this->name.'" height="50" width="50">';
}
return '';
}
2017-11-02 04:15:09 -07:00
/**
* Generate img tag to this models image.
* @return string
*/
public function imageSrc()
{
if (!empty($this->image)) {
return url('/') . '/uploads/models/' . $this->image;
}
return '';
}
/**
* Url to view this item.
* @return string
*/
public function viewUrl()
{
return route('models.show', $this->id);
}
}