Inital Commit
This commit is contained in:
194
app/Helpers/BibClass.php
Normal file
194
app/Helpers/BibClass.php
Normal file
@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class BibClass
|
||||
{
|
||||
static function createSelect($HTMLLabel, $tableName, $valueField, $displayField, $condition = "", $defaultValue = "", $HTMLName = "", $HTMLId = "", $HTMLClass = "", $HTMLRequired = "")
|
||||
{
|
||||
$tableName = strtolower($tableName);
|
||||
$query = "SELECT $valueField, $displayField FROM $tableName";
|
||||
if ($condition != "") {
|
||||
$query .= " WHERE $condition";
|
||||
}
|
||||
|
||||
$results = DB::select(DB::raw($query));
|
||||
?>
|
||||
<label for="<?php echo $HTMLId; ?>" class="form-label col-form-label"> <?php echo label($HTMLLabel); ?> </label>
|
||||
<select class="form-select <?php echo $HTMLClass ?>" name="<?php echo $HTMLName; ?>" data-search="true" id="<?php echo $HTMLId; ?>" aria-label="Default select example" <?php echo ($HTMLRequired) ? "Required" : ""; ?>>
|
||||
<option value=""><?php label("Select Option"); ?></option>
|
||||
<?php foreach ($results as $item) { ?>
|
||||
<option value="<?php echo $item->$valueField ?>" <?php echo $item->$valueField == $defaultValue ? 'selected' : '' ?>><?php echo $item->$displayField ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
<p id='error_<?php echo $HTMLName; ?>' class='text-danger custom-error'></p>
|
||||
<?php
|
||||
}
|
||||
static function lookupField($tableName, $field, $refField, $refValue)
|
||||
{
|
||||
$tableName = strtolower($tableName);
|
||||
$t = "select $field from $tableName where $refField = '$refValue'";
|
||||
$Value = DB::select($t);
|
||||
|
||||
if (!empty($Value)) {
|
||||
return $Value[0]->$field;
|
||||
} else {
|
||||
return "Not Found in Table";
|
||||
}
|
||||
}
|
||||
static function getRow($tableName, $condition = "1")
|
||||
{
|
||||
$tableName = strtolower($tableName);
|
||||
$t = "select * from $tableName where $condition";
|
||||
$Value = DB::select($t);
|
||||
return (empty($Value) ? "Not Found" : $Value[0]);
|
||||
}
|
||||
static function getRowByQuery($query)
|
||||
{
|
||||
$Value = DB::select($query);
|
||||
return (empty($Value) ? false : $Value[0]);
|
||||
}
|
||||
static function getTableByQuery($query)
|
||||
{
|
||||
$Value = DB::select($query);
|
||||
|
||||
return (empty($Value) ? false : $Value);
|
||||
}
|
||||
static function updateRow($tableName, $fieldName, $fieldValue, $referenceField, $referenceValue)
|
||||
{
|
||||
$tableName = strtolower($tableName);
|
||||
$t = "update $tableName set $fieldName='$fieldValue' where $referenceField=$referenceValue";
|
||||
return DB::select($t);
|
||||
}
|
||||
public static function pre($array)
|
||||
{
|
||||
echo "<pre>";
|
||||
print_r($array);
|
||||
echo "</pre>";
|
||||
}
|
||||
public static function addButton($path, $text)
|
||||
{
|
||||
?>
|
||||
<a href="<?php echo url($path); ?>" class="btn btn-primary btn-sm pull-right">
|
||||
<em class="icon ni ni-plus"></em><span><?php echo $text; ?></span>
|
||||
</a>
|
||||
<?php
|
||||
}
|
||||
public static function addRowActions($pk)
|
||||
{
|
||||
|
||||
|
||||
echo "<ul class=\"d-flex flex-wrap\">
|
||||
<li><a href=\"#\" type=\"button\" class=\"btn btn-color-success btn-hover-success btn-icon btn-soft\" ><em class=\"icon ni ni-eye\"></em></a></li>
|
||||
<li><a href=\"form2.php\" type=\"button\" class=\"btn btn-color-primary btn-hover-primary btn-icon btn-soft\" data-bs-toggle=\"tooltip\" data-bs-placement=\"top\" data-bs-custom-class=\"custom-tooltip\" title=\"Edit\"> <em class=\"icon ni ni-edit\"></em></a></li>
|
||||
<li><button type=\"button\" class=\"btn btn-color-danger btn-hover-danger btn-icon btn-soft\"><em class=\"icon ni ni-trash\"></em></button></li>
|
||||
</ul>";
|
||||
BibClass::addButton("edit/$pk", 'Edit');
|
||||
BibClass::addButton("view/$pk", 'View');
|
||||
BibClass::addButton("destroy/$pk", 'Delete');
|
||||
}
|
||||
|
||||
public static function getController()
|
||||
{
|
||||
$routeArray = app('request')->route()->getAction();
|
||||
$controllerAction = class_basename($routeArray['controller']);
|
||||
list($controller, $action) = explode('@', $controllerAction);
|
||||
|
||||
print_r($controller);
|
||||
}
|
||||
public static function createSidebarMenu($link, $name, $target = "")
|
||||
{
|
||||
?>
|
||||
<li class="nk-menu-item"><a href="<?php echo $link; ?>" class="nk-menu-link" <?php echo ($target != "") ? "target=\"_blank\"" : ""; ?>><span class="nk-menu-text"><?php echo $name; ?></span></a></li>
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function dataTable($TableRows, $TableName)
|
||||
{
|
||||
$TableName = strtolower($TableName);
|
||||
$Table_pk = str_replace("tbl_", "", $TableName) . "_id";
|
||||
$TableCols = array_keys((array)$TableRows[0]);
|
||||
|
||||
//BibClass::pre($TableCols);
|
||||
?>
|
||||
<table class="datatable-init table" data-nk-container="table-responsive table-border">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ($TableCols as $TableCol) : //echo $TableCol;
|
||||
?>
|
||||
<?php switch ($TableCol) {
|
||||
case $Table_pk:
|
||||
case 'created_by':
|
||||
case 'created_on':
|
||||
case 'remarks':
|
||||
case 'status':
|
||||
case 'created_at':
|
||||
case 'updated_at':
|
||||
break;
|
||||
default:
|
||||
?>
|
||||
<th class="text-nowrap"><span class="overline-title"><?php echo label($TableCol); ?></span>
|
||||
</th>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($TableRows as $TableRow) : ?>
|
||||
<tr>
|
||||
<?php foreach ($TableCols as $TableCol) : //echo $TableCol;
|
||||
?>
|
||||
<?php switch ($TableCol) {
|
||||
case $Table_pk:
|
||||
case 'created_by':
|
||||
case 'created_on':
|
||||
case 'remarks':
|
||||
case 'status':
|
||||
case 'created_at':
|
||||
case 'updated_at':
|
||||
break;
|
||||
default:
|
||||
?>
|
||||
<th class="text-nowrap"><span class="overline-title"><?php echo $TableRow->$TableCol; ?></span>
|
||||
</th>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
public static function tableEntryForm($tableName)
|
||||
{
|
||||
$tableName = strtolower($tableName);
|
||||
$Table_pk = str_replace("tbl_", "", $tableName) . "_id";
|
||||
$tableFields = DB::select("describe " . $tableName);
|
||||
foreach ($tableFields as $tableField) {
|
||||
$tableField = $tableField->Field;
|
||||
switch ($tableField) {
|
||||
case $Table_pk:
|
||||
case 'status':
|
||||
case 'created_at':
|
||||
case 'updated_at':
|
||||
break;
|
||||
default:
|
||||
createInput("text", $tableField, $tableField, $tableField, "", "", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
525
app/Helpers/MPCMS.php
Normal file
525
app/Helpers/MPCMS.php
Normal file
@ -0,0 +1,525 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Menulocations;
|
||||
use App\Models\News;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class MPCMS
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->initDB();
|
||||
}
|
||||
|
||||
public static function showCount($table)
|
||||
{
|
||||
$count = DB::table($table)->where('status', '!=', -1)->count();
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
||||
public static function createMenuLink($text, $URL)
|
||||
{
|
||||
$isActive = request()->fullUrl() == $URL;
|
||||
$activeClass = $isActive ? 'active' : '';
|
||||
?>
|
||||
<li>
|
||||
<a class="nav-link menu-link <?php echo $activeClass; ?>" href="<?php echo $URL; ?>"><i
|
||||
class="ri-file-text-line "></i> <span data-key="t-landing"><?php echo $text; ?></span></a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function getslider()
|
||||
{
|
||||
$Gallery = DB::table('sliders')->where('status', 1)->orderBy('display_order')->get();
|
||||
return $Gallery;
|
||||
}
|
||||
public static function getCustomFields()
|
||||
{
|
||||
$Rows = DB::table('customfields')->where('status', 1)->orderBy('display_order')->get();
|
||||
return $Rows;
|
||||
}
|
||||
public static function getGallery($gallery_id)
|
||||
{
|
||||
$Gallery = DB::select("select * from tbl_galleries where gallery_id='$gallery_id'")[0];
|
||||
$clients = DB::select('select * from tbl_photos where galleries_id=' . $Gallery->gallery_id . ' and status=1');
|
||||
return $clients;
|
||||
}
|
||||
public static function getGalleryByAlias($alias)
|
||||
{
|
||||
$alias = trim($alias, "'\""); // Remove leading/trailing quotes, if present
|
||||
$gallery = DB::table("galleries")->where('alias', $alias)->first();
|
||||
|
||||
if (!$gallery) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$photos = DB::table('photos')->where('galleries_id', $gallery->gallery_id)->where('status', 1)->get();
|
||||
|
||||
return $photos;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getarticle($alias = '')
|
||||
{
|
||||
$t = "select * from tbl_companyarticles where status=1";
|
||||
|
||||
if ($alias != '') {
|
||||
$t .= " and alias='$alias'";
|
||||
// dd($t);
|
||||
$Article = DB::select($t);
|
||||
if (!$Article)
|
||||
$Article = DB::select("select * from tbl_companyarticles where status=1 LIMIT 1");
|
||||
$Article = $Article[0];
|
||||
$Aboutus = $Article;
|
||||
$q = "select * from tbl_companyarticles where parent_article=$Aboutus->article_id";
|
||||
$Aboutus->children = DB::select($q);
|
||||
} else {
|
||||
|
||||
$Aboutus = DB::select($t);
|
||||
}
|
||||
//dd($Aboutus);die;
|
||||
return $Aboutus;
|
||||
}
|
||||
|
||||
public static function getgalleries($alias = '', $limit = "")
|
||||
{
|
||||
$q = "select * from tbl_galleries ";
|
||||
if ($alias != '') {
|
||||
$q .= " where alias='$alias'";
|
||||
$Gallerys = DB::select($q)[0];
|
||||
|
||||
$t = 'select * from tbl_photos where galleries_id=' . $Gallerys->gallery_id . ' and status=1 ORDER BY photo_id DESC';
|
||||
if ($limit != '') {
|
||||
$t .= " limit $limit";
|
||||
}
|
||||
$Gallerys->images = DB::select($t);
|
||||
} else {
|
||||
$Gallerys = DB::select($q);
|
||||
foreach ($Gallerys as $Gallery) {
|
||||
$t = 'select * from tbl_photos where galleries_id=' . $Gallery->gallery_id . ' and status=1 ORDER BY photo_id DESC';
|
||||
if ($limit != '') {
|
||||
$t .= " limit $limit";
|
||||
}
|
||||
$Gallery->images = DB::select($t);
|
||||
}
|
||||
}
|
||||
// BIBHelper::pre($Gallerys);
|
||||
return $Gallerys;
|
||||
}
|
||||
|
||||
static public function showMenu($menulocation_alias)
|
||||
{
|
||||
$MenuItems = MPCMS::getMenuItems($menulocation_alias);
|
||||
// dd($MenuItems);
|
||||
|
||||
?>
|
||||
<ul class="menu">
|
||||
<?php foreach ($MenuItems as $menuItem): ?>
|
||||
<?php $menuItem->alias = str_replace("-", "_", $menuItem->alias); ?>
|
||||
<li class="nav-item <?php if (!empty($menuItem->children)): ?> dropdown <?php endif; ?>" id="myDropdown">
|
||||
<a class="nav-link <?php if (!empty($menuItem->children)): ?> dropdown-toggle <?php endif; ?>" <?php if (!empty($menuItem->children)): ?> data-bs-toggle="dropdown" <?php endif; ?> aria-current="page"
|
||||
href="<?php if ($menuItem->type != ""): ?>
|
||||
<?php echo route($menuItem->alias); ?><?php else: ?><?php echo site_url(ltrim($menuItem->ref, '/')); ?><?php endif; ?>" target="<?php echo strtolower($menuItem->target) ?>">
|
||||
|
||||
<?php echo $menuItem->title; ?>
|
||||
</a>
|
||||
<?php if (!empty($menuItem->children)): ?>
|
||||
<ul class="dropdown-menu">
|
||||
<?php foreach ($menuItem->children as $menu): ?>
|
||||
<li> <a class="dropdown-item" href="<?php echo route($menuItem->alias . '.' . $menu->alias) ?>"
|
||||
target="<?php echo strtolower($menuItem->target); ?>"> <?php echo $menu->title; ?> </a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
public static function showTopMenu($menulocation_alias)
|
||||
{
|
||||
$MenuItems = MPCMS::getMenuItems($menulocation_alias);
|
||||
// dd($MenuItems);
|
||||
|
||||
?>
|
||||
<ul class="menu">
|
||||
<?php foreach ($MenuItems as $MenuItem): ?>
|
||||
<?php $MenuItem->alias = str_replace("-", "_", $MenuItem->alias); ?>
|
||||
<li <?php if ($MenuItem->alias == "quote"): ?>class="extra-menu-item menu-item-button-link" <?php endif; ?> <?php if (!empty($MenuItem->children)): ?>class="has-children" <?php endif; ?>>
|
||||
<a <?php if ($MenuItem->alias == "quote"): ?> class="fh-btn btn" <?php endif; ?> <?php if (!empty($MenuItem->children)): ?>class="dropdown-toggle" <?php endif; ?>
|
||||
href="<?php if ($MenuItem->type !== ""): ?><?php echo route($MenuItem->alias); ?><?php else: ?><?php echo site_url(ltrim($MenuItem->ref, '/')); ?><?php endif; ?>"
|
||||
target="<?php echo strtolower($MenuItem->target); ?>">
|
||||
<?php echo $MenuItem->title; ?>
|
||||
</a>
|
||||
<?php if (!empty($MenuItem->children)): ?>
|
||||
<ul class="sub-menu">
|
||||
<?php foreach ($MenuItem->children as $subMenu): ?>
|
||||
<li><a href="<?php echo route($MenuItem->alias . '.' . $subMenu->alias); ?>"
|
||||
target="<?php echo strtolower($MenuItem->target); ?>"><?php echo $subMenu->title; ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
public static function showTopFooter($menuLocationAlias)
|
||||
{
|
||||
$menuItems = MPCMS::getFooMenuItems($menuLocationAlias);
|
||||
// dd($menuItems);
|
||||
?>
|
||||
<ul class="menu">
|
||||
<?php foreach ($menuItems as $menuItem): ?>
|
||||
|
||||
<li><a
|
||||
href="<?php echo route('services.' . $menuItem->alias); ?>target =<?php $menuItem->target ?>"><?php echo $menuItem->title; ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getMenuItems($menulocation_alias, $parentId = 0)
|
||||
{
|
||||
$menulocations_id = DB::table('menulocations')
|
||||
->where('alias', $menulocation_alias)
|
||||
->value('menulocation_id');
|
||||
// dd($menulocation_alias);
|
||||
$menuItems = DB::table('menuitems')
|
||||
->where('menulocations_id', $menulocations_id)
|
||||
->where('parent_menu', $parentId)
|
||||
->where('status', '<>', -1)
|
||||
->orderBy('display_order')
|
||||
->get();
|
||||
// dd($menuItems);
|
||||
$result = [];
|
||||
foreach ($menuItems as $menuItem) {
|
||||
$children = self::getMenuItems($menulocation_alias, $menuItem->menu_id);
|
||||
$menuItem->children = $children;
|
||||
$result[] = $menuItem;
|
||||
}
|
||||
// dd($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getFooMenuItems($menulocation_alias, $parentId = 0)
|
||||
{
|
||||
$menulocations_id = DB::table('menulocations')
|
||||
->where('alias', $menulocation_alias)
|
||||
->value('menulocation_id');
|
||||
// dump($menulocations_id);
|
||||
$menuItems = DB::table('menuitems')
|
||||
->where('menulocations_id', $menulocations_id)
|
||||
// ->where('parent_menu', $parentId)
|
||||
->where('status', '<>', -1)
|
||||
->orderBy('display_order')
|
||||
->get();
|
||||
// dd($menuItems);
|
||||
$result = [];
|
||||
foreach ($menuItems as $menuItem) {
|
||||
$children = self::getMenuItems($menulocation_alias, $menuItem->menu_id);
|
||||
$menuItem->children = $children;
|
||||
$result[] = $menuItem;
|
||||
}
|
||||
// dd($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getSiteVars()
|
||||
{
|
||||
$siteVars = DB::table("settings")->where('status', 1)->orderby('display_order')->get();
|
||||
return $siteVars[0];
|
||||
}
|
||||
public static function getCountries()
|
||||
{
|
||||
$Countries = DB::table("countries")->where('status', 1)->orderby('display_order')->get();
|
||||
return $Countries;
|
||||
}
|
||||
|
||||
public static function getCountry($alias)
|
||||
{
|
||||
$Countries = DB::table("countries")->where('alias', $alias)->get();
|
||||
return $Countries[0];
|
||||
}
|
||||
public static function getDemandCountries()
|
||||
{
|
||||
$demandCountries1 = DB::table('jobdemands')->where('status', 1)->orderby('display_order')->pluck('countries_id');
|
||||
$demandCountries2 = DB::table('paperdemands')->where('status', 1)->orderby('display_order')->pluck('countries_id');
|
||||
$demandCountries = $demandCountries1->concat($demandCountries2);
|
||||
// pre($demandCountries2,true);
|
||||
$demandCountries = DB::table("countries")->where('status', 1)->orderby('display_order')->whereIn('country_id', $demandCountries)->get();
|
||||
return $demandCountries;
|
||||
}
|
||||
public static function getCertificates()
|
||||
{
|
||||
$Certificates = DB::table("certificates")->where('status', 1)->orderby('display_order')->get();
|
||||
return $Certificates;
|
||||
}
|
||||
public static function getCertificate($alias)
|
||||
{
|
||||
$Certificate = DB::table("certificates")->where('alias', $alias)->get()[0];
|
||||
return $Certificate;
|
||||
}
|
||||
public static function getTeams()
|
||||
{
|
||||
$Teams = DB::table("teams")->where('status', 1)->orderby('display_order')->get();
|
||||
return $Teams;
|
||||
}
|
||||
public static function getTeam($alias)
|
||||
{
|
||||
$Team = DB::table("teams")->where('alias', $alias)->get()[0];
|
||||
return $Team;
|
||||
}
|
||||
public static function getPaperDemands($limit = 0)
|
||||
{
|
||||
$query = DB::table("paperdemands")->where('status', 1)->orderBy('display_order');
|
||||
|
||||
if ($limit > 1) {
|
||||
$query->take($limit);
|
||||
}
|
||||
|
||||
$PaperDemands = $query->get();
|
||||
|
||||
return $PaperDemands;
|
||||
}
|
||||
|
||||
public static function getPaperDemand($alias)
|
||||
{
|
||||
$PaperDemand = DB::table("paperdemands")->where('alias', $alias)->get()[0];
|
||||
return $PaperDemand;
|
||||
}
|
||||
public static function getJobCategories()
|
||||
{
|
||||
$JobCategories = DB::table("job_categories")->where('status', 1)->orderby('display_order')->get();
|
||||
return $JobCategories;
|
||||
}
|
||||
public static function getJobCategory($alias)
|
||||
{
|
||||
$JobCategory = DB::table("job_categories")->where('alias', $alias)->get()[0];
|
||||
return $JobCategory;
|
||||
}
|
||||
public static function getCompanies()
|
||||
{
|
||||
$Companies = DB::table("companies")->where('status', 1)->orderby('display_order')->get();
|
||||
return $Companies;
|
||||
}
|
||||
public static function getCompany($alias)
|
||||
{
|
||||
$Company = DB::table("companies")->where('alias', $alias)->get()[0];
|
||||
return $Company;
|
||||
}
|
||||
public static function showForm($formID)
|
||||
{
|
||||
if (is_numeric($formID)) {
|
||||
$Form = DB::table("forms")->where('form_id', $formID)->first();
|
||||
} else {
|
||||
$Form = DB::table("forms")->where('alias', $formID)->first();
|
||||
}
|
||||
|
||||
if (!$Form) {
|
||||
// Handle the case where the form with the given ID/alias doesn't exist
|
||||
return "Error: Form (ID/Alias: $formID) not found.";
|
||||
}
|
||||
|
||||
$csrfToken = csrf_token();
|
||||
|
||||
if (session('success')) {
|
||||
echo '<div class="alert alert-success" role="alert">';
|
||||
echo session('success');
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<form class="mt-5" action="' . route("form.submit") . '" method="POST">';
|
||||
echo '<input type="hidden" name="_token" value="' . $csrfToken . '">';
|
||||
echo '<input type="hidden" name="form_id" value="' . $Form->form_id . '">';
|
||||
$form_fields = json_decode($Form->form_fields);
|
||||
|
||||
foreach ($form_fields as $field) {
|
||||
$fieldAlias = strtolower($field->fieldAlias);
|
||||
$fieldName = strtolower($field->fieldName);
|
||||
$fieldType = $field->fieldType;
|
||||
$fieldDefault = $field->fieldDefault;
|
||||
$fieldCss = $field->fieldCss;
|
||||
|
||||
echo '<div class="mb-3 ' . $fieldCss . '">';
|
||||
echo '<label for="' . $fieldAlias . '" class="form-label">' . ucfirst($fieldName) . '</label>';
|
||||
|
||||
// Check if the "required" class is present in $fieldCss and add the required attribute
|
||||
$isRequired = strpos($fieldCss, 'required') !== false;
|
||||
|
||||
if ($fieldType === 'textarea') {
|
||||
echo '<textarea class="form-control ' . ($isRequired ? 'required' : '') . '" id="' . $fieldAlias . '" name="' . $fieldAlias . '" ' . ($isRequired ? 'required' : '') . '>' . $fieldDefault . '</textarea>';
|
||||
} else {
|
||||
echo '<input type="' . $fieldType . '" class="form-control ' . ($isRequired ? 'required' : '') . '" id="' . $fieldAlias . '" name="' . $fieldAlias . '" value="' . $fieldDefault . '" ' . ($isRequired ? 'required' : '') . '>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<button type="submit" class="btn btn-primary">Submit</button>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
function initDB()
|
||||
{
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS tbl_franchises (
|
||||
franchise_id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
title text NULL,
|
||||
alias text NULL,
|
||||
text TEXT NULL,
|
||||
thumb VARCHAR(255),
|
||||
banners VARCHAR(255),
|
||||
display_order INT(11) NULL,
|
||||
status INT(11) DEFAULT 1,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
createdby INT(11) DEFAULT 1,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updatedby INT(11) DEFAULT 1
|
||||
);");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS tbl_partners (
|
||||
partner_id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
title text NULL,
|
||||
alias text NULL,
|
||||
text TEXT NULL,
|
||||
thumb VARCHAR(255),
|
||||
display_order INT(11) NULL,
|
||||
status INT(11) DEFAULT 1,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
createdby INT(11) DEFAULT 1,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updatedby INT(11) DEFAULT 1
|
||||
);");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS tbl_services (
|
||||
service_id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(255) NULL,
|
||||
alias VARCHAR(255) NULL,
|
||||
sub_text TEXT NULL,
|
||||
text TEXT NULL,
|
||||
icon VARCHAR(255) NULL,
|
||||
thumb VARCHAR(255),
|
||||
display_order INT(11) NULL,
|
||||
status INT(11) DEFAULT 1,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
createdby INT(11) DEFAULT 1,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updatedby INT(11) DEFAULT 1
|
||||
);");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS tbl_testimonials (
|
||||
testimonial_id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(255) NULL,
|
||||
alias VARCHAR(255) NULL,
|
||||
text TEXT NULL,
|
||||
designation VARCHAR(255) NULL,
|
||||
thumb VARCHAR(255),
|
||||
display_order INT(11) NULL,
|
||||
status INT(11) DEFAULT 1,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
createdby INT(11) DEFAULT 1,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updatedby INT(11) DEFAULT 1
|
||||
);");
|
||||
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS tbl_customfields (
|
||||
customfield_id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
customfield_for VARCHAR(250) NULL,
|
||||
customfield_forref VARCHAR(250) NULL,
|
||||
title VARCHAR(255) NULL,
|
||||
alias VARCHAR(255) NULL,
|
||||
text TEXT NULL,
|
||||
fa_icon VARCHAR(255),
|
||||
logo VARCHAR(255),
|
||||
display_order INT(11) NULL,
|
||||
status INT(11) DEFAULT 1,
|
||||
remarks TEXT NULL,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
createdby INT(11) DEFAULT 1,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updatedby INT(11) DEFAULT 1
|
||||
);");
|
||||
|
||||
if (!Schema::hasColumn('users', 'status')) {
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// Add the new column to the table
|
||||
$table->string('status')->nullable();
|
||||
});
|
||||
}
|
||||
if (!Schema::hasColumn('users', 'display_order')) {
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// Add the new column to the table
|
||||
$table->string('display_order')->nullable();
|
||||
});
|
||||
}
|
||||
if (!Schema::hasColumn('users', 'createdBy')) {
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// Add the new column to the table
|
||||
$table->integer('createdBy')->nullable();
|
||||
});
|
||||
}
|
||||
if (!Schema::hasColumn('users', 'updatedBy')) {
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// Add the new column to the table
|
||||
$table->integer('updatedBy')->nullable();
|
||||
});
|
||||
}
|
||||
if (!Schema::hasColumn('companyarticles', 'location')) {
|
||||
Schema::table('companyarticles', function (Blueprint $table) {
|
||||
// Add the new column to the table
|
||||
$table->string('location')->nullable()->after('parent_article');
|
||||
});
|
||||
}
|
||||
Schema::table('companyarticles', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('companyarticles', 'FBenfitTitle')) {
|
||||
$table->string('FBenfitTitle')->nullable()->after('text');
|
||||
}
|
||||
if (!Schema::hasColumn('companyarticles', 'SBenfitTitle')) {
|
||||
$table->string('SBenfitTitle')->nullable()->after('text');
|
||||
}
|
||||
if (!Schema::hasColumn('companyarticles', 'TBenfitTitle')) {
|
||||
$table->string('TBenfitTitle')->nullable()->after('text');
|
||||
}
|
||||
if (!Schema::hasColumn('companyarticles', 'FBenfitText')) {
|
||||
$table->text('FBenfitText')->nullable()->after('text');
|
||||
}
|
||||
if (!Schema::hasColumn('companyarticles', 'SBenfitText')) {
|
||||
$table->text('SBenfitText')->nullable()->after('text');
|
||||
}
|
||||
if (!Schema::hasColumn('companyarticles', 'TBenfitText')) {
|
||||
$table->text('TBenfitText')->nullable()->after('text');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('franchises', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('franchises', 'for')) {
|
||||
$table->text('for')->nullable()->after('franchise_id');
|
||||
}
|
||||
});
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('settings', 'address')) {
|
||||
$table->string('address')->nullable()->after('email');
|
||||
}
|
||||
});
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('services', 'parent_service')) {
|
||||
$table->integer('parent_service')->nullable()->after('service_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
599
app/Helpers/bibHelper.php
Normal file
599
app/Helpers/bibHelper.php
Normal file
@ -0,0 +1,599 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\BibClass;
|
||||
use App\Http\Controllers\NepaliDictonary\DictonaryController;
|
||||
use App\Models\Log\ActivityLog;
|
||||
use App\Models\Log\ErrorLog;
|
||||
use App\Models\Log\OperationLog;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
function pre($object, $die = false)
|
||||
{
|
||||
echo "<pre>";
|
||||
print_r($object);
|
||||
echo "</pre>";
|
||||
if ($die) die;
|
||||
}
|
||||
function label($text, $echo = true)
|
||||
{
|
||||
|
||||
|
||||
if ($echo) {
|
||||
echo $text;
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
function template($filepath)
|
||||
{
|
||||
$filepath = env("APP_URL") .'/' .env("CLIENT_PATH") . '/' . $filepath;
|
||||
// $filepath=str_replace('\\','/',env("APP_URL")."/layout/".$filepath);
|
||||
echo $filepath;
|
||||
// return
|
||||
}
|
||||
if (!function_exists('N2')) {
|
||||
function N2($N)
|
||||
{
|
||||
return number_format($N, 2, '.', ',');
|
||||
}
|
||||
}
|
||||
if (!function_exists('slugify')) {
|
||||
function slugify($text)
|
||||
{
|
||||
|
||||
$text = preg_replace('/[^a-zA-Z0-9\-]/', '-', $text);
|
||||
|
||||
$text = preg_replace('/-+/', '-', $text);
|
||||
|
||||
$text = trim($text, '-');
|
||||
|
||||
$text = strtolower($text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
function createButton($class = "", $type = "submit", $display = "Submit", $url = "")
|
||||
{
|
||||
if (!$url) :
|
||||
?>
|
||||
<button class="btn <?php echo $class; ?>" type="<?php echo ($display == "Submit") ? $display : $type; ?>">
|
||||
<?php echo label($display) ?>
|
||||
</button>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<a class="btn <?php echo $class; ?>" href="<?php echo $url; ?>">
|
||||
<?php echo label($display) ?>
|
||||
</a>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
function createText($name, $id, $display, $class = "", $value = "", $placeHolder = "", $readonly = "", $required = "")
|
||||
{
|
||||
?>
|
||||
<?php if ($display != "") : ?><label for="<?php echo $id; ?>" class="form-label col-form-label"> <?php echo label($display); ?> </label><?php endif; ?>
|
||||
<div class="form-control-wrap">
|
||||
<input type="text" id="<?php echo $id; ?>" <?php echo $readonly; ?> placeholder="<?php echo $placeHolder; ?>" name="<?php echo $name; ?>" class="form-control <?php echo $class; ?>" value="<?php echo $value; ?>" <?php if ($required != "") : ?>required<?php endif; ?>>
|
||||
</div>
|
||||
<p id='error_<?php echo $name; ?>' class='text-danger custom-error'></p>
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* $tableName = Name of table
|
||||
* $pk = primary key of table
|
||||
* $name = table select column name
|
||||
* $class = extra class
|
||||
* $data = Existing data or for edit case showing selected data
|
||||
* $display = Displaying name or showing label name.
|
||||
*/
|
||||
function getSelectForForeignColumn($tableName, $pk, $name, $class = "form-control", $data = null, $display = null, $customColumnName = null)
|
||||
{
|
||||
$tableName = strtolower(trim($tableName));
|
||||
$pk = trim($pk);
|
||||
$name = trim($name);
|
||||
$class = trim($class);
|
||||
$systems = DB::table($tableName)->where('status', '<>', -1)->orderBy($pk, 'asc')->pluck($name, $pk);
|
||||
$customColumnName = !empty($customColumnName) ? $customColumnName : $pk; //if we pass column name other then primary key.
|
||||
customCreateSelect($pk, $pk, $class, $display ?? $name, $systems, ($data) ? $data->$customColumnName : null);
|
||||
}
|
||||
function customCreateSelect($name, $id, $class = "form-control", $display = '', $values = array(), $defaultValue = '')
|
||||
{
|
||||
$disabled = (in_array("DISABLED", explode(" ", strtoupper($class)))) ? "Disabled" : false;
|
||||
$required = (in_array("REQUIRED", explode(" ", strtoupper($class)))) ? "Required" : false;
|
||||
?><label for="<?php echo $id; ?>" class="form-label col-form-label"> <?php echo label($display); ?> </label>
|
||||
<?php if ($disabled) : ?>
|
||||
<input type="hidden" name="<?php echo $name; ?>" value="<?php echo $defaultValue; ?>" /><?php endif; ?>
|
||||
<select class="form-select <?php echo $class ?>" name="<?php echo $name; ?>" data-search="true" id="<?php echo $name; ?>" aria-label="Default select example" <?php echo ($disabled) ? "Disabled" : ""; ?> <?php echo ($required) ? "Required" : ""; ?>>
|
||||
<option value=""><?php label("Select Option"); ?></option>
|
||||
<?php foreach ($values as $key => $value) { ?>
|
||||
<option value="<?= $key ?>" <?php echo $defaultValue == $key ? 'selected' : '' ?>><?= $value ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<p id='error_<?php echo $name; ?>' class='text-danger custom-error'></p>
|
||||
<?php
|
||||
}
|
||||
function createCustomSelectFromArray($Array, $displayTextForLabel, $HTMLElementName, $defaultValueSelected = '', $additionalClass = "form-control")
|
||||
{
|
||||
$disabled = (in_array("DISABLED", explode(" ", strtoupper($additionalClass)))) ? "Disabled" : false;
|
||||
$required = (in_array("REQUIRED", explode(" ", strtoupper($additionalClass)))) ? "Required" : false;
|
||||
?>
|
||||
<label for="<?php echo $HTMLElementName; ?>" class="form-label col-form-label"> <?php echo label($displayTextForLabel); ?> </label>
|
||||
<?php if ($disabled) : ?>
|
||||
<input type="hidden" name="<?php echo $HTMLElementName; ?>" value="<?php echo $defaultValueSelected; ?>" />
|
||||
<?php endif; ?>
|
||||
<select class="form-select <?php echo $additionalClass ?>" name="<?php echo $HTMLElementName; ?>" data-search="true" id="<?php echo $HTMLElementName; ?>" aria-label="Default select example" <?php echo ($disabled) ? "Disabled" : ""; ?> <?php echo ($required) ? "Required" : ""; ?>>
|
||||
<option <?php if ($required) : ?>value="-1" <?php endif; ?>><?php label("Select Option"); ?></option>
|
||||
<?php foreach ($Array as $option) : ?>
|
||||
<option value="<?php echo $option['value']; ?>" <?php echo $defaultValueSelected == $option['value'] ? 'selected' : ''; ?>>
|
||||
<?php echo $option['display']; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<p id='error_<?php echo $HTMLElementName; ?>' class='text-danger custom-error'></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
function createCustomSelect($tableName, $fieldNameToDisplay, $fieldNameForValue, $defaultValueSelected, $displayTextForLabel, $HTMLElementName, $additionalClass = "form-control", $defaultCondition = null)
|
||||
{
|
||||
// Supply conditions as $defaultCondition = "column_name = 'value'";
|
||||
$tableName = strtolower(trim($tableName));
|
||||
$fieldNameToDisplay = trim($fieldNameToDisplay);
|
||||
$fieldNameForValue = trim($fieldNameForValue);
|
||||
$additionalClass = trim($additionalClass);
|
||||
|
||||
$query = DB::table(DB::raw("`$tableName`"))->where('status', '<>', -1);
|
||||
|
||||
if ($defaultCondition) {
|
||||
$query->whereRaw($defaultCondition);
|
||||
}
|
||||
|
||||
$systems = $query->orderBy($fieldNameForValue, 'asc')->pluck($fieldNameToDisplay, $fieldNameForValue);
|
||||
|
||||
?><label class="form-label col-form-label"><?php echo label($displayTextForLabel); ?></label>
|
||||
<select class="form-select <?php echo $additionalClass; ?>" name="<?php echo $HTMLElementName; ?>" data-search="true" aria-label="" <?php if (stripos($additionalClass, 'required') !== false) {
|
||||
echo "REQUIRED";
|
||||
} ?>>
|
||||
<?php if (stripos($additionalClass, 'required') !== false) { ?>
|
||||
<option value=""><?php label("Select Option"); ?></option>
|
||||
<?php } else { ?>
|
||||
<option value="0"><?php label("Select Option"); ?></option>
|
||||
<?php } ?>
|
||||
<?php foreach ($systems as $key => $value) { ?>
|
||||
<option value="<?= $key ?>" <?php echo $defaultValueSelected == $key ? 'selected' : '' ?>><?= $value ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<p id='error_<?php echo $fieldNameForValue; ?>' class='text-danger custom-error'></p>
|
||||
<?php
|
||||
}
|
||||
function createImageInput($name, $display = "", $class = "", $default = "")
|
||||
{
|
||||
?>
|
||||
<div class="input-group">
|
||||
<span class="input-group-btn">
|
||||
<a id="<?php echo $name; ?>" data-input="<?php echo $name; ?>_url" data-preview="<?php echo $name; ?>holder" class="btn btn-primary">
|
||||
<i class="fa fa-picture-o"></i> <?php echo ($display != "") ? $display : "Choose Photo"; ?>
|
||||
</a>
|
||||
</span>
|
||||
<input id="<?php echo $name; ?>_url" class="form-control lfm <?php echo $class; ?>" type="text" name="<?php echo $name; ?>" <?php if ($default != "") : ?> value="<?php echo env("APP_URL") . "/" . $default; ?>" <?php endif; ?>>
|
||||
</div>
|
||||
<div id="<?php echo $name; ?>holder" style="margin-top:15px;max-height:80px;overflow:hidden;">
|
||||
<?php if ($default != "") : ?> <img src="<?php echo env("APP_URL") . "/" . $default; ?>" style="height: 5rem" /> <?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
collectScripts(function () use ($name) {
|
||||
?>
|
||||
<script>
|
||||
lfm('<?php echo $name; ?>', 'image', {
|
||||
prefix: '<?php echo env("APP_URL"); ?>/files'
|
||||
});
|
||||
</script>
|
||||
<?php });
|
||||
}
|
||||
|
||||
function site_url($url = "")
|
||||
{
|
||||
return env("APP_URL") . "/" . $url;
|
||||
}
|
||||
function base_url($url = "")
|
||||
{
|
||||
return env("APP_URL") . "/" . trim($url, "/");
|
||||
}
|
||||
function showImageThumb($url)
|
||||
{ ?>
|
||||
<div style="margin-top:15px;max-height:40px;overflow:hidden">
|
||||
<?php if ($url != "") : ?> <img src="<?php echo env("APP_URL") . "/" . $url; ?>" style="height: 40px;" class="img-fluid" /> <?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function getFieldData($tableName, $returnField, $referenceFieldName, $referenceValue)
|
||||
{
|
||||
$tableName = strtolower(trim($tableName));
|
||||
$returnField = trim($returnField);
|
||||
$referenceFieldName = trim($referenceFieldName);
|
||||
|
||||
$query = DB::table(DB::raw("`$tableName`"))->where($referenceFieldName, $referenceValue);
|
||||
|
||||
$fieldData = $query->value($returnField);
|
||||
|
||||
return $fieldData;
|
||||
}
|
||||
|
||||
|
||||
function createErrorParagraph($name, $class = null)
|
||||
{
|
||||
echo "<p id='error_$name' class='text-danger custom-error $class'></p>";
|
||||
}
|
||||
function createActivityLog($controllerName, $methodName, $activity)
|
||||
{
|
||||
$user_id = auth()->user()->id;
|
||||
ActivityLog::create([
|
||||
'user_id' => $user_id,
|
||||
'controllerName' => $controllerName,
|
||||
'methodName' => $methodName,
|
||||
'actionUrl' => request()->fullUrl(),
|
||||
'activity' => $activity,
|
||||
]);
|
||||
}
|
||||
function getOperationNumber()
|
||||
{
|
||||
$startNumber = date('YmdHis') . rand(1000, 9999);
|
||||
$isExists = OperationLog::where('operation_end_no', $startNumber)->first();
|
||||
while ($isExists) {
|
||||
$startNumber = date('YmdHis') . rand(1000, 9999);
|
||||
$isExists = OperationLog::where('operation_end_no', $startNumber)->first();
|
||||
}
|
||||
return $startNumber;
|
||||
}
|
||||
|
||||
function createOperationLog($startOperationNumber, $endOperationNumber, $modelName, $modelId, $operationName, $previousValues, $newValues)
|
||||
{
|
||||
$operationId = getOperationNumber();
|
||||
$user_id = auth()->user()->id;
|
||||
OperationLog::create([
|
||||
'user_id' => $user_id,
|
||||
'operation_start_no' => $startOperationNumber,
|
||||
'operation_end_no' => $endOperationNumber,
|
||||
'model_name' => $modelName,
|
||||
'model_id' => $modelId,
|
||||
'operation_name' => $operationName,
|
||||
'previous_values' => $previousValues ? json_encode($previousValues) : null,
|
||||
'new_values' => $newValues ? json_encode($newValues) : null,
|
||||
]);
|
||||
}
|
||||
function createErrorLog($controllerName, $methodName, $errors)
|
||||
{
|
||||
$user_id = auth()->user()->id;
|
||||
ErrorLog::create([
|
||||
'user_id' => $user_id,
|
||||
'controller_name' => $controllerName,
|
||||
'method_name' => $methodName,
|
||||
'errors' => $errors,
|
||||
]);
|
||||
}
|
||||
function createDate($name, $display = "", $class = "datepicker", $default = "")
|
||||
{
|
||||
?>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="<?php echo $name; ?>" class="form-label col-form-label"><?php echo label($display); ?></label>
|
||||
<div class="form-control-wrap">
|
||||
<input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" class="form-control <?php echo $class; ?>" value="<?php echo $default; ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
function createTextArea($name, $class = "", $display = "", $default = "", $row = "")
|
||||
{
|
||||
$hasCkeditorClassic = strpos($class, 'ckeditor-classic') !== false;
|
||||
$uploadUrlAttribute = $hasCkeditorClassic ? ' data-upload-url="' . route('upload') . '"' : '';
|
||||
?>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="<?php echo $name; ?>" class="form-label col-form-label"><?php echo label($display); ?></label>
|
||||
<div class="form-control-wrap">
|
||||
<textarea class="form-control text-area <?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" rows="<?php echo $row; ?>" <?php echo $uploadUrlAttribute; ?>><?php if (isset($default)) {
|
||||
echo ($default);
|
||||
} ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
function createPlainTextArea($name, $class = "", $display = "", $default = "", $row = "")
|
||||
{
|
||||
?>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="<?php echo $name; ?>" class="form-label col-form-label"><?php echo label($display); ?></label>
|
||||
<div class="form-control-wrap">
|
||||
<textarea class="form-control text-area <?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" rows="<?php echo $row; ?>"><?php if (isset($default)) {
|
||||
echo ($default);
|
||||
} ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
function getDisplayOrder($tableName)
|
||||
{
|
||||
// echo $tableName;die;
|
||||
$maxDisplayOrder = DB::select("select max(display_order) as display_order from $tableName")[0]->display_order;
|
||||
$nextDisplayOrder = $maxDisplayOrder + 1;
|
||||
return $nextDisplayOrder;
|
||||
}
|
||||
if (!function_exists('myDate')) {
|
||||
function myDate($originalDate)
|
||||
{
|
||||
return date("F d Y", strtotime($originalDate));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('dbDate')) {
|
||||
function dbDate($date)
|
||||
{
|
||||
return date("Y-m-d", strtotime($date));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('myTime')) {
|
||||
function myTime($originalDate)
|
||||
{
|
||||
return date("g:i A", strtotime($originalDate));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('myDateTime')) {
|
||||
function myDateTime($originalDate)
|
||||
{
|
||||
return date("F d Y g:i A", strtotime($originalDate));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('myDaysDiff')) {
|
||||
function myDaysDiff($fromDate, $toDate)
|
||||
{
|
||||
$fromDate = strtotime($fromDate);
|
||||
$toDate = strtotime($toDate);
|
||||
$datediff = $toDate - $fromDate;
|
||||
return round($datediff / (60 * 60 * 24));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('firstDayOfNepaliMonth')) {
|
||||
function firstDayOfNepaliMonth($engDate = "")
|
||||
{
|
||||
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
|
||||
$NepaliDate = NepaliDate($engDate);
|
||||
$nD = explode("-", $NepaliDate);
|
||||
$Day = '1';
|
||||
$Month = $nD[1];
|
||||
$Year = $nD[0];
|
||||
$t = "select bs_date from tbl_nepengcalendar where bs_date='" . $Year . "-" . $Month . "-" . $Day . "'";
|
||||
return DB::select($t)[0]->bs_date;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('firstDayOfNepaliMonth1')) {
|
||||
function firstDayOfNepaliMonth1($engDate = "")
|
||||
{
|
||||
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
|
||||
$NepaliDate = NepaliDate($engDate);
|
||||
$nD = explode("-", $NepaliDate);
|
||||
$Day = '1';
|
||||
$Month = ($nD[1] < 10) ? '0' . $nD[1] : $nD[1];
|
||||
$Year = $nD[0];
|
||||
$t = "select ad_date from tbl_nepengcalendar where bs_date='" . $Year . "-" . $Month . "-" . $Day . "'";
|
||||
return DB::select($t)[0]->ad_date;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('lastDayOfNepaliMonth')) {
|
||||
function lastDayOfNepaliMonth($engDate = "")
|
||||
{
|
||||
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
|
||||
$NepaliDate = NepaliDate1($engDate);
|
||||
$nD = explode("-", $NepaliDate);
|
||||
$Day = '1';
|
||||
$Month = $nD[1];
|
||||
$Year = $nD[0];
|
||||
$t = "select ad_date from tbl_nepengcalendar where bs_date like '" . $Year . "-" . $Month . "-%' order by ad_date";
|
||||
$dates = DB::select($t);
|
||||
$date = end($dates);
|
||||
return $date->ad_date;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('EnglishDate')) {
|
||||
function EnglishDate($NepaliYear, $NepaliMonth, $NepaliDay)
|
||||
{
|
||||
if ($NepaliMonth < 10) {
|
||||
$NepaliMonth = "0" . $NepaliMonth;
|
||||
}
|
||||
$bs_date = $NepaliYear . "-" . $NepaliMonth . "-" . $NepaliDay;
|
||||
$t = "select ad_date from tbl_nepengcalendar where bs_date='$bs_date'";
|
||||
$q = DB::select($t);
|
||||
return $q[0]->ad_date;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('Today')) {
|
||||
function Today()
|
||||
{
|
||||
return date("Y-m-d");
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('NepaliToEnglishDate')) {
|
||||
function NepaliToEnglishDate($NepaliDate)
|
||||
{
|
||||
$NepaliDate = trim($NepaliDate);
|
||||
if (trim($NepaliDate) == "") {
|
||||
return date("Y-m-d");
|
||||
}
|
||||
$NepaliDate = explode("-", $NepaliDate);
|
||||
$NepaliMonth = intval($NepaliDate[1]);
|
||||
$NepaliYear = intval($NepaliDate[0]);
|
||||
$NepaliDay = intval($NepaliDate[2]);
|
||||
if ($NepaliMonth < 10) {
|
||||
$NepaliMonth = "0" . $NepaliMonth;
|
||||
}
|
||||
$bs_date = $NepaliYear . "-" . $NepaliMonth . "-" . $NepaliDay;
|
||||
$t = "select ad_date from tbl_nepengcalendar where bs_date='$bs_date'";
|
||||
$q = DB::select($t);
|
||||
return $q[0]->ad_date;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('NepaliDate')) {
|
||||
function NepaliDate($engDate = "")
|
||||
{
|
||||
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
|
||||
if ($engDate != "0000-00-00") {
|
||||
// return str_replace("-0", "-", DB::table('tbl_nepengcalendar')->where('ad_date', $engDate)->first()->bs_date);
|
||||
$result = DB::table('tbl_nepengcalendar')->where('ad_date', $engDate)->first();
|
||||
|
||||
if ($result) {
|
||||
$bsDate = $result->bs_date;
|
||||
$convertedDate = convertNumbersToUnicode(str_replace("-", "-", $bsDate));
|
||||
return $convertedDate;
|
||||
} else {
|
||||
// Handle the case when the query result is null
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
function convertNumbersToUnicode($number = "2080-10-13")
|
||||
{
|
||||
$unicodeDigits = [
|
||||
'0' => '०',
|
||||
'1' => '१',
|
||||
'2' => '२',
|
||||
'3' => '३',
|
||||
'4' => '४',
|
||||
'5' => '५',
|
||||
'6' => '६',
|
||||
'7' => '७',
|
||||
'8' => '८',
|
||||
'9' => '९',
|
||||
];
|
||||
|
||||
$converted = '';
|
||||
$digits = str_split((string)$number);
|
||||
|
||||
foreach ($digits as $digit) {
|
||||
if (isset($unicodeDigits[$digit])) {
|
||||
$converted .= $unicodeDigits[$digit];
|
||||
} elseif ($digit === '-') {
|
||||
$converted .= '-';
|
||||
} else {
|
||||
$converted .= $digit;
|
||||
}
|
||||
}
|
||||
//dd($converted);
|
||||
return $converted;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!function_exists('NepaliMonth')) {
|
||||
function NepaliMonth($engDate = "")
|
||||
{
|
||||
$NepaliDate = NepaliDate($engDate);
|
||||
$nD = explode("-", $NepaliDate);
|
||||
$Month = $nD[1];
|
||||
return intval($Month);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('NepaliYear')) {
|
||||
function NepaliYear($engDate = "")
|
||||
{
|
||||
$NepaliDate = NepaliDate($engDate);
|
||||
$nD = explode("-", $NepaliDate);
|
||||
$Year = $nD[0];
|
||||
return intval($Year);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('NepaliMonthNameByNumber')) {
|
||||
function NepaliMonthNameByNumber($number)
|
||||
{
|
||||
$MonthNames = array(
|
||||
"Baisakh", "Jestha", "Ashad", "Shrawan", "Bhadra", "Asoj",
|
||||
"Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra"
|
||||
);
|
||||
return $MonthNames[$number - 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('NepaliMonthName')) {
|
||||
function NepaliMonthName($engDate = "")
|
||||
{
|
||||
$Month = NepaliMonth($engDate);
|
||||
$MonthNames = array(
|
||||
"Baisakh", "Jestha", "Ashad", "Shrawan", "Bhadra", "Asoj",
|
||||
"Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra"
|
||||
);
|
||||
return $MonthNames[$Month - 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('N2')) {
|
||||
function N2($N)
|
||||
{
|
||||
return number_format($N, 2, '.', ',');
|
||||
}
|
||||
}
|
||||
function collectScripts(callable $callback)
|
||||
{
|
||||
ob_start();
|
||||
$callback();
|
||||
$script = ob_get_clean();
|
||||
|
||||
if (!empty($script)) {
|
||||
pushScriptToFooter($script);
|
||||
}
|
||||
}
|
||||
|
||||
function pushScriptToFooter($script)
|
||||
{
|
||||
if (!isset($GLOBALS['scripts'])) {
|
||||
$GLOBALS['scripts'] = [];
|
||||
}
|
||||
|
||||
$GLOBALS['scripts'][] = $script;
|
||||
}
|
||||
function processForShortcode($content)
|
||||
{
|
||||
return preg_replace_callback('/\[([\w_]+)([^]]*)\]/', function ($matches) {
|
||||
$shortcodeName = $matches[1];
|
||||
$shortcodeAttributes = [];
|
||||
$mandatoryAttributes = ['alias', 'css', 'title'];
|
||||
|
||||
preg_match_all('/\s*(\w+)\s*=\s*(?:"([^"]*)"|\'([^\']*)\'|([^"\'][^\s]*))/', $matches[2], $attrMatches, PREG_SET_ORDER);
|
||||
|
||||
foreach ($attrMatches as $attrMatch) {
|
||||
$attrName = $attrMatch[1];
|
||||
$attrValue = $attrMatch[2] ?: ($attrMatch[3] ?: $attrMatch[4]); // Use non-empty capture group as the attribute value
|
||||
$attrValue = trim($attrValue, "\"'"); // Remove both single and double quotes from the attribute value
|
||||
$shortcodeAttributes[$attrName] = $attrValue;
|
||||
}
|
||||
|
||||
// Fill in missing mandatory attributes with empty strings
|
||||
foreach ($mandatoryAttributes as $attribute) {
|
||||
if (!isset($shortcodeAttributes[$attribute])) {
|
||||
$shortcodeAttributes[$attribute] = '';
|
||||
}
|
||||
}
|
||||
return view("shortcodes." . $shortcodeName, $shortcodeAttributes);
|
||||
}, $content);
|
||||
}
|
Reference in New Issue
Block a user