6
0
Fork 0
jiqu-library-server/app/Admin/Widgets/InfoBox.php

111 lines
1.8 KiB
PHP

<?php
namespace App\Admin\Widgets;
use Dcat\Admin\Widgets\Widget;
class InfoBox extends Widget
{
/**
* @var string
*/
protected $view = 'admin::widgets.info-box';
/**
* @var string
*/
protected $title;
/**
* @var string
*/
protected $content;
/**
* @var string
*/
protected $style = 'primary';
/**
* @var string
*/
protected $icon;
public function __construct(string $title, string $content, ?string $icon = null)
{
$this->title($title);
$this->content($content);
$this->icon($icon);
}
/**
* Info Box 图标
*
* @param string $icon
* @return $this
*/
public function icon(string $icon = null)
{
$this->icon = $icon;
return $this;
}
/**
* Info Box 内容
*
* @param string $content
* @return $this
*/
public function content($content)
{
$this->content = $content;
return $this;
}
/**
* Info Box 标题
*
* @param string $title
* @return $this
*/
public function title($title)
{
$this->title = $title;
return $this;
}
/**
* Add style.
*
* @param string $style
* @return $this
*/
public function style($style = 'info')
{
$this->style = $style;
return $this;
}
/**
* Variables in view.
*
* @return array
*/
public function defaultVariables()
{
$this->class('info-box');
return [
'title' => $this->title,
'content' => $this->content,
'icon' => $this->icon,
'style' => $this->style,
'attributes' => $this->formatHtmlAttributes(),
];
}
}