1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 23:52:33 +01:00
invoiceninja/app/Helpers/ClientPortal.php

66 lines
1.5 KiB
PHP
Raw Normal View History

2020-03-23 18:10:42 +01:00
<?php
2020-12-24 17:01:34 +01:00
2020-03-23 18:10:42 +01:00
/**
* Invoice Ninja (https://invoiceninja.com).
2020-03-23 18:10:42 +01:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2020-03-23 18:10:42 +01:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2020-03-23 18:10:42 +01:00
*/
2020-10-28 11:10:49 +01:00
use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Facades\Route;
2020-10-28 11:10:49 +01:00
use Illuminate\View\View;
2020-03-23 18:10:42 +01:00
/**
* Check if passed page is currently active.
*
* @param $page
* @param bool $boolean
2023-07-25 12:24:33 +02:00
* @return bool | string
2020-03-23 18:10:42 +01:00
*/
function isActive($page, bool $boolean = false)
{
$current_page = Route::currentRouteName();
$action = Route::currentRouteAction(); // string
2023-02-16 02:36:09 +01:00
$show = str_replace(['.show','payment_methodss','documentss','subscriptionss','paymentss'], ['s.index','payment_methods','documents','subscriptions','payments'], $current_page);
2020-03-23 18:10:42 +01:00
if ($page == $current_page && $boolean) {
2020-03-23 18:10:42 +01:00
return true;
}
2020-03-23 18:10:42 +01:00
if ($page == $current_page) {
2021-05-19 13:28:06 +02:00
return 'bg-gray-200';
}
2020-03-23 18:10:42 +01:00
2023-02-16 02:36:09 +01:00
if (($page == $show) && $boolean) {
return true;
}
2020-03-23 18:10:42 +01:00
return false;
}
/**
* New render method that works with themes.
*
* @param string $path
* @param array $options
2020-10-28 11:10:49 +01:00
* @return Factory|View
2020-03-23 18:10:42 +01:00
*/
function render(string $path, array $options = [])
{
$theme = array_key_exists('theme', $options) ? $options['theme'] : 'ninja2020';
if (array_key_exists('root', $options)) {
return view(
sprintf('%s.%s.%s', $options['root'], $theme, $path),
$options
);
2020-03-23 18:10:42 +01:00
}
return view("portal.$theme.$path", $options);
}