2022-06-01 10:15:55 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\View\Components;
|
|
|
|
|
|
|
|
use App\Abstracts\View\Component;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
class Icon extends Component
|
|
|
|
{
|
|
|
|
/** @var string */
|
|
|
|
public $icon;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $class;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $filled;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $rounded;
|
|
|
|
|
2023-04-20 17:42:44 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $sharp;
|
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
/** @var bool */
|
|
|
|
public $simpleIcons;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $custom;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $alias;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new component instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct(
|
2023-04-20 17:42:44 +03:00
|
|
|
string $icon = '', string $class = '',
|
|
|
|
bool $filled = false, bool $rounded = false, bool $sharp = false,
|
2022-06-01 10:15:55 +03:00
|
|
|
bool $simpleIcons = false, bool $custom = false, string $alias = ''
|
|
|
|
) {
|
|
|
|
$this->icon = $icon;
|
|
|
|
$this->class = ($simpleIcons) ? 'w-8 h-8 ' . $class : $class;
|
|
|
|
$this->filled = $filled;
|
|
|
|
$this->rounded = $rounded;
|
2023-04-20 17:42:44 +03:00
|
|
|
$this->sharp = $sharp;
|
2022-06-01 10:15:55 +03:00
|
|
|
$this->simpleIcons = $simpleIcons;
|
|
|
|
$this->custom = $custom;
|
|
|
|
$this->alias = $alias;
|
|
|
|
|
|
|
|
if ($custom) {
|
|
|
|
$this->icon = $this->getCustomIcon($icon, $alias);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the view / contents that represent the component.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Contracts\View\View|string
|
|
|
|
*/
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('components.icon');
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getCustomIcon($icon, $alias)
|
|
|
|
{
|
|
|
|
$slug = Str::replace('custom-', '', $icon);
|
|
|
|
|
|
|
|
$base_path = 'public/img/icons/';
|
|
|
|
|
|
|
|
if (! empty($alias)) {
|
|
|
|
$base_path = 'modules/' . Str::studly($alias) . '/Resources/assets/img/icons/';
|
|
|
|
}
|
|
|
|
|
|
|
|
$path = base_path($base_path . $slug . '.svg');
|
|
|
|
|
|
|
|
if (! file_exists($path)) {
|
|
|
|
$path = 'public/img/akaunting-logo-purple.svg';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $path;
|
|
|
|
}
|
|
|
|
}
|