first commit
This commit is contained in:
34
app/Console/Commands/GeneratePermissions.php
Normal file
34
app/Console/Commands/GeneratePermissions.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Modules\User\Repositories\PermissionRepository;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class GeneratePermissions extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'permissions:generate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate Permissions From Named Route';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info('Generating Permissions');
|
||||
PermissionRepository::generatePermissionFromRoutes();
|
||||
$this->info('Permissions generated successfully!');
|
||||
}
|
||||
}
|
27
app/Console/Kernel.php
Normal file
27
app/Console/Kernel.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*/
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*/
|
||||
protected function commands(): void
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
48
app/Exceptions/Handler.php
Normal file
48
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of exception types with their corresponding custom log levels.
|
||||
*
|
||||
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
BIN
app/Helpers/.DS_Store
vendored
Normal file
BIN
app/Helpers/.DS_Store
vendored
Normal file
Binary file not shown.
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, "", "", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
749
app/Helpers/OMIS.php
Normal file
749
app/Helpers/OMIS.php
Normal file
@@ -0,0 +1,749 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class OMIS
|
||||
{
|
||||
// public function __construct()
|
||||
// {
|
||||
// $this->initDB();
|
||||
// $this->seedPermissions();
|
||||
// }
|
||||
|
||||
public static function sendSMSWithCurl($destination, $message)
|
||||
{
|
||||
$userName = (SITEVARS->sms_username) ? SITEVARS->sms_username : '';
|
||||
$password = (SITEVARS->sms_password) ? SITEVARS->sms_password : '';
|
||||
$sender = (SITEVARS->sms_sender) ? SITEVARS->sms_sender : '';
|
||||
$url = (SITEVARS->sms_api) ? SITEVARS->sms_api : 'http://api.ininepal.com/api/index?';
|
||||
$encodedMessage = urlencode($message);
|
||||
$encodedDestination = urlencode($destination);
|
||||
$url_query = "username={$userName}&password={$password}&msg={$encodedMessage}&contacts={$encodedDestination}&responsetype=json";
|
||||
$url_final = $url . $url_query;
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url_final);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
ob_clean();
|
||||
if ($response === false) {
|
||||
// Handle the error if needed (e.g., log the error)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Close the cURL session
|
||||
curl_close($ch);
|
||||
return true;
|
||||
}
|
||||
|
||||
//CONSULTANCY RELATED TEMP FUNCTIONS
|
||||
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 getSiteVars()
|
||||
{
|
||||
$siteVars = DB::table("settings")->where('status', 1)->orderby('display_order')->first();
|
||||
|
||||
return $siteVars;
|
||||
}
|
||||
|
||||
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>';
|
||||
}
|
||||
|
||||
public static function seedPermissions()
|
||||
{
|
||||
$modelNames = self::getModelNames();
|
||||
|
||||
foreach ($modelNames as $modelName) {
|
||||
self::createPermission($modelName, 'create');
|
||||
self::createPermission($modelName, 'edit');
|
||||
self::createPermission($modelName, 'index');
|
||||
self::createPermission($modelName, 'delete');
|
||||
self::createPermission($modelName, 'store');
|
||||
self::createPermission($modelName, 'update');
|
||||
}
|
||||
}
|
||||
|
||||
public static function getModelNames()
|
||||
{
|
||||
// Adjust the directory path based on your model location
|
||||
$modelsDirectory = app_path('Models');
|
||||
$files = scandir($modelsDirectory);
|
||||
$models = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (pathinfo($file, PATHINFO_EXTENSION) == 'php') {
|
||||
$modelName = pathinfo($file, PATHINFO_FILENAME);
|
||||
$models[] = $modelName;
|
||||
}
|
||||
}
|
||||
|
||||
return $models;
|
||||
}
|
||||
public static function createPermission($modelName, $command)
|
||||
{
|
||||
|
||||
$AdminUser = DB::table('users')
|
||||
->where('roles_id', 1)
|
||||
->first();
|
||||
if (!$AdminUser) {
|
||||
// dd("hello");
|
||||
DB::table('users')->insert([
|
||||
'name' => 'Prajwal Adhikari',
|
||||
'email' => 'prajwalbro@hotmail.com',
|
||||
'username' => 'prajwalbro@hotmail.com',
|
||||
'password' => Hash::make('p@ssw0rd'),
|
||||
'roles_id' => 1,
|
||||
'created_at' => now(), // or use a specific timestamp if needed
|
||||
'createdby' => 1, // replace with the actual user ID who created it
|
||||
'updated_at' => now(),
|
||||
'updatedby' => 1, // replace with the actual user ID who updated it
|
||||
'status' => 1, // adjust as needed
|
||||
]);
|
||||
}
|
||||
$permissionName = "{$command} {$modelName}";
|
||||
$existingPermission = DB::table('permissions')
|
||||
->where('title', $permissionName)
|
||||
->first();
|
||||
$adminRole = DB::table('roles')
|
||||
->where('title', 'admin')
|
||||
->first();
|
||||
if (!$existingPermission) {
|
||||
$LastInsertID = DB::table('permissions')->insert([
|
||||
'title' => ucfirst($command) . ' ' . $modelName,
|
||||
'alias' => strtolower("{$command}_{$modelName}"),
|
||||
'modal' => $modelName,
|
||||
'command' => $command,
|
||||
'created_at' => now(), // or use a specific timestamp if needed
|
||||
'createdby' => 1, // replace with the actual user ID who created it
|
||||
'updated_at' => now(),
|
||||
'updatedby' => 1, // replace with the actual user ID who updated it
|
||||
'status' => 1, // adjust as needed
|
||||
]);
|
||||
DB::table('rolepermissions')->insert([
|
||||
'roles_id' => $adminRole->role_id,
|
||||
'permissions_id' => $LastInsertID,
|
||||
'created_at' => now(),
|
||||
'createdby' => 1,
|
||||
'updated_at' => now(),
|
||||
'updatedby' => 1,
|
||||
'status' => 1,
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function initDB()
|
||||
{
|
||||
static $initialized = false;
|
||||
if (!$initialized) {
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_operation_logs` (
|
||||
`operation_id` bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`refNo` varchar(255) DEFAULT NULL,
|
||||
`user_id` int(11) DEFAULT NULL,
|
||||
`operation_start_no` bigint(20) DEFAULT NULL,
|
||||
`operation_end_no` bigint(20) DEFAULT NULL,
|
||||
`model_name` varchar(100) DEFAULT NULL,
|
||||
`model_id` int(11) DEFAULT NULL,
|
||||
`operation_name` varchar(100) DEFAULT NULL,
|
||||
`previous_values` text DEFAULT NULL,
|
||||
`new_values` longtext DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
");
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_error_logs` (
|
||||
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`user_id` bigint(20) UNSIGNED DEFAULT NULL,
|
||||
`controller_name` varchar(255) DEFAULT NULL,
|
||||
`method_name` varchar(255) DEFAULT NULL,
|
||||
`errors` longTEXT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
");
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_activity_logs` (
|
||||
`activity_id` bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`user_id` int(11) DEFAULT NULL,
|
||||
`controllerName` varchar(100) DEFAULT NULL,
|
||||
`methodName` varchar(100) DEFAULT NULL,
|
||||
`actionUrl` varchar(255) DEFAULT NULL,
|
||||
`activity` varchar(255) DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
");
|
||||
// DB::statement("CREATE TABLE IF NOT EXISTS `tbl_users` (
|
||||
// `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
// `name` varchar(255) NULL,
|
||||
// `email` varchar(255) NULL,
|
||||
// `username` varchar(255) NULL,
|
||||
// `email_verified_at` timestamp NULL DEFAULT NULL,
|
||||
// `password` varchar(255) NULL,
|
||||
// `remember_token` varchar(100) DEFAULT NULL,
|
||||
// `display_order` INT(11) DEFAULT 1,
|
||||
// `roles_id` INT(11),
|
||||
// `branches_id` INT(11),
|
||||
// `vendors_id` INT(11),
|
||||
// `employees_id` INT(11),
|
||||
// `status` INT(11) DEFAULT 1,
|
||||
// `created_at` timestamp NULL DEFAULT NULL,
|
||||
// `createdby` INT(11),
|
||||
// `updated_at` timestamp NULL DEFAULT NULL,
|
||||
// `updatedby` INT(11)
|
||||
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
// ");
|
||||
// DB::statement("CREATE TABLE IF NOT EXISTS tbl_roles (
|
||||
// role_id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
// title VARCHAR(255),
|
||||
// alias VARCHAR(255),
|
||||
// description TEXT,
|
||||
// display_order INT(11),
|
||||
// status INT(11),
|
||||
// remarks TEXT,
|
||||
// created_at DATETIME,
|
||||
// createdby INT(11),
|
||||
// updated_at DATETIME,
|
||||
// updatedby INT(11)
|
||||
// );");
|
||||
// DB::statement("CREATE TABLE IF NOT EXISTS tbl_permissions (
|
||||
// permission_id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
// title VARCHAR(255),
|
||||
// alias VARCHAR(255),
|
||||
// modal VARCHAR(255),
|
||||
// command VARCHAR(255),
|
||||
// created_at DATETIME,
|
||||
// createdby INT(11),
|
||||
// updated_at DATETIME,
|
||||
// updatedby INT(11),
|
||||
// status INT(11)
|
||||
|
||||
// );");
|
||||
// DB::statement("CREATE TABLE IF NOT EXISTS tbl_rolepermissions (
|
||||
// rolepermission_id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
// roles_id INT(11),
|
||||
// permissions_id INT(11),
|
||||
// display_order INT(11),
|
||||
// remarks VARCHAR(255),
|
||||
// created_at DATETIME,
|
||||
// createdby INT(11),
|
||||
// updated_at DATETIME,
|
||||
// updatedby INT(11),
|
||||
// status INT(11)
|
||||
// );");
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_settings` (
|
||||
`setting_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`title` varchar(255) NULL,
|
||||
`description` TEXT NULL,
|
||||
`url1` varchar(255) NULL,
|
||||
`url2` varchar(255) NULL,
|
||||
`email` varchar(255) NULL,
|
||||
`phone` varchar(255) NULL,
|
||||
`secondary_phone` varchar(255) NULL,
|
||||
`google_map` TEXT NULL,
|
||||
`fb` varchar(255) NULL,
|
||||
`insta` varchar(255) NULL,
|
||||
`twitter` varchar(255) NULL,
|
||||
`tiktok` varchar(255) NULL,
|
||||
`primary_logo` varchar(255) NULL,
|
||||
`secondary_logo` varchar(255) NULL,
|
||||
`thumb` varchar(255) NULL,
|
||||
`icon` varchar(255) NULL,
|
||||
`og_image` varchar(255) NULL,
|
||||
`no_image` varchar(250) NULL,
|
||||
`copyright_text` varchar(250) NULL,
|
||||
`content1` TEXT NULL,
|
||||
`content2` TEXT NULL,
|
||||
`content3` TEXT NULL,
|
||||
`seo_title` varchar(255) NULL,
|
||||
`seo_description` TEXT NULL,
|
||||
`seo_keywords` TEXT NULL,
|
||||
`og_tags` TEXT NULL,
|
||||
`display_order` int(11) NULL DEFAULT 0,
|
||||
`status` int(11) NULL DEFAULT 0,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updatedby` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
");
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS tbl_progressstatuses (
|
||||
status_id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(255),
|
||||
alias VARCHAR(255),
|
||||
display_order int(11),
|
||||
created_at DATETIME,
|
||||
createdby INT(11),
|
||||
updated_at DATETIME,
|
||||
updatedby INT(11),
|
||||
status INT(11)
|
||||
|
||||
);");
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_articles` (
|
||||
`article_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`parent_article` int(11) DEFAULT 0,
|
||||
`title` varchar(250) NULL,
|
||||
`alias` varchar(250) NULL,
|
||||
`text` TEXT NULL,
|
||||
`cover_photo` varchar(500) NOT NULL,
|
||||
`thumb` varchar(255) NULL,
|
||||
`display_order` int(11) NULL DEFAULT 0,
|
||||
`status` int(11) NULL DEFAULT 0,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updatedby` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
");
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_countries` (
|
||||
`country_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`title` VARCHAR(255),
|
||||
`alias` VARCHAR(255),
|
||||
`description` TEXT,
|
||||
`display_order` INT(11),
|
||||
`status` INT(11),
|
||||
`remarks` TEXT,
|
||||
`created_at` DATETIME,
|
||||
`createdby` INT(11),
|
||||
`updated_at` DATETIME,
|
||||
`updatedby` INT(11)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_provinces` (
|
||||
`province_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`countries_id` INT(11) NULL,
|
||||
`title` VARCHAR(255),
|
||||
`alias` VARCHAR(255),
|
||||
`description` TEXT,
|
||||
`display_order` INT(11),
|
||||
`status` INT(11),
|
||||
`remarks` TEXT,
|
||||
`created_at` DATETIME,
|
||||
`createdby` INT(11),
|
||||
`updated_at` DATETIME,
|
||||
`updatedby` INT(11)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_districts` (
|
||||
`district_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`provinces_id` INT(11),
|
||||
`title` VARCHAR(255),
|
||||
`alias` VARCHAR(255),
|
||||
`description` TEXT,
|
||||
`display_order` INT(11),
|
||||
`status` INT(11),
|
||||
`remarks` TEXT,
|
||||
`created_at` DATETIME DEFAULT NOW(),
|
||||
`createdby` INT(11),
|
||||
`updated_at` DATETIME DEFAULT NOW(),
|
||||
`updatedby` INT(11)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
");
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_cities` (
|
||||
`city_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`districts_id` INT(11),
|
||||
`title` VARCHAR(255),
|
||||
`alias` VARCHAR(255),
|
||||
`description` TEXT,
|
||||
`display_order` INT(11),
|
||||
`status` INT(11),
|
||||
`remarks` TEXT,
|
||||
`created_at` DATETIME DEFAULT NOW(),
|
||||
`createdby` INT(11),
|
||||
`updated_at` DATETIME DEFAULT NOW(),
|
||||
`updatedby` INT(11)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
");
|
||||
|
||||
// DB::statement("CREATE TABLE IF NOT EXISTS `tbl_companytypes` (
|
||||
// `companytype_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
// `title` VARCHAR(255),
|
||||
// `alias` VARCHAR(255),
|
||||
// `description` TEXT,
|
||||
// `display_order` INT(11),
|
||||
// `status` INT(11),
|
||||
// `remarks` TEXT,
|
||||
// `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
// `createdby` INT(11),
|
||||
// `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
// `updatedby` INT(11)
|
||||
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
// ");
|
||||
// DB::statement("CREATE TABLE IF NOT EXISTS `tbl_companies` (
|
||||
// `company_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
// `title` VARCHAR(255),
|
||||
// `alias` VARCHAR(255),
|
||||
// `description` TEXT,
|
||||
// `address` TEXT,
|
||||
// `cities_id` INT(11),
|
||||
// `companytypes_id` INT(11),
|
||||
// `display_order` INT(11),
|
||||
// `status` INT(11),
|
||||
// `remarks` TEXT,
|
||||
// `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
// `createdby` INT(11),
|
||||
// `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
// `updatedby` INT(11)
|
||||
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
// ");
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_branches` (
|
||||
`branch_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`companies_id` INT(11) NULL,
|
||||
`title` VARCHAR(255),
|
||||
`alias` VARCHAR(255),
|
||||
`description` TEXT,
|
||||
`email` VARCHAR(255),
|
||||
`telephone` VARCHAR(255),
|
||||
`phone1` VARCHAR(255),
|
||||
`phone2` VARCHAR(255),
|
||||
`address` VARCHAR(255),
|
||||
`company_reg` VARCHAR(255),
|
||||
`company_pan` VARCHAR(255),
|
||||
`logo` VARCHAR(255),
|
||||
`is_main` INT(11) NULL Default 1,
|
||||
`display_order` INT(11),
|
||||
`status` INT(11),
|
||||
`remarks` TEXT,
|
||||
`created_at` DATETIME,
|
||||
`createdby` INT(11),
|
||||
`updated_at` DATETIME,
|
||||
`updatedby` INT(11)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_vendortypes` (
|
||||
`vendortypes_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`title` VARCHAR(255),
|
||||
`alias` VARCHAR(255),
|
||||
`description` TEXT,
|
||||
`display_order` INT(11),
|
||||
`status` INT(11),
|
||||
`remarks` TEXT,
|
||||
`created_at` DATETIME DEFAULT NOW(),
|
||||
`createdby` INT(11),
|
||||
`updated_at` DATETIME DEFAULT NOW(),
|
||||
`updatedby` INT(11)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_vendors` (
|
||||
`vendor_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`vendortypes_id` INT(11) NULL,
|
||||
`title` VARCHAR(255),
|
||||
`alias` VARCHAR(255),
|
||||
`description` TEXT,
|
||||
`display_order` INT(11),
|
||||
`status` INT(11),
|
||||
`remarks` TEXT,
|
||||
`created_at` DATETIME DEFAULT NOW(),
|
||||
`createdby` INT(11),
|
||||
`updated_at` DATETIME DEFAULT NOW(),
|
||||
`updatedby` INT(11)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_genders` (
|
||||
`gender_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`title` varchar(255) DEFAULT NULL,
|
||||
`alias` varchar(255) DEFAULT NULL,
|
||||
`status` varchar(255) DEFAULT NULL,
|
||||
`remarks` varchar(255) DEFAULT NULL,
|
||||
`display_order` int(11) DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`updatedby` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_castes` (
|
||||
`caste_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`title` varchar(255) DEFAULT NULL,
|
||||
`alias` varchar(255) DEFAULT NULL,
|
||||
`status` varchar(255) DEFAULT NULL,
|
||||
`remarks` varchar(255) DEFAULT NULL,
|
||||
`display_order` int(11) DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`updatedby` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_ethnicities` (
|
||||
`ethnicity_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`title` varchar(255) DEFAULT NULL,
|
||||
`alias` varchar(255) DEFAULT NULL,
|
||||
`status` varchar(255) DEFAULT NULL,
|
||||
`remarks` varchar(255) DEFAULT NULL,
|
||||
`display_order` int(11) DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`updatedby` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_dags` (
|
||||
`dag_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`title` varchar(255) DEFAULT NULL,
|
||||
`alias` varchar(255) DEFAULT NULL,
|
||||
`status` varchar(255) DEFAULT NULL,
|
||||
`remarks` varchar(255) DEFAULT NULL,
|
||||
`display_order` int(11) DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`updatedby` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
");
|
||||
|
||||
DB::statement("CREATE TABLE IF NOT EXISTS `tbl_nationalities` (
|
||||
`nationality_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`title` varchar(255) DEFAULT NULL,
|
||||
`alias` varchar(255) DEFAULT NULL,
|
||||
`status` varchar(255) DEFAULT NULL,
|
||||
`remarks` varchar(255) DEFAULT NULL,
|
||||
`display_order` int(11) DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`updatedby` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
");
|
||||
|
||||
// DB::statement("CREATE TABLE IF NOT EXISTS `tbl_employees` (
|
||||
// `employee_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
// `first_name` varchar(255) DEFAULT NULL,
|
||||
// `middle_name` varchar(255) DEFAULT NULL,
|
||||
// `last_name` varchar(255) DEFAULT NULL,
|
||||
// `email` varchar(255) DEFAULT NULL,
|
||||
// `genders_id` int(11) DEFAULT NULL,
|
||||
// `nepali_dob` date DEFAULT NULL,
|
||||
// `dob` date DEFAULT NULL,
|
||||
// `nationalities_id` int(11) DEFAULT NULL,
|
||||
// `about_me` text,
|
||||
// `signature` varchar(255) DEFAULT NULL,
|
||||
// `father_name` varchar(255) DEFAULT NULL,
|
||||
// `mother_name` varchar(255) DEFAULT NULL,
|
||||
// `grand_father_name` varchar(255) DEFAULT NULL,
|
||||
// `grand_mother_name` varchar(255) DEFAULT NULL,
|
||||
// `spouse` varchar(255) DEFAULT NULL,
|
||||
// `contact` varchar(255) DEFAULT NULL,
|
||||
// `alt_contact` varchar(255) DEFAULT NULL,
|
||||
// `profile_picture` varchar(255) DEFAULT NULL,
|
||||
// `users_id` int(11) DEFAULT NULL,
|
||||
// `is_login_required` tinyint(1) DEFAULT NULL,
|
||||
// `skills` text,
|
||||
// `experience` text,
|
||||
// `permanent_address` text,
|
||||
// `permanent_city` int(11) DEFAULT NULL,
|
||||
// `temporary_address` text,
|
||||
// `temporary_city` int(11) DEFAULT NULL,
|
||||
// `old_system_address` text,
|
||||
// `education` text,
|
||||
// `castes_id` int(11) DEFAULT NULL,
|
||||
// `ethnicities_id` int(11) DEFAULT NULL,
|
||||
// `dags_id` int(11) DEFAULT NULL,
|
||||
// `title` varchar(255) DEFAULT NULL,
|
||||
// `alias` varchar(255) DEFAULT NULL,
|
||||
// `status` varchar(255) DEFAULT NULL,
|
||||
// `display_order` int(11) DEFAULT NULL,
|
||||
// `created_at` timestamp NULL DEFAULT NULL,
|
||||
// `createdby` int(11) DEFAULT NULL,
|
||||
// `updated_at` timestamp NULL DEFAULT NULL,
|
||||
// `updatedby` int(11) DEFAULT NULL,
|
||||
// `remarks` varchar(255) DEFAULT NULL
|
||||
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
// ");
|
||||
|
||||
// DB::statement("
|
||||
// CREATE TABLE IF NOT EXISTS `tbl_onboardings` (
|
||||
// `onboarding_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
// `doj` datetime DEFAULT NULL,
|
||||
// `designations_id` int(11) DEFAULT NULL,
|
||||
// `position_status` varchar(255) DEFAULT NULL,
|
||||
// `departments_id` int(11) DEFAULT NULL,
|
||||
// `shifts_id` int(11) DEFAULT NULL,
|
||||
// `agreement` varchar(255) DEFAULT NULL,
|
||||
// `nda` varchar(255) DEFAULT NULL,
|
||||
// `terms` text DEFAULT NULL,
|
||||
// `workoptions` varchar(255) DEFAULT NULL,
|
||||
// `title` varchar(255) DEFAULT NULL,
|
||||
// `alias` varchar(255) DEFAULT NULL,
|
||||
// `status` int(11) DEFAULT NULL,
|
||||
// `remarks` text DEFAULT NULL,
|
||||
// `display_order` int(11) DEFAULT NULL,
|
||||
// `created_at` timestamp NULL DEFAULT NULL,
|
||||
// `createdby` int(11) DEFAULT NULL,
|
||||
// `updated_at` timestamp NULL DEFAULT NULL,
|
||||
// `updatedby` int(11) DEFAULT NULL
|
||||
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
// ");
|
||||
|
||||
// Dharamaraj
|
||||
|
||||
// DB::statement("
|
||||
// CREATE TABLE IF NOT EXISTS `tbl_departments` (
|
||||
// `department_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
// `title` varchar(255) DEFAULT NULL,
|
||||
// `alias` varchar(255) DEFAULT NULL,
|
||||
// `status` int(11) DEFAULT NULL,
|
||||
// `remarks` text DEFAULT NULL,
|
||||
// `display_order` int(11) DEFAULT NULL,
|
||||
// `created_at` timestamp NULL DEFAULT NULL,
|
||||
// `createdby` int(11) DEFAULT NULL,
|
||||
// `updated_at` timestamp NULL DEFAULT NULL,
|
||||
// `updatedby` int(11) DEFAULT NULL,
|
||||
// `branches_id` int(11) DEFAULT NULL,
|
||||
// `description` text DEFAULT NULL
|
||||
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
// ");
|
||||
|
||||
// DB::statement("
|
||||
// CREATE TABLE IF NOT EXISTS `tbl_designations` (
|
||||
// `designation_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
// `title` varchar(255) DEFAULT NULL,
|
||||
// `salary` DECIMAL(10, 2) DEFAULT NULL,
|
||||
// `alias` varchar(255) DEFAULT NULL,
|
||||
// `status` int(11) DEFAULT NULL,
|
||||
// `remarks` text DEFAULT NULL,
|
||||
// `display_order` int(11) DEFAULT NULL,
|
||||
// `created_at` timestamp NULL DEFAULT NULL,
|
||||
// `createdby` int(11) DEFAULT NULL,
|
||||
// `updated_at` timestamp NULL DEFAULT NULL,
|
||||
// `updatedby` int(11) DEFAULT NULL,
|
||||
// `job_description` text DEFAULT NULL,
|
||||
// `departments_id` int(11) DEFAULT NULL
|
||||
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
// ");
|
||||
|
||||
// DB::statement("
|
||||
// CREATE TABLE IF NOT EXISTS `tbl_shifts` (
|
||||
// `shift_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
// `title` varchar(255) DEFAULT NULL,
|
||||
// `alias` varchar(255) DEFAULT NULL,
|
||||
// `status` int(11) DEFAULT NULL,
|
||||
// `remarks` text DEFAULT NULL,
|
||||
// `display_order` int(11) DEFAULT NULL,
|
||||
// `created_at` timestamp NULL DEFAULT NULL,
|
||||
// `createdby` int(11) DEFAULT NULL,
|
||||
// `updated_at` timestamp NULL DEFAULT NULL,
|
||||
// `updatedby` int(11) DEFAULT NULL
|
||||
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
// ");
|
||||
|
||||
DB::statement("
|
||||
CREATE TABLE IF NOT EXISTS `tbl_workoptions` (
|
||||
`workoption_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`title` varchar(255) DEFAULT NULL,
|
||||
`alias` varchar(255) DEFAULT NULL,
|
||||
`status` int(11) DEFAULT NULL,
|
||||
`remarks` text DEFAULT NULL,
|
||||
`display_order` int(11) DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`createdby` int(11) DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`updatedby` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
");
|
||||
|
||||
// DB::statement("
|
||||
// CREATE TABLE IF NOT EXISTS `tbl_leavetypes` (
|
||||
// `leavetype_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
// `title` varchar(255) DEFAULT NULL,
|
||||
// `alias` varchar(255) DEFAULT NULL,
|
||||
// `status` int(11) DEFAULT NULL,
|
||||
// `remarks` text DEFAULT NULL,
|
||||
// `display_order` int(11) DEFAULT NULL,
|
||||
// `created_at` timestamp NULL DEFAULT NULL,
|
||||
// `createdby` int(11) DEFAULT NULL,
|
||||
// `updated_at` timestamp NULL DEFAULT NULL,
|
||||
// `updatedby` int(11) DEFAULT NULL
|
||||
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
// ");
|
||||
|
||||
// if (!(DB::table('users')->first())) {
|
||||
// DB::statement("INSERT INTO `users` (`name`,`email`,`username`,`password`,`roles_id`,`status`) VALUES ('Prajwal Adhikari','prajwalbro@hotmail.com','prajwalbro@hotmail.com','$2y$10$3zlF9VeXexzWKRDPZuDio.W7RZIC3tU.cjwMoLzG8ki8bVwAQn1WW','1','1');");
|
||||
// }
|
||||
|
||||
// if (!(DB::table('settings')->first())) {
|
||||
// DB::statement("INSERT INTO `tbl_settings` (`title`, `description`, `status`) VALUES ('Bibhuti OMIS', '', '1');");
|
||||
// }
|
||||
|
||||
// if (!(DB::table('countries')->first())) {
|
||||
// DB::statement("INSERT INTO `tbl_countries` (`title`,`alias`,`status`) VALUES ('Nepal','nepal', '1');");
|
||||
// }
|
||||
// if (!(DB::table('provinces')->first())) {
|
||||
// DB::statement("INSERT INTO `tbl_provinces` (`title`,`alias`,`status`) VALUES ('Bagmati','bagmati', '1');");
|
||||
// }
|
||||
|
||||
// if (!(DB::table('roles')->first())) {
|
||||
// DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Admin','admin','1');");
|
||||
// DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Manager','manager','1');");
|
||||
// DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Branch','branch','1');");
|
||||
// DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Agent','agent','1');");
|
||||
// DB::statement("INSERT INTO `tbl_roles` (`title`,`alias`,`status`) VALUES ('Student','student','1');");
|
||||
// }
|
||||
|
||||
$initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
19
app/Helpers/RouteHelper.php
Normal file
19
app/Helpers/RouteHelper.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
function getRouteList()
|
||||
{
|
||||
$routes = Route::getRoutes();
|
||||
$ignoreRoutes = ['debugbar', 'login', 'register', 'logout', 'post', 'sanctum', 'ignition', 'unisharp', 'errorpage', 'form7', 'master', 'hr', 'setting', 'nepalidictonary', 'api'];
|
||||
$routeNameArr = [];
|
||||
foreach ($routes as $value) {
|
||||
if (!is_null($value)) {
|
||||
$routeName = explode('.', $value->getName());
|
||||
if (is_array($routeName) && !empty($routeName[0])) {
|
||||
if (!in_array($routeName[0], $ignoreRoutes)) {
|
||||
$routeNameArr[$routeName[0]][] = $value->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $routeNameArr;
|
||||
}
|
808
app/Helpers/bibHelper.php
Normal file
808
app/Helpers/bibHelper.php
Normal file
@@ -0,0 +1,808 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Log\ActivityLog;
|
||||
use App\Models\Log\ErrorLog;
|
||||
use App\Models\Log\OperationLog;
|
||||
use App\Notifications\SendNotification;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
function pre($object, $die = false)
|
||||
{
|
||||
echo "<pre>";
|
||||
print_r($object);
|
||||
echo "</pre>";
|
||||
if ($die) {
|
||||
die;
|
||||
}
|
||||
|
||||
}
|
||||
function label($text, $echo = true)
|
||||
{
|
||||
|
||||
$text = strtoupper($text);
|
||||
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
|
||||
}
|
||||
function landingtemplate($filepath)
|
||||
{
|
||||
$filepath = env("APP_URL") . '/' . env("CLIENT_PATH") . '/landing/' . $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, $tableName = null)
|
||||
{
|
||||
// Generate the initial slug from the text
|
||||
$slug = preg_replace('/[^a-zA-Z0-9\-]/', '-', $text);
|
||||
$slug = preg_replace('/-+/', '-', $slug);
|
||||
$slug = trim($slug, '-');
|
||||
$slug = strtolower($slug);
|
||||
|
||||
// If the table name is provided, check for uniqueness and modify the slug if needed
|
||||
if ($tableName) {
|
||||
$originalSlug = $slug;
|
||||
$count = 1;
|
||||
|
||||
while (isSlugExists($tableName, $slug)) {
|
||||
$slug = $originalSlug . '-' . $count;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
return $slug;
|
||||
}
|
||||
}
|
||||
if (!function_exists('isSlugExists')) {
|
||||
function isSlugExists($tableName, $slug)
|
||||
{
|
||||
$aliasField = 'alias';
|
||||
$count = DB::table($tableName)
|
||||
->where($aliasField, $slug)
|
||||
->count();
|
||||
return $count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
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, $extra = 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);
|
||||
|
||||
?>
|
||||
<?php if ($displayTextForLabel != ''): ?><label class="form-label col-form-label">
|
||||
<?php echo label($displayTextForLabel); ?>
|
||||
</label>
|
||||
<?php endif;?>
|
||||
<select class="form-select <?php echo $additionalClass; ?>" name="<?php echo $HTMLElementName; ?>" id="<?php echo $HTMLElementName; ?>" data-search="true"
|
||||
aria-label="" <?php if (stripos($additionalClass, 'required') !== false) {echo "REQUIRED";}?> <?php if (stripos($additionalClass, 'readonly') !== false) {echo "DISABLED";}?> <?php echo $extra; ?>>
|
||||
<?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 : "Upload"; ?>
|
||||
</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;?> multiple>
|
||||
</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 createMultiImageInput($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;?> multiple>
|
||||
</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',
|
||||
type: 'file',
|
||||
multi_selection: true
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
});
|
||||
}
|
||||
|
||||
function site_url($url = "")
|
||||
{
|
||||
return env("APP_URL") . "/" . trim($url, "/");
|
||||
}
|
||||
function base_url($url = "")
|
||||
{
|
||||
return env("APP_URL") . "/" . trim($url, "/");
|
||||
}
|
||||
function showImageThumb($url)
|
||||
{?>
|
||||
<div style="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)) ? $query->value($returnField) : "N/A";
|
||||
|
||||
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()) ? auth()->user()->id : "0";
|
||||
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()) ? auth()->user()->id : "0";
|
||||
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()) ? auth()->user()->id : "0";
|
||||
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 datepicker<?php echo $class; ?>" value="<?php echo $default; ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
function createPassword($name, $display = "", $class = "password", $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="password" 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;
|
||||
}
|
||||
function getAlias($textField, $tableName)
|
||||
{
|
||||
|
||||
$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 sectionHeader($text, $sectiontitle = null)
|
||||
{
|
||||
$texts = explode(" ", $text);
|
||||
?>
|
||||
<div class="row text-center intro">
|
||||
|
||||
<div class="col-12">
|
||||
<?php if ($sectiontitle): ?>
|
||||
<span class="pre-title">
|
||||
<?php echo $sectiontitle; ?>
|
||||
</span>
|
||||
<?php endif;?>
|
||||
|
||||
<h2 class="ylw-clr">
|
||||
<?php echo $texts[0];
|
||||
unset($texts[0]); ?> <span class="featured"><span>
|
||||
<?php echo implode(" ", $texts); ?>
|
||||
</span></span>
|
||||
</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
if (!function_exists('replace_img_src')) {
|
||||
function replace_img_src($content)
|
||||
{
|
||||
return preg_replace(
|
||||
'/src="storage(\/[^"]*)"/',
|
||||
'src="' . site_url() . 'storage$1"',
|
||||
$content
|
||||
);
|
||||
}
|
||||
}
|
||||
function processForShortcode($content)
|
||||
{
|
||||
$content = replace_img_src($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);
|
||||
}
|
||||
function createCustomCheckboxes($tableName, $labelColumn, $valueColumn, $selectedValue = null, $extraAttributes = "", $name = "", $inputType = "checkbox", $condition = "")
|
||||
{
|
||||
// Your implementation logic goes here
|
||||
|
||||
// Example: Fetching data from the database
|
||||
$options = DB::table($tableName)
|
||||
->whereRaw($condition)
|
||||
->get();
|
||||
|
||||
// Example: Creating checkboxes
|
||||
foreach ($options as $option) {
|
||||
$isChecked = ($option->$valueColumn == $selectedValue) ? 'checked' : '';
|
||||
|
||||
echo " <div class='form-check mb-0 '><input class='form-check-input' type='$inputType' name='$name' id='valuefor$name" . $option->{$valueColumn} . "' value='" . $option->{$valueColumn} . "' $isChecked $extraAttributes> <label class='form-check-label' for='valuefor$name" . $option->{$valueColumn} . "' >
|
||||
{$option->$labelColumn}
|
||||
</label> </div>";
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('sendNotification')) {
|
||||
function sendNotification($user, $notification = [])
|
||||
{
|
||||
\Notification::send($user, new SendNotification($notification));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('uploadImage')) {
|
||||
function uploadImage($file)
|
||||
{
|
||||
$fileName = time() . '_' . $file->getClientOriginalName();
|
||||
$filePath = Storage::disk('public')->putFileAs('uploads', $file, $fileName);
|
||||
return $filePath;
|
||||
}
|
||||
}
|
39
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
39
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||
|
||||
class ConfirmPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confirm Password Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password confirmations and
|
||||
| uses a simple trait to include the behavior. You're free to explore
|
||||
| this trait and override any functions that require customization.
|
||||
|
|
||||
*/
|
||||
|
||||
use ConfirmsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users when the intended url fails.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/dashboard';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
}
|
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
}
|
39
app/Http/Controllers/Auth/LoginController.php
Normal file
39
app/Http/Controllers/Auth/LoginController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/dashboard';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
}
|
72
app/Http/Controllers/Auth/RegisterController.php
Normal file
72
app/Http/Controllers/Auth/RegisterController.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/dashboard';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\Models\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
29
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
29
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/dashboard';
|
||||
}
|
41
app/Http/Controllers/Auth/VerificationController.php
Normal file
41
app/Http/Controllers/Auth/VerificationController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Email Verification Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling email verification for any
|
||||
| user that recently registered with the application. Emails may also
|
||||
| be re-sent if the user didn't receive the original email message.
|
||||
|
|
||||
*/
|
||||
|
||||
use VerifiesEmails;
|
||||
|
||||
/**
|
||||
* Where to redirect users after verification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/dashboard';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('signed')->only('verify');
|
||||
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||
}
|
||||
}
|
218
app/Http/Controllers/BranchesController.php
Normal file
218
app/Http/Controllers/BranchesController.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Branches;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class BranchesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Branches $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'index', ' Branches index');
|
||||
$data = Branches::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.branches.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'create', ' Branches create');
|
||||
$TableData = Branches::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.branches.create",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'store', ' Branches store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$request->request->add(['alias' => slugify($request->title)]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_branches')]);
|
||||
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
|
||||
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$operationNumber = getOperationNumber();
|
||||
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(BranchesController::class, 'store', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Branches Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('branches.index')->with('success','The Branches created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Branches::find($id);
|
||||
$companyArticle->display_order = $index + 1;
|
||||
$companyArticle->save();
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200);
|
||||
}
|
||||
public function updatealias(Request $request)
|
||||
{
|
||||
|
||||
$articleId = $request->input('articleId');
|
||||
$newAlias = $request->input('newAlias');
|
||||
$companyArticle = Branches::find($articleId);
|
||||
if (!$companyArticle) {
|
||||
return response()->json(['status' => false, 'content' => 'Company article not found.'], 404);
|
||||
}
|
||||
$companyArticle->alias = $newAlias;
|
||||
$companyArticle->save();
|
||||
return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'show', ' Branches show');
|
||||
$data = Branches::findOrFail($id);
|
||||
|
||||
return view("crud.generated.branches.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'edit', ' Branches edit');
|
||||
$TableData = Branches::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Branches::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.branches.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'update', ' Branches update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('branch_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(BranchesController::class, 'update', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Branches updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('branches.index')->with('success','The Branches updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Branches updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'destroy', ' Branches destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(BranchesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Branches Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'destroy', ' Branches destroy');
|
||||
$data = Branches::findOrFail($id);
|
||||
$requestData=['status'=>($data->status==1)?0:1];
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(BranchesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Branches Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'clone', ' Branches clone');
|
||||
$data = Branches::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(BranchesController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Branches Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
12
app/Http/Controllers/Controller.php
Normal file
12
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, ValidatesRequests;
|
||||
}
|
218
app/Http/Controllers/DagsController.php
Normal file
218
app/Http/Controllers/DagsController.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Dags;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class DagsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Dags $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'index', ' Dags index');
|
||||
$data = Dags::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.dags.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'create', ' Dags create');
|
||||
$TableData = Dags::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.dags.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'store', ' Dags store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$request->request->add(['alias' => slugify($request->title)]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_dags')]);
|
||||
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
|
||||
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$operationNumber = getOperationNumber();
|
||||
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DagsController::class, 'store', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Dags Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('dags.index')->with('success','The Dags created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Dags::find($id);
|
||||
$companyArticle->display_order = $index + 1;
|
||||
$companyArticle->save();
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200);
|
||||
}
|
||||
public function updatealias(Request $request)
|
||||
{
|
||||
|
||||
$articleId = $request->input('articleId');
|
||||
$newAlias = $request->input('newAlias');
|
||||
$companyArticle = Dags::find($articleId);
|
||||
if (!$companyArticle) {
|
||||
return response()->json(['status' => false, 'content' => 'Company article not found.'], 404);
|
||||
}
|
||||
$companyArticle->alias = $newAlias;
|
||||
$companyArticle->save();
|
||||
return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'show', ' Dags show');
|
||||
$data = Dags::findOrFail($id);
|
||||
|
||||
return view("crud.generated.dags.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'edit', ' Dags edit');
|
||||
$TableData = Dags::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Dags::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.dags.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'update', ' Dags update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('dag_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DagsController::class, 'update', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Dags updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('dags.index')->with('success','The Dags updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Dags updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'destroy', ' Dags destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DagsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Dags Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'destroy', ' Dags destroy');
|
||||
$data = Dags::findOrFail($id);
|
||||
$requestData=['status'=>($data->status==1)?0:1];
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DagsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Dags Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'clone', ' Dags clone');
|
||||
$data = Dags::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DagsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Dags Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
65
app/Http/Controllers/DocumentController.php
Normal file
65
app/Http/Controllers/DocumentController.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Document;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DocumentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Document $document)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Document $document)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Document $document)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Document $document)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
40
app/Http/Controllers/HomeController.php
Normal file
40
app/Http/Controllers/HomeController.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Modules\Attendance\Models\Attendance;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['isClockIn'] = true;
|
||||
$attendance = Attendance::where('employee_id', auth()->user()->employee_id)->whereDate('date', now())->first();
|
||||
if ($attendance) {
|
||||
if ($attendance->type == 'clockout') {
|
||||
$data['isClockIn'] = false;
|
||||
}
|
||||
}
|
||||
return view('dashboard', $data);
|
||||
}
|
||||
|
||||
public function employeeDashboard()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
218
app/Http/Controllers/OnboardingsController.php
Normal file
218
app/Http/Controllers/OnboardingsController.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Onboardings;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class OnboardingsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Onboardings $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'index', ' Onboardings index');
|
||||
$data = Onboardings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.onboardings.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'create', ' Onboardings create');
|
||||
$TableData = Onboardings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.onboardings.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'store', ' Onboardings store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$request->request->add(['alias' => slugify($request->title)]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_onboardings')]);
|
||||
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
|
||||
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$operationNumber = getOperationNumber();
|
||||
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(OnboardingsController::class, 'store', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Onboardings Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('onboardings.index')->with('success','The Onboardings created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Onboardings::find($id);
|
||||
$companyArticle->display_order = $index + 1;
|
||||
$companyArticle->save();
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200);
|
||||
}
|
||||
public function updatealias(Request $request)
|
||||
{
|
||||
|
||||
$articleId = $request->input('articleId');
|
||||
$newAlias = $request->input('newAlias');
|
||||
$companyArticle = Onboardings::find($articleId);
|
||||
if (!$companyArticle) {
|
||||
return response()->json(['status' => false, 'content' => 'Company article not found.'], 404);
|
||||
}
|
||||
$companyArticle->alias = $newAlias;
|
||||
$companyArticle->save();
|
||||
return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'show', ' Onboardings show');
|
||||
$data = Onboardings::findOrFail($id);
|
||||
|
||||
return view("crud.generated.onboardings.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'edit', ' Onboardings edit');
|
||||
$TableData = Onboardings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Onboardings::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.onboardings.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'update', ' Onboardings update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('onboarding_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(OnboardingsController::class, 'update', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Onboardings updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('onboardings.index')->with('success','The Onboardings updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Onboardings updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'destroy', ' Onboardings destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(OnboardingsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Onboardings Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'destroy', ' Onboardings destroy');
|
||||
$data = Onboardings::findOrFail($id);
|
||||
$requestData=['status'=>($data->status==1)?0:1];
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(OnboardingsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Onboardings Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'clone', ' Onboardings clone');
|
||||
$data = Onboardings::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(OnboardingsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Onboardings Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
198
app/Http/Controllers/SettingsController.php
Normal file
198
app/Http/Controllers/SettingsController.php
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Settings $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'index', ' Settings index');
|
||||
$data = Settings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.settings.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'create', ' Settings create');
|
||||
$TableData = Settings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.settings.create",compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'store', ' Settings store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$request->request->add(['alias' => slugify($request->title)]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_settings')]);
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$operationNumber = getOperationNumber();
|
||||
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(SettingsController::class, 'store', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Settings Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('settings.index')->with('success','The Settings created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Settings::find($id);
|
||||
$companyArticle->display_order = $index + 1;
|
||||
$companyArticle->save();
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200);
|
||||
}
|
||||
public function updatealias(Request $request)
|
||||
{
|
||||
|
||||
$articleId = $request->input('articleId');
|
||||
$newAlias = $request->input('newAlias');
|
||||
$companyArticle = Settings::find($articleId);
|
||||
if (!$companyArticle) {
|
||||
return response()->json(['status' => false, 'content' => 'Company article not found.'], 404);
|
||||
}
|
||||
$companyArticle->alias = $newAlias;
|
||||
$companyArticle->save();
|
||||
return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'show', ' Settings show');
|
||||
$data = Settings::findOrFail($id);
|
||||
|
||||
return view("crud.generated.settings.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'edit', ' Settings edit');
|
||||
$TableData = Settings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Settings::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.settings.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.settings.edit", compact('data','TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'update', ' Settings update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('setting_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(SettingsController::class, 'update', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Settings updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('settings.index')->with('success','The Settings updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Settings updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'destroy', ' Settings destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(SettingsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Settings Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'destroy', ' Settings destroy');
|
||||
$data = Settings::findOrFail($id);
|
||||
$requestData=['status'=>($data->status==1)?0:1];
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(SettingsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Settings Deleted Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
70
app/Http/Kernel.php
Normal file
70
app/Http/Kernel.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\PermissionMiddleware::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's middleware aliases.
|
||||
*
|
||||
* Aliases may be used to conveniently assign middleware to routes and groups.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
|
||||
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
|
||||
];
|
||||
}
|
17
app/Http/Middleware/Authenticate.php
Normal file
17
app/Http/Middleware/Authenticate.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*/
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
62
app/Http/Middleware/PermissionMiddleware.php
Normal file
62
app/Http/Middleware/PermissionMiddleware.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Spatie\Permission\Exceptions\UnauthorizedException;
|
||||
use Spatie\Permission\Guard;
|
||||
|
||||
class PermissionMiddleware
|
||||
{
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
$authGuard = Auth::guard($guard);
|
||||
|
||||
$user = $authGuard->user();
|
||||
|
||||
// For machine-to-machine Passport clients
|
||||
if (!$user && $request->bearerToken() && config('permission.use_passport_client_credentials')) {
|
||||
|
||||
$user = Guard::getPassportClient($guard);
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
|
||||
throw UnauthorizedException::notLoggedIn();
|
||||
}
|
||||
|
||||
if (!method_exists($user, 'hasAnyPermission')) {
|
||||
|
||||
throw UnauthorizedException::missingTraitHasRoles($user);
|
||||
}
|
||||
|
||||
// if ($user->hasRole('admin')) {
|
||||
// return $next($request);
|
||||
// }
|
||||
|
||||
foreach ($user->roles as $role) {
|
||||
if ($role->hasPermissionTo($request->route()->getName())) {
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
throw UnauthorizedException::forPermissions($user->getAllPermissions()->toArray());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the permission and guard for the middleware.
|
||||
*
|
||||
* @param array|string $permission
|
||||
* @param string|null $guard
|
||||
* @return string
|
||||
*/
|
||||
public static function using($permission, $guard = null)
|
||||
{
|
||||
$permissionString = is_string($permission) ? $permission : implode('|', $permission);
|
||||
$args = is_null($guard) ? $permissionString : "$permissionString,$guard";
|
||||
|
||||
return static::class . ':' . $args;
|
||||
}
|
||||
}
|
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
30
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
30
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
22
app/Http/Middleware/ValidateSignature.php
Normal file
22
app/Http/Middleware/ValidateSignature.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
16
app/Models/Branches.php
Normal file
16
app/Models/Branches.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Branches extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "tbl_branches";
|
||||
protected $primaryKey = "branch_id";
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
29
app/Models/Document.php
Normal file
29
app/Models/Document.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Document extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "tbl_documents";
|
||||
protected $primaryKey = "document_id";
|
||||
|
||||
protected $fillable = [
|
||||
'document_name',
|
||||
'document_path',
|
||||
'document_for_ref',
|
||||
'description',
|
||||
'status',
|
||||
'description',
|
||||
'remarks'
|
||||
];
|
||||
|
||||
public function documentable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
25
app/Models/Scopes/CreatedByScope.php
Normal file
25
app/Models/Scopes/CreatedByScope.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Scopes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Scope;
|
||||
|
||||
class CreatedByScope implements Scope
|
||||
{
|
||||
/**
|
||||
* Apply the scope to a given Eloquent query builder.
|
||||
*/
|
||||
public function apply(Builder $builder, Model $model): void
|
||||
{
|
||||
if (auth()->user()->hasRole('admin')) {
|
||||
// $builder->where('dftqcoffice_id', auth()->user()->dftqcoffice_id);
|
||||
}
|
||||
|
||||
if (auth()->user()->hasRole('employee')) {
|
||||
$user = \Auth::user();
|
||||
$builder->where($model->getTable() . '.employee_id', $user->employee_id);
|
||||
}
|
||||
}
|
||||
}
|
62
app/Models/User.php
Normal file
62
app/Models/User.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Modules\Employee\Models\Employee;
|
||||
use Spatie\Permission\Traits\HasPermissions;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable, HasRoles, HasPermissions;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'employee_id',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $appends = ['full_name', 'profile_pic'];
|
||||
|
||||
public function employee()
|
||||
{
|
||||
return $this->belongsTo(Employee::class, 'employee_id');
|
||||
}
|
||||
|
||||
protected function getProfilePicAttribute()
|
||||
{
|
||||
return $this->employee ? asset('storage/' . $this->employee?->profile_picture) : asset('assets/images/task.png');
|
||||
}
|
||||
|
||||
}
|
16
app/Models/Vendors.php
Normal file
16
app/Models/Vendors.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Vendors extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'tbl_vendors';
|
||||
protected $primaryKey = 'vendor_id';
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
16
app/Models/Vendortypes.php
Normal file
16
app/Models/Vendortypes.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Vendortypes extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'tbl_vendortypes';
|
||||
protected $primaryKey = 'vendortype_id';
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
64
app/Notifications/HrActionNotification.php
Normal file
64
app/Notifications/HrActionNotification.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class HrActionNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected $actionType;
|
||||
protected $model;
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct($actionType, $model, $message)
|
||||
{
|
||||
$this->actionType = $actionType;
|
||||
$this->model = $model;
|
||||
$this->message = $message;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail', 'database'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
return (new MailMessage)
|
||||
->subject('HR Notification')
|
||||
->view('emails.email_template', [
|
||||
'actionType' => $this->actionType,
|
||||
'model' => $this->model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
'action_type' => $this->actionType,
|
||||
'model' => $this->model,
|
||||
'msg' => $this->message,
|
||||
];
|
||||
}
|
||||
}
|
56
app/Notifications/SendNotification.php
Normal file
56
app/Notifications/SendNotification.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class SendNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
private $data;
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['database'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
return (new MailMessage)
|
||||
->line('The introduction to the notification.')
|
||||
->action('Notification Action', url('/'))
|
||||
->line('Thank you for using our application!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
'msg' => $this->data['msg'],
|
||||
];
|
||||
}
|
||||
}
|
51
app/Observers/AppreciationObserver.php
Normal file
51
app/Observers/AppreciationObserver.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Notifications\HrActionNotification;
|
||||
use Modules\Admin\Models\Appreciation;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
class AppreciationObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Appreciation "created" event.
|
||||
*/
|
||||
public function created(Appreciation $appreciation): void
|
||||
{
|
||||
$appreciatee = $appreciation->appreciatee;
|
||||
$appreciatee->notify(new HrActionNotification('appreciation', $appreciation,'you have been appreciated.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Appreciation "updated" event.
|
||||
*/
|
||||
public function updated(Appreciation $appreciation): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Appreciation "deleted" event.
|
||||
*/
|
||||
public function deleted(Appreciation $appreciation): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Appreciation "restored" event.
|
||||
*/
|
||||
public function restored(Appreciation $appreciation): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Appreciation "force deleted" event.
|
||||
*/
|
||||
public function forceDeleted(Appreciation $appreciation): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
53
app/Observers/InterviewScheduleObserver.php
Normal file
53
app/Observers/InterviewScheduleObserver.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Notifications\HrActionNotification;
|
||||
use Modules\Employee\Models\Employee;
|
||||
use Modules\Recruit\Models\InterviewSchedule;
|
||||
|
||||
|
||||
class InterviewScheduleObserver
|
||||
{
|
||||
/**
|
||||
* Handle the InterviewSchedule "created" event.
|
||||
*/
|
||||
public function created(InterviewSchedule $interviewSchedule): void
|
||||
{
|
||||
$interviewers = Employee::whereIn('id', $interviewSchedule->interviewer_choices)->get();
|
||||
$interviewers->each->notify(new HrActionNotification('interviewer', $interviewSchedule,'you have been selected as interviewer'));
|
||||
$interviewSchedule->jobPost->jobApplications->each->notify(new HrActionNotification('interviewee', $interviewSchedule,'you interview has been scheduled'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the InterviewSchedule "updated" event.
|
||||
*/
|
||||
public function updated(InterviewSchedule $interviewSchedule): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the InterviewSchedule "deleted" event.
|
||||
*/
|
||||
public function deleted(InterviewSchedule $interviewSchedule): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the InterviewSchedule "restored" event.
|
||||
*/
|
||||
public function restored(InterviewSchedule $interviewSchedule): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the InterviewSchedule "force deleted" event.
|
||||
*/
|
||||
public function forceDeleted(InterviewSchedule $interviewSchedule): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
52
app/Observers/PromotionDemotionObserver.php
Normal file
52
app/Observers/PromotionDemotionObserver.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Notifications\HrActionNotification;
|
||||
use Modules\Admin\Models\PromotionDemotion;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
|
||||
class PromotionDemotionObserver
|
||||
{
|
||||
/**
|
||||
* Handle the PromotionDemotion "created" event.
|
||||
*/
|
||||
public function created(PromotionDemotion $promotionDemotion): void
|
||||
{
|
||||
$employee = $promotionDemotion->employee;
|
||||
$employee->notify(new HrActionNotification($promotionDemotion->type, $promotionDemotion,'You have been promoted'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the PromotionDemotion "updated" event.
|
||||
*/
|
||||
public function updated(PromotionDemotion $promotionDemotion): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the PromotionDemotion "deleted" event.
|
||||
*/
|
||||
public function deleted(PromotionDemotion $promotionDemotion): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the PromotionDemotion "restored" event.
|
||||
*/
|
||||
public function restored(PromotionDemotion $promotionDemotion): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the PromotionDemotion "force deleted" event.
|
||||
*/
|
||||
public function forceDeleted(PromotionDemotion $promotionDemotion): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
50
app/Observers/WarningObserver.php
Normal file
50
app/Observers/WarningObserver.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
use App\Notifications\HrActionNotification;
|
||||
use Modules\Admin\Models\Warning;
|
||||
|
||||
|
||||
class WarningObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Warning "created" event.
|
||||
*/
|
||||
public function created(Warning $warning): void
|
||||
{
|
||||
$employee = $warning->warningRecipient;
|
||||
$employee->notify(new HrActionNotification('warning', $warning,'you have been warned'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Warning "updated" event.
|
||||
*/
|
||||
public function updated(Warning $warning): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Warning "deleted" event.
|
||||
*/
|
||||
public function deleted(Warning $warning): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Warning "restored" event.
|
||||
*/
|
||||
public function restored(Warning $warning): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Warning "force deleted" event.
|
||||
*/
|
||||
public function forceDeleted(Warning $warning): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
27
app/Providers/AppServiceProvider.php
Normal file
27
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
|
||||
Paginator::useBootstrap();
|
||||
}
|
||||
}
|
28
app/Providers/AuthServiceProvider.php
Normal file
28
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
// use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
19
app/Providers/BroadcastServiceProvider.php
Normal file
19
app/Providers/BroadcastServiceProvider.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
38
app/Providers/EventServiceProvider.php
Normal file
38
app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*/
|
||||
public function shouldDiscoverEvents(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
48
app/Providers/RouteServiceProvider.php
Normal file
48
app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/dashboard';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*/
|
||||
protected function configureRateLimiting(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
217
app/Service/CommonModelService.php
Normal file
217
app/Service/CommonModelService.php
Normal file
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use Exception;
|
||||
|
||||
class CommonModelService
|
||||
{
|
||||
protected $model;
|
||||
|
||||
public function __construct($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create operation
|
||||
* $operationStartNumber -> It is required first time if it contain multiple tables operation
|
||||
* $operationEndNumber -> It is required Every time on any operation because on showing block it is required.
|
||||
* $oldValues -> On store/insert old values will be null
|
||||
* $newValues => On store/insert operation $new values will be model created object values and stoe in json format.
|
||||
*/
|
||||
public function create($operationStartNumber, $operationEndNumber, $oldValues, $newValues)
|
||||
{
|
||||
$baseClass = get_class($this->model);
|
||||
$modelData = $this->model->create($newValues);
|
||||
$prmimayKeyFieldName = $modelData->getKeyName();
|
||||
$ModelID = $modelData->$prmimayKeyFieldName;
|
||||
createOperationLog($operationStartNumber, $operationEndNumber, $baseClass, $ModelID, 'create', $oldValues, $modelData);
|
||||
return $modelData;
|
||||
}
|
||||
|
||||
/**
|
||||
* update operation
|
||||
* $operationStartNumber -> It is required first time if it contain multiple tables operation
|
||||
* $operationEndNumber -> It is required Every time on any operation because on showing block it is required.
|
||||
* $oldValues -> On store/insert old values case, is required only if it is updated on direct table on like users_roles table case other wise We get here
|
||||
* null but find from model Id. It will be also stored in json format.
|
||||
* $newValues => On store/insert operation $new values will be model created object values and stoe in json format.
|
||||
*/
|
||||
public function update($operationStartNumber, $operationEndNumber, $oldValues, $newValues, $ModelID)
|
||||
{
|
||||
$baseClass = get_class($this->model);
|
||||
$this->model = $this->model->find($ModelID);
|
||||
$oldValues = !empty($oldValues) ? $oldValues : $this->model->toArray();
|
||||
$this->model->update($newValues);
|
||||
createOperationLog($operationStartNumber, $operationEndNumber, $baseClass, $ModelID, 'update', $oldValues, $this->model->getChanges());
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create operation
|
||||
* $operationStartNumber -> It is required first time if it contain multiple tables operation
|
||||
* $operationEndNumber -> It is required Every time on any operation because on showing block it is required.
|
||||
* $oldValues -> On store/insert old values will be null
|
||||
* $newValues => On store/insert operation $new values will be model created object values and stoe in json format.
|
||||
*/
|
||||
public function destroy($operationStartNumber, $operationEndNumber, $ModelID)
|
||||
{
|
||||
$baseClass = get_class($this->model);
|
||||
$this->model = $this->model->find($ModelID);
|
||||
$oldValues = ['status' => $this->model->status];
|
||||
$this->model->update(['status' => -1]);
|
||||
createOperationLog($operationStartNumber, $operationEndNumber, $baseClass, $ModelID, 'delete', $oldValues, ['status' => -1]);
|
||||
return $this->model;
|
||||
}
|
||||
/**
|
||||
* Paginate all User
|
||||
*
|
||||
* @param array $filter
|
||||
* @return Collection
|
||||
*/
|
||||
public function paginate(array $filter = [])
|
||||
{
|
||||
$filter['limit'] = 25;
|
||||
|
||||
return $this->model->orderBy('id', 'DESC')->whereIsDeleted('no')->paginate($filter['limit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all User
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return $this->model->whereIsDeleted('no')->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all users with supervisor type
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
|
||||
|
||||
public function find($userId)
|
||||
{
|
||||
try {
|
||||
return $this->model->whereIsDeleted('no')->find($userId);
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public function update($userId, array $data)
|
||||
// {
|
||||
// try {
|
||||
|
||||
// $data['visibility'] = (isset($data['visibility']) ? $data['visibility'] : '') == 'on' ? 'visible' : 'invisible';
|
||||
// $data['status'] = (isset($data['status']) ? $data['status'] : '') == 'on' ? 'active' : 'in_active';
|
||||
// $data['availability'] = (isset($data['availability']) ? $data['availability'] : '') == 'on' ? 'available' : 'not_available';
|
||||
// $data['has_subuser'] = (isset($data['has_subuser']) ? $data['has_subuser'] : '') == 'on' ? 'yes' : 'no';
|
||||
// $data['last_updated_by'] = Auth::user()->id;
|
||||
// $user = $this->model->find($userId);
|
||||
|
||||
// $user = $user->update($data);
|
||||
// $this->logger->info(' created successfully', $data);
|
||||
|
||||
// return $user;
|
||||
// } catch (Exception $e) {
|
||||
// $this->logger->error($e->getMessage());
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Delete a User
|
||||
*
|
||||
* @param Id
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($userId)
|
||||
{
|
||||
try {
|
||||
$data['last_deleted_by'] = Auth::user()->id;
|
||||
$data['deleted_at'] = Carbon::now();
|
||||
$user = $this->model->find($userId);
|
||||
$data['is_deleted'] = 'yes';
|
||||
return $user = $user->update($data);
|
||||
dd($user);
|
||||
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserRoles($id)
|
||||
{
|
||||
try {
|
||||
$user = User::with('roles')->find($id);
|
||||
$roles = $user->roles;
|
||||
return $roles;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* write brief description
|
||||
* @param $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function getByName($name)
|
||||
{
|
||||
return $this->model->whereIsDeleted('no')->whereName($name);
|
||||
}
|
||||
|
||||
public function getBySlug($id)
|
||||
{
|
||||
return $this->model->whereIsDeleted('no')->whereId($id)->first();
|
||||
}
|
||||
|
||||
|
||||
function uploadFile($file)
|
||||
{
|
||||
if (!empty($file)) {
|
||||
$this->uploadPath = 'uploads/user';
|
||||
return $fileName = $this->uploadFromAjax($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function __deleteImages($subCat)
|
||||
{
|
||||
try {
|
||||
if (is_file($subCat->image_path))
|
||||
unlink($subCat->image_path);
|
||||
|
||||
if (is_file($subCat->thumbnail_path))
|
||||
unlink($subCat->thumbnail_path);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function updateImage($userId, array $data)
|
||||
{
|
||||
try {
|
||||
$user = $this->model->find($userId);
|
||||
$user = $user->update($data);
|
||||
|
||||
return $user;
|
||||
} catch (Exception $e) {
|
||||
//$this->logger->error($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
33
app/Service/DepartmentService.php
Normal file
33
app/Service/DepartmentService.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Department\Repositories;
|
||||
|
||||
use Modules\Department\Models\Department;
|
||||
|
||||
class DepartmentService
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Department::paginate(20);
|
||||
}
|
||||
|
||||
public function getDepartmentById($DepartmentId)
|
||||
{
|
||||
return Department::findOrFail($DepartmentId);
|
||||
}
|
||||
|
||||
public function delete($DepartmentId)
|
||||
{
|
||||
Department::destroy($DepartmentId);
|
||||
}
|
||||
|
||||
public function create($DepartmentDetails)
|
||||
{
|
||||
return Department::create($DepartmentDetails);
|
||||
}
|
||||
|
||||
public function update($DepartmentId, array $newDetails)
|
||||
{
|
||||
return Department::whereId($DepartmentId)->update($newDetails);
|
||||
}
|
||||
}
|
32
app/Traits/CreatedUpdatedBy.php
Normal file
32
app/Traits/CreatedUpdatedBy.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
trait CreatedUpdatedBy
|
||||
{
|
||||
public static function bootCreatedUpdatedBy()
|
||||
{
|
||||
// updating created_by and updated_by when model is created
|
||||
static::creating(function ($model) {
|
||||
if (!$model->isDirty('createdBy')) {
|
||||
$model->createdBy = auth()->user() ? auth()->user()->id : null;
|
||||
}
|
||||
if (!$model->isDirty('updatedBy')) {
|
||||
$model->updatedBy = auth()->user() ? auth()->user()->id : null;
|
||||
}
|
||||
if ($model->isDirty('createdOn') && !$model->isDirty('createdOn')) {
|
||||
$model->createdOn = now();
|
||||
}
|
||||
// if (!$model->isDirty('status')) {
|
||||
// $model->status = 11;
|
||||
// }
|
||||
});
|
||||
|
||||
// updating updated_by when model is updated
|
||||
static::updating(function ($model) {
|
||||
if (!$model->isDirty('updatedBy')) {
|
||||
$model->updatedBy = auth()->user() ? auth()->user()->id : 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
34
app/Traits/StatusTrait.php
Normal file
34
app/Traits/StatusTrait.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
trait StatusTrait
|
||||
{
|
||||
const STATUS = [
|
||||
11 => 'Active',
|
||||
10 => 'In-Active',
|
||||
];
|
||||
|
||||
protected function statusName(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function (mixed $value, array $attributes) {
|
||||
// dd($value, $attributes);
|
||||
switch ($attributes['status']) {
|
||||
case '10':
|
||||
return '<span class="badge bg-danger">' . self::STATUS[$attributes['status']] . '</span>';
|
||||
break;
|
||||
case '11':
|
||||
return '<span class="badge bg-success">' . self::STATUS[$attributes['status']] . '</span>';
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
},
|
||||
set: fn($value) => $value,
|
||||
);
|
||||
}
|
||||
}
|
26
app/View/Components/ClockInOutForm.php
Normal file
26
app/View/Components/ClockInOutForm.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class ClockInOutForm extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.clock-in-out-form');
|
||||
}
|
||||
}
|
26
app/View/Components/DataTableScript.php
Normal file
26
app/View/Components/DataTableScript.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class DataTableScript extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.data-table-script');
|
||||
}
|
||||
}
|
26
app/View/Components/FormButtons.php
Normal file
26
app/View/Components/FormButtons.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class FormButtons extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.form-buttons');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user