112 lines
3.2 KiB
PHP
112 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\View\Components;
|
|
|
|
use App\Abstracts\View\Component;
|
|
use Illuminate\Support\Str;
|
|
|
|
class Title extends Component
|
|
{
|
|
public $textSize;
|
|
|
|
public $icon;
|
|
|
|
/**
|
|
* Create a new component instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(
|
|
string $textSize = '',
|
|
string $icon = '',
|
|
) {
|
|
$this->textSize = $this->getTextSize($textSize);
|
|
$this->icon = $icon ?: $this->resolveIcon();
|
|
}
|
|
|
|
/**
|
|
* Get the view / contents that represent the component.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View|string
|
|
*/
|
|
public function render()
|
|
{
|
|
return view('components.title');
|
|
}
|
|
|
|
protected function getTextSize($textSize)
|
|
{
|
|
switch ($textSize) {
|
|
case 'short':
|
|
$textSize = '15';
|
|
break;
|
|
default:
|
|
$textSize = '25';
|
|
break;
|
|
}
|
|
|
|
return $textSize;
|
|
}
|
|
|
|
/**
|
|
* Keep page-title icons consistent across the application.
|
|
*/
|
|
protected function resolveIcon(): string
|
|
{
|
|
$route = request()->route();
|
|
$routeName = is_object($route) && method_exists($route, 'getName')
|
|
? (string) $route->getName()
|
|
: '';
|
|
$context = Str::lower($routeName . ' ' . request()->path());
|
|
|
|
$icons = [
|
|
'financial-risk-control' => 'security',
|
|
'store-receiving-bills' => 'account_balance_wallet',
|
|
'marketing-account-bills' => 'account_balance_wallet',
|
|
'supplier-payables' => 'local_shipping',
|
|
'goods-reconciliations' => 'fact_check',
|
|
'dashboards' => 'dashboard',
|
|
'reports' => 'analytics',
|
|
'companies' => 'business',
|
|
'users' => 'manage_accounts',
|
|
'roles' => 'admin_panel_settings',
|
|
'permissions' => 'admin_panel_settings',
|
|
'customers' => 'groups',
|
|
'contacts' => 'groups',
|
|
'vendors' => 'engineering',
|
|
'suppliers' => 'local_shipping',
|
|
'recurring-invoices' => 'request_quote',
|
|
'invoices' => 'description',
|
|
'recurring-bills' => 'receipt_long',
|
|
'bills' => 'receipt_long',
|
|
'payments' => 'payments',
|
|
'transactions' => 'receipt_long',
|
|
'reconciliations' => 'fact_check',
|
|
'transfers' => 'sync_alt',
|
|
'banking' => 'account_balance',
|
|
'accounts' => 'account_balance_wallet',
|
|
'items' => 'inventory_2',
|
|
'inventory' => 'inventory_2',
|
|
'currencies' => 'paid',
|
|
'taxes' => 'percent',
|
|
'categories' => 'folder',
|
|
'email-templates' => 'mark_email_read',
|
|
'settings' => 'settings',
|
|
'import' => 'upload_file',
|
|
'modules' => 'extension',
|
|
'apps' => 'extension',
|
|
'notifications' => 'notifications',
|
|
'profile' => 'person',
|
|
'wizard' => 'auto_fix_high',
|
|
];
|
|
|
|
foreach ($icons as $needle => $icon) {
|
|
if (Str::contains($context, $needle)) {
|
|
return $icon;
|
|
}
|
|
}
|
|
|
|
return 'description';
|
|
}
|
|
}
|