0) {
foreach ($customAttributes as $key => $value) {
$attributes .= $key . '="' . $value . '" ';
}
}
return '' . $iconText . ' ';
}
public static function dropdown(
string $iconClass,
array $dropdownItems,
array $customClass = [],
array $customAttributes = []
) {
$customClassStr = implode(' ', $customClass);
$class = self::$defaultClasses . ' dropdown ' . $customClassStr;
$attributes = '';
if (count($customAttributes) > 0) {
foreach ($customAttributes as $key => $value) {
$attributes .= $key . '="' . $value . '" ';
}
}
$dropdown = '
';
$dropdown .= '';
$dropdown .= '';
$dropdown .= '
';
return $dropdown;
}
/**
* @param string $dataBsTarget
* @param null $customClass
* @param null $id
* @param string $iconClass
* @param null $onClick
* @return string
*/
public static function editButton($url, bool $modal = false, $dataBsTarget = '#editModal', $customClass = null, $id = null, $iconClass = 'fa fa-edit', $onClick = null)
{
$customClass = ['btn-primary' . ' ' . $customClass];
$customAttributes = [
'title' => trans('Edit'),
];
if ($modal) {
$customAttributes = [
'title' => trans('Edit'),
'data-bs-target' => $dataBsTarget,
'data-bs-toggle' => 'modal',
'id' => $id,
'onclick' => $onClick,
];
$customClass[] = 'edit_btn set-form-url';
}
return self::button($iconClass, $url, $customClass, $customAttributes);
}
/**
* @param null $id
* @param null $dataId
* @param null $dataCategory
* @param null $customClass
* @return string
*/
public static function deleteButton($url, $id = null, $dataId = null, $dataCategory = null, $customClass = null)
{
// dd($dataId);
$customClass = ['delete-form', 'btn-danger' . $customClass];
$customAttributes = [
'title' => trans('Delete'),
'id' => $id,
'data-id' => $dataId,
'data-category' => $dataCategory,
];
$iconClass = 'fas fa-trash';
return self::button($iconClass, $url, $customClass, $customAttributes);
}
/**
* @return string
*/
public static function restoreButton($url, string $title = 'Restore')
{
$customClass = ['btn-gradient-success', 'restore-data'];
$customAttributes = [
'title' => trans($title),
];
$iconClass = 'fa fa-refresh';
return self::button($iconClass, $url, $customClass, $customAttributes);
}
/**
* @return string
*/
public static function trashButton($url)
{
$customClass = ['btn-gradient-danger', 'trash-data'];
$customAttributes = [
'title' => trans('Delete Permanent'),
];
$iconClass = 'fa fa-times';
return self::button($iconClass, $url, $customClass, $customAttributes);
}
public static function optionButton($url)
{
$customClass = ['btn-option'];
$customAttributes = [
'title' => trans('View Option Data'),
];
$iconClass = 'bi bi-gear';
$iconText = ' Options';
return self::button($iconClass, $url, $customClass, $customAttributes, $iconText);
}
}