first commit
This commit is contained in:
BIN
app/.DS_Store
vendored
Normal file
BIN
app/.DS_Store
vendored
Normal file
Binary file not shown.
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');
|
||||
}
|
||||
}
|
30
app/Exceptions/Handler.php
Normal file
30
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* The 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) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
11
app/Handlers/LfmConfigHandler.php
Normal file
11
app/Handlers/LfmConfigHandler.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Handlers;
|
||||
|
||||
class LfmConfigHandler extends \UniSharp\LaravelFilemanager\Handlers\ConfigHandler
|
||||
{
|
||||
public function userField()
|
||||
{
|
||||
return parent::userField();
|
||||
}
|
||||
}
|
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, "", "", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
43
app/Helpers/CCMS.php
Normal file
43
app/Helpers/CCMS.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Menuitems;
|
||||
use App\Models\Menulocations;
|
||||
use App\Models\Preparationclasses;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CCMS
|
||||
{
|
||||
// public function __construct()
|
||||
// {
|
||||
// $this->initDB();
|
||||
// }
|
||||
|
||||
|
||||
// public static function getSiteVars()
|
||||
// {
|
||||
// $siteVars = DB::table("settings")->where('status', 1)->orderby('display_order')->first();
|
||||
// return $siteVars;
|
||||
// }
|
||||
|
||||
// private function initDB()
|
||||
// {
|
||||
// static $initialized = false;
|
||||
// if (!$initialized) {
|
||||
|
||||
|
||||
// if (!(DB::table('users')->first())) {
|
||||
// DB::statement("INSERT INTO `tbl_users` (`name`,`email`,`username`,`password`,`status`) VALUES ('Prajwal Adhikari','prajwalbro@hotmail.com','prajwalbro@hotmail.com','$2y$10$3zlF9VeXexzWKRDPZuDio.W7RZIC3tU.cjwMoLzG8ki8bVwAQn1WW','1');");
|
||||
// }
|
||||
// if (!(DB::table('settings')->first())) {
|
||||
// DB::statement("INSERT INTO `tbl_settings` (`title`, `description`, `status`) values ('Bibhuti LMS', '', '1');");
|
||||
// }
|
||||
// if (!(DB::table('articles')->first())) {
|
||||
// DB::statement("INSERT INTO `tbl_articles` (`title`,`alias`, `text`, `status`) VALUES ('Company Profile', 'company-profile','Welcome Article', '1');");
|
||||
// }
|
||||
|
||||
// $initialized = true;
|
||||
// }
|
||||
// }
|
||||
}
|
681
app/Helpers/bibHelper.php
Normal file
681
app/Helpers/bibHelper.php
Normal file
@@ -0,0 +1,681 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\BibClass;
|
||||
use App\Http\Controllers\NepaliDictonary\DictonaryController;
|
||||
use App\Models\Log\ActivityLog;
|
||||
use App\Models\Log\ErrorLog;
|
||||
use App\Models\Log\OperationLog;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
function pre($object, $die = false)
|
||||
{
|
||||
echo "<pre>";
|
||||
print_r($object);
|
||||
echo "</pre>";
|
||||
if ($die) die;
|
||||
}
|
||||
function label($text, $echo = true)
|
||||
{
|
||||
|
||||
|
||||
if ($echo) {
|
||||
echo $text;
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
function template($filepath)
|
||||
{
|
||||
$filepath = env("APP_URL") . "/layout/" . $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)
|
||||
{
|
||||
// Supply conditions as $defaultCondition = "column_name = 'value'";
|
||||
$tableName = strtolower(trim($tableName));
|
||||
$fieldNameToDisplay = trim($fieldNameToDisplay);
|
||||
$fieldNameForValue = trim($fieldNameForValue);
|
||||
$additionalClass = trim($additionalClass);
|
||||
|
||||
$query = DB::table(DB::raw("`$tableName`"))->where('status', '<>', -1);
|
||||
|
||||
if ($defaultCondition) {
|
||||
$query->whereRaw($defaultCondition);
|
||||
}
|
||||
|
||||
$systems = $query->orderBy($fieldNameForValue, 'asc')->pluck($fieldNameToDisplay, $fieldNameForValue);
|
||||
|
||||
?><label class="form-label col-form-label"><?php echo label($displayTextForLabel); ?></label>
|
||||
<select class="form-select <?php echo $additionalClass; ?>" name="<?php echo $HTMLElementName; ?>" data-search="true" aria-label="" <?php if (stripos($additionalClass, 'required') !== false) {
|
||||
echo "REQUIRED";
|
||||
} ?>>
|
||||
<?php if (stripos($additionalClass, 'required') !== false) { ?>
|
||||
<option value=""><?php label("Select Option"); ?></option>
|
||||
<?php } else { ?>
|
||||
<option value="0"><?php label("Select Option"); ?></option>
|
||||
<?php } ?>
|
||||
<?php foreach ($systems as $key => $value) { ?>
|
||||
<option value="<?= $key ?>" <?php echo $defaultValueSelected == $key ? 'selected' : '' ?>><?= $value ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<p id='error_<?php echo $fieldNameForValue; ?>' class='text-danger custom-error'></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
function createImageInput($name, $display = "", $class = "", $default = "")
|
||||
{
|
||||
?>
|
||||
<div class="input-group">
|
||||
<span class="input-group-btn">
|
||||
<a id="<?php echo $name; ?>" data-input="<?php echo $name; ?>_url" data-preview="<?php echo $name; ?>holder" class="btn btn-primary">
|
||||
<i class="fa fa-picture-o"></i> <?php echo ($display != "") ? $display : "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()->id;
|
||||
ActivityLog::create([
|
||||
'user_id' => $user_id,
|
||||
'controllerName' => $controllerName,
|
||||
'methodName' => $methodName,
|
||||
'actionUrl' => request()->fullUrl(),
|
||||
'activity' => $activity,
|
||||
]);
|
||||
}
|
||||
function getOperationNumber()
|
||||
{
|
||||
$startNumber = date('YmdHis') . rand(1000, 9999);
|
||||
$isExists = OperationLog::where('operation_end_no', $startNumber)->first();
|
||||
while ($isExists) {
|
||||
$startNumber = date('YmdHis') . rand(1000, 9999);
|
||||
$isExists = OperationLog::where('operation_end_no', $startNumber)->first();
|
||||
}
|
||||
return $startNumber;
|
||||
}
|
||||
|
||||
function createOperationLog($startOperationNumber, $endOperationNumber, $modelName, $modelId, $operationName, $previousValues, $newValues)
|
||||
{
|
||||
$operationId = getOperationNumber();
|
||||
$user_id = auth()->user()->id;
|
||||
OperationLog::create([
|
||||
'user_id' => $user_id,
|
||||
'operation_start_no' => $startOperationNumber,
|
||||
'operation_end_no' => $endOperationNumber,
|
||||
'model_name' => $modelName,
|
||||
'model_id' => $modelId,
|
||||
'operation_name' => $operationName,
|
||||
'previous_values' => $previousValues ? json_encode($previousValues) : null,
|
||||
'new_values' => $newValues ? json_encode($newValues) : null,
|
||||
]);
|
||||
}
|
||||
function createErrorLog($controllerName, $methodName, $errors)
|
||||
{
|
||||
$user_id = (auth()->user()) ? 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 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);
|
||||
}
|
BIN
app/Http/.DS_Store
vendored
Normal file
BIN
app/Http/.DS_Store
vendored
Normal file
Binary file not shown.
48
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
48
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Auth\LoginRequest;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AuthenticatedSessionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the login view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('pages.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming authentication request.
|
||||
*/
|
||||
public function store(LoginRequest $request): RedirectResponse
|
||||
{
|
||||
$request->authenticate();
|
||||
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->intended(RouteServiceProvider::HOME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy an authenticated session.
|
||||
*/
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
Auth::guard('web')->logout();
|
||||
|
||||
$request->session()->invalidate();
|
||||
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
43
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
43
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ConfirmablePasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the confirm password view.
|
||||
*/
|
||||
public function show(): View
|
||||
{
|
||||
return view('auth.confirm-password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm the user's password.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if (!Auth::guard('web')->validate([
|
||||
'email' => $request->user()->email,
|
||||
'password' => $request->password,
|
||||
])) {
|
||||
throw ValidationException::withMessages([
|
||||
'password' => __('auth.password'),
|
||||
]);
|
||||
}
|
||||
|
||||
$request->session()->put('auth.password_confirmed_at', time());
|
||||
|
||||
return redirect()->intended(RouteServiceProvider::HOME);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EmailVerificationNotificationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Send a new email verification notification.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return redirect()->intended(RouteServiceProvider::HOME);
|
||||
}
|
||||
|
||||
$request->user()->sendEmailVerificationNotification();
|
||||
|
||||
return back()->with('status', 'verification-link-sent');
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class EmailVerificationPromptController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the email verification prompt.
|
||||
*/
|
||||
public function __invoke(Request $request): RedirectResponse|View
|
||||
{
|
||||
return $request->user()->hasVerifiedEmail()
|
||||
? redirect()->intended(RouteServiceProvider::HOME)
|
||||
: view('auth.verify-email');
|
||||
}
|
||||
}
|
61
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
61
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Auth\Events\PasswordReset;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rules;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class NewPasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the password reset view.
|
||||
*/
|
||||
public function create(Request $request): View
|
||||
{
|
||||
return view('auth.reset-password', ['request' => $request]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming new password request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'token' => ['required'],
|
||||
'email' => ['required', 'email'],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
]);
|
||||
|
||||
// Here we will attempt to reset the user's password. If it is successful we
|
||||
// will update the password on an actual user model and persist it to the
|
||||
// database. Otherwise we will parse the error and return the response.
|
||||
$status = Password::reset(
|
||||
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||
function ($user) use ($request) {
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($request->password),
|
||||
'remember_token' => Str::random(60),
|
||||
])->save();
|
||||
|
||||
event(new PasswordReset($user));
|
||||
}
|
||||
);
|
||||
|
||||
// If the password was successfully reset, we will redirect the user back to
|
||||
// the application's home authenticated view. If there is an error we can
|
||||
// redirect them back to where they came from with their error message.
|
||||
return $status == Password::PASSWORD_RESET
|
||||
? redirect()->route('login')->with('status', __($status))
|
||||
: back()->withInput($request->only('email'))
|
||||
->withErrors(['email' => __($status)]);
|
||||
}
|
||||
}
|
31
app/Http/Controllers/Auth/PasswordController.php
Normal file
31
app/Http/Controllers/Auth/PasswordController.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Update the user's password.
|
||||
*/
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validateWithBag('updatePassword', [
|
||||
'current_password' => ['required', 'current_password'],
|
||||
'password' => ['required', Password::defaults(), 'confirmed'],
|
||||
]);
|
||||
|
||||
$request->user()->update([
|
||||
'password' => Hash::make($validated['password']),
|
||||
]);
|
||||
|
||||
return back()->with('status', 'password-updated');
|
||||
}
|
||||
|
||||
|
||||
}
|
44
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
44
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PasswordResetLinkController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the password reset link request view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('auth.forgot-password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming password reset link request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'email' => ['required', 'email'],
|
||||
]);
|
||||
|
||||
// We will send the password reset link to this user. Once we have attempted
|
||||
// to send the link, we will examine the response then see the message we
|
||||
// need to show to the user. Finally, we'll send out a proper response.
|
||||
$status = Password::sendResetLink(
|
||||
$request->only('email')
|
||||
);
|
||||
|
||||
return $status == Password::RESET_LINK_SENT
|
||||
? back()->with('status', __($status))
|
||||
: back()->withInput($request->only('email'))
|
||||
->withErrors(['email' => __($status)]);
|
||||
}
|
||||
}
|
52
app/Http/Controllers/Auth/RegisteredUserController.php
Normal file
52
app/Http/Controllers/Auth/RegisteredUserController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class RegisteredUserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the registration view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('auth.register');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming registration request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:' . User::class],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
]);
|
||||
$request->merge(["username" => $request->email]);
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'username' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
event(new Registered($user));
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
28
app/Http/Controllers/Auth/VerifyEmailController.php
Normal file
28
app/Http/Controllers/Auth/VerifyEmailController.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Auth\Events\Verified;
|
||||
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class VerifyEmailController extends Controller
|
||||
{
|
||||
/**
|
||||
* Mark the authenticated user's email address as verified.
|
||||
*/
|
||||
public function __invoke(EmailVerificationRequest $request): RedirectResponse
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return redirect()->intended(RouteServiceProvider::HOME.'?verified=1');
|
||||
}
|
||||
|
||||
if ($request->user()->markEmailAsVerified()) {
|
||||
event(new Verified($request->user()));
|
||||
}
|
||||
|
||||
return redirect()->intended(RouteServiceProvider::HOME.'?verified=1');
|
||||
}
|
||||
}
|
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;
|
||||
}
|
20
app/Http/Controllers/FileController.php
Normal file
20
app/Http/Controllers/FileController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
public function upload(Request $request)
|
||||
{
|
||||
$file = $request->file('upload');
|
||||
$filename = uniqid() . '_' . $file->getClientOriginalName();
|
||||
Storage::disk('public')->put($filename, file_get_contents($file));
|
||||
$url = asset('storage/' . $filename);
|
||||
return response()->json([
|
||||
'url' => $url,
|
||||
]);
|
||||
}
|
||||
}
|
374
app/Http/Controllers/FormsController.php
Normal file
374
app/Http/Controllers/FormsController.php
Normal file
@@ -0,0 +1,374 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\CustomMailer;
|
||||
use App\Models\Enquiries;
|
||||
use App\Models\Forms;
|
||||
use App\Models\Formsubmissions;
|
||||
use App\Models\Settings;
|
||||
use App\Service\CommonModelService;
|
||||
use Exception;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Log;
|
||||
|
||||
class FormsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Forms $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(FormsController::class, 'index', ' Forms index');
|
||||
$data = Forms::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.forms.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(FormsController::class, 'create', ' Forms create');
|
||||
$TableData = Forms::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.forms.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(FormsController::class, 'store', ' Forms 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_forms')]);
|
||||
$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);
|
||||
});
|
||||
// dd($requestData);
|
||||
$fieldNames = $_POST['fieldNames'];
|
||||
$fieldTypes = $_POST['fieldTypes'];
|
||||
$fieldDefaults = $_POST['fieldDefaults'];
|
||||
$fieldCss = $_POST['fieldCss'];
|
||||
|
||||
$fieldData = [];
|
||||
|
||||
// Loop through the arrays and create an associative array for each field
|
||||
for ($i = 0; $i < count($fieldNames); $i++) {
|
||||
$fieldData[] = [
|
||||
'fieldName' => $fieldNames[$i],
|
||||
'fieldType' => $fieldTypes[$i],
|
||||
'fieldDefault' => $fieldDefaults[$i],
|
||||
'fieldCss' => $fieldCss[$i],
|
||||
];
|
||||
}
|
||||
|
||||
// Convert the field data array to JSON string
|
||||
$requestData["form_fields"] = json_encode($fieldData);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$operationNumber = getOperationNumber();
|
||||
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Forms Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('forms.index')->with('success', 'The Forms created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Forms::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 = Forms::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(FormsController::class, 'show', ' Forms show');
|
||||
$data = Forms::findOrFail($id);
|
||||
|
||||
return view("crud.generated.forms.show", compact('data'));
|
||||
}
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(FormsController::class, 'edit', ' Forms edit');
|
||||
$TableData = Forms::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Forms::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.forms.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.forms.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(FormsController::class, 'update', ' Forms 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);
|
||||
});
|
||||
$fieldNames = $_POST['fieldNames'];
|
||||
$fieldTypes = $_POST['fieldTypes'];
|
||||
$fieldDefaults = $_POST['fieldDefaults'];
|
||||
$fieldCss = $_POST['fieldCss'];
|
||||
|
||||
$fieldData = [];
|
||||
|
||||
// Loop through the arrays and create an associative array for each field
|
||||
for ($i = 0; $i < count($fieldNames); $i++) {
|
||||
$fieldData[] = [
|
||||
'fieldName' => $fieldNames[$i],
|
||||
'fieldAlias' => slugify($fieldNames[$i]),
|
||||
'fieldType' => $fieldTypes[$i],
|
||||
'fieldDefault' => $fieldDefaults[$i],
|
||||
'fieldCss' => $fieldCss[$i],
|
||||
];
|
||||
}
|
||||
|
||||
// Convert the field data array to JSON string
|
||||
$requestData["form_fields"] = json_encode($fieldData);
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('form_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(FormsController::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 Forms updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('forms.index')->with('success','The Forms updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Forms updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(FormsController::class, 'destroy', ' Forms destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(FormsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Forms Deleted Successfully.'], 200);
|
||||
}
|
||||
|
||||
// public function submitenquiry(Request $r)
|
||||
// {
|
||||
// // dd($r->all());
|
||||
// $validator = Validator::make($r->all(), [
|
||||
// 'g-recaptcha-response' => 'required',
|
||||
// ]);
|
||||
|
||||
// if ($validator->fails()) {
|
||||
// return redirect()
|
||||
// ->route('register')
|
||||
// ->withErrors($validator)
|
||||
// ->withInput();
|
||||
// }
|
||||
// $r = $r->all();
|
||||
// $captcha = $r['g-recaptcha-response'];
|
||||
// // dd($captcha);
|
||||
|
||||
// $response = Http::get("https://www.google.com/recaptcha/api/siteverify", [
|
||||
// 'secret' => env('RECAPTCHA_SECRET_KEY'),
|
||||
// 'secret' => SITEVARS->recaptcha_secret_key,
|
||||
// 'response' => $captcha,
|
||||
// ]);
|
||||
// $response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . env("RECAPTCHA_SECRET_KEY") . "&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']), true);
|
||||
// dd($response);
|
||||
|
||||
// $response = $response->json(); //['success'];
|
||||
// if ($response['success'] == false) {
|
||||
// return response()->json(['success' => false, 'message' => 'Captcha Validation Error. Refresh and submit the form again']);
|
||||
// }
|
||||
|
||||
// $FormData = array(
|
||||
// "name" => isset($r['name']) ? $r['name'] : "",
|
||||
// "email" => isset($r['email']) ? $r['email'] : "",
|
||||
// "phone" => isset($r['phone']) ? $r['phone'] : "",
|
||||
// "preparationclassoffers_id" => isset($r['preparationclassoffers_id']) ? $r['preparationclassoffers_id'] : "",
|
||||
// );
|
||||
|
||||
// dd($FormData);
|
||||
|
||||
// DB::table('enquiries')->insert($FormData);
|
||||
// $mailer = new CustomMailer($FormData);
|
||||
// Mail::to("deepakstha123321@gmail.com")->send($mailer->enquiryform());
|
||||
// if (!empty(SITEVARS->email)) {
|
||||
// Mail::to(SITEVARS->email)->send($mailer->enquiryform());
|
||||
// }
|
||||
|
||||
// Mail::to($r['email'])->send($mailer->enquiryresponse());
|
||||
|
||||
// // Respond back to the customer
|
||||
// return response()->json(['success' => true, 'message' => 'Form submitted successfully!']);
|
||||
// }
|
||||
|
||||
public function submitEnquiry(Request $r)
|
||||
{
|
||||
$validator = Validator::make($r->all(), [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'phone' => 'required',
|
||||
'preparationclassoffers_id' => 'required_if:enquiry_type,class',
|
||||
'message' => 'required_if:enquiry_type,contact',
|
||||
'g-recaptcha-response' => 'required',
|
||||
'agree' => 'required',
|
||||
], [
|
||||
'name' => 'Name is required.',
|
||||
'preparationclassoffers_id' => 'Select at least one classs.',
|
||||
'g-recaptcha-response.required' => 'Please complete the security verification.',
|
||||
'email.required' => 'Email is required.',
|
||||
'email.email' => 'Must be a valid email address.',
|
||||
'phone.required' => 'Phone number is required.',
|
||||
'agree.required' => 'You must agree to the terms and conditions.',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json($validator->errors(), 422);
|
||||
}
|
||||
|
||||
$setting = Settings::where('status', 1)->first();
|
||||
|
||||
// Validate reCAPTCHA response
|
||||
$captcha = $r['g-recaptcha-response'];
|
||||
$response = Http::get("https://www.google.com/recaptcha/api/siteverify", [
|
||||
'secret' => $setting->recaptcha_secret_key,
|
||||
'response' => $captcha,
|
||||
]);
|
||||
$responseData = $response->json();
|
||||
|
||||
if (!$responseData['success']) {
|
||||
return response()->json(['error' => false, 'message' => 'Captcha validation failed'], 422);
|
||||
}
|
||||
|
||||
$FormData = [
|
||||
"name" => $r->input('name'),
|
||||
"email" => $r->input('email'),
|
||||
"phone" => $r->input('phone'),
|
||||
"enquiry_type" => $r->input('enquiry_type'),
|
||||
];
|
||||
|
||||
if ($r->enquiry_type == "contact") {
|
||||
$FormData['message'] = $r->input('message');
|
||||
} else {
|
||||
$FormData['preparationclassoffers_id'] = $r->input('preparationclassoffers_id');
|
||||
}
|
||||
|
||||
Enquiries::create($FormData);
|
||||
|
||||
$mailer = new CustomMailer($FormData);
|
||||
if (!empty(SITEVARS->email)) {
|
||||
Mail::to(SITEVARS->email)->send($mailer->enquiryform());
|
||||
} else {
|
||||
Mail::to("info@access-skills.com")->send($mailer->enquiryform());
|
||||
}
|
||||
|
||||
Mail::to($r['email'])->send($mailer->enquiryresponse());
|
||||
|
||||
return response()->json(['success' => true, 'message' => 'Your registeration form submitted successfully']);
|
||||
}
|
||||
|
||||
public function handleFormSubmission(Request $r)
|
||||
{
|
||||
$r = $r->all();
|
||||
$FormID = $r['form_id'];
|
||||
$FormFields = Forms::where("form_id", $FormID)->pluck('form_fields')[0];
|
||||
$tableName = 'formsubmissions';
|
||||
if (!Schema::hasTable($tableName)) {
|
||||
Schema::create($tableName, function (Blueprint $table) {
|
||||
$table->increments('formsubmission_id');
|
||||
$table->integer('forms_id')->unsigned();
|
||||
$table->json('submitted_values');
|
||||
$table->integer('display_order')->default(0);
|
||||
$table->integer('status')->default(1);
|
||||
$table->timestamps();
|
||||
$table->integer('createdby')->nullable();
|
||||
$table->integer('updatedby')->nullable();
|
||||
});
|
||||
}
|
||||
$FormFields = json_decode($FormFields);
|
||||
$FilledForm = array();
|
||||
foreach ($FormFields as $FormField) {
|
||||
$fieldData = new \stdClass;
|
||||
$fieldData->fieldName = $FormField->fieldName;
|
||||
$fieldData->fieldType = $FormField->fieldType;
|
||||
$fieldData->fieldValue = isset($r[strtolower($FormField->fieldAlias)]) ? $r[strtolower($FormField->fieldAlias)] : "";
|
||||
$FilledForm[] = $fieldData;
|
||||
}
|
||||
$FilledForm = json_encode($FilledForm);
|
||||
$formSubmission = new FormSubmissions();
|
||||
$formSubmission->forms_id = $FormID;
|
||||
$formSubmission->submitted_values = $FilledForm;
|
||||
$formSubmission->save();
|
||||
return redirect()->back()->with('success', 'Form submitted successfully!');
|
||||
}
|
||||
}
|
180
app/Http/Controllers/FormsubmissionsController.php
Normal file
180
app/Http/Controllers/FormsubmissionsController.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Formsubmissions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class FormsubmissionsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Formsubmissions $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(FormsubmissionsController::class, 'index', ' Formsubmissions index');
|
||||
$data = Formsubmissions::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.formsubmissions.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(FormsubmissionsController::class, 'create', ' Formsubmissions create');
|
||||
$TableData = Formsubmissions::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.formsubmissions.create",compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(FormsubmissionsController::class, 'store', ' Formsubmissions 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_formsubmissions')]);
|
||||
$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(FormsubmissionsController::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 Formsubmissions Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('formsubmissions.index')->with('success','The Formsubmissions created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Formsubmissions::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 = Formsubmissions::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(FormsubmissionsController::class, 'show', ' Formsubmissions show');
|
||||
$data = Formsubmissions::findOrFail($id);
|
||||
|
||||
return view("crud.generated.formsubmissions.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(FormsubmissionsController::class, 'edit', ' Formsubmissions edit');
|
||||
$TableData = Formsubmissions::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Formsubmissions::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.formsubmissions.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.formsubmissions.edit", compact('data','TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(FormsubmissionsController::class, 'update', ' Formsubmissions 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('formsubmission_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(FormsubmissionsController::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 Formsubmissions updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('formsubmissions.index')->with('success','The Formsubmissions updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Formsubmissions updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(FormsubmissionsController::class, 'destroy', ' Formsubmissions destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(FormsubmissionsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Formsubmissions Deleted Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
1284
app/Http/Controllers/GeneralFormController.php
Normal file
1284
app/Http/Controllers/GeneralFormController.php
Normal file
File diff suppressed because it is too large
Load Diff
237
app/Http/Controllers/MenuitemsController.php
Normal file
237
app/Http/Controllers/MenuitemsController.php
Normal file
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Menuitems;
|
||||
use App\Service\CommonModelService;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Log;
|
||||
|
||||
class MenuitemsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected static $menuTypes;
|
||||
public function __construct(Menuitems $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
self::initializeController();
|
||||
}
|
||||
public function initializeController()
|
||||
{
|
||||
$menuTypes = [
|
||||
['display' => "Articles", 'value' => "tbl_articles"],
|
||||
['display' => "Country", 'value' => "tbl_countries"],
|
||||
['display' => "Country Articles", 'value' => "tbl_countryarticles"],
|
||||
['display' => "Events", 'value' => "tbl_events"],
|
||||
['display' => "Faqs", 'value' => "tbl_faqs"],
|
||||
['display' => "Institutions", 'value' => "tbl_institutions"],
|
||||
['display' => "News/Blogs", 'value' => "tbl_news"],
|
||||
['display' => "Preparation class", 'value' => "tbl_preparationclasses"],
|
||||
['display' => "Testimonial", 'value' => "tbl_testimonials"],
|
||||
|
||||
['display' => "Custom", 'value' => ""],
|
||||
];
|
||||
|
||||
foreach ($menuTypes as &$menuType) {
|
||||
switch ($menuType['value']) {
|
||||
case 'tbl_articles':
|
||||
$menuType['values'] = json_encode(DB::select("select article_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_countries':
|
||||
$menuType['values'] = json_encode(DB::select("select country_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_countryarticles':
|
||||
$menuType['values'] = json_encode(DB::select("select article_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_events':
|
||||
$menuType['values'] = json_encode(DB::select("select event_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_faqs':
|
||||
$menuType['values'] = json_encode(DB::select("select faq_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_institutions':
|
||||
$menuType['values'] = json_encode(DB::select("select institution_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_news':
|
||||
$menuType['values'] = json_encode(DB::select("select news_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_preparationclasses':
|
||||
$menuType['values'] = json_encode(DB::select("select preparationclass_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_testimonials':
|
||||
$menuType['values'] = json_encode(DB::select("select testimonial_id as value, `by` as display from " . $menuType['value'] . " where status=1 order by `by`"));
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
$menuType['values'] = "";
|
||||
}
|
||||
}
|
||||
self::$menuTypes = $menuTypes;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(MenuitemsController::class, 'index', ' Menuitems index');
|
||||
$data = Menuitems::where('status', '<>', -1);
|
||||
$menulocation = $request->query("menulocation");
|
||||
if (null != $menulocation) {
|
||||
$data = $data->where('menulocations_id', $menulocation);
|
||||
}
|
||||
$data = $data->orderBy('display_order')->get();
|
||||
return view("crud.generated.menuitems.index", compact('data', 'menulocation'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(MenuitemsController::class, 'create', ' Menuitems create');
|
||||
$TableData = Menuitems::where('status', '<>', -1);
|
||||
$menulocation = $request->query("menulocation");
|
||||
if (null != $menulocation) {
|
||||
$TableData = $TableData->where('menulocations_id', $menulocation);
|
||||
}
|
||||
$TableData = $TableData->orderBy('display_order')->get();
|
||||
$menuTypes = self::$menuTypes;
|
||||
return view("crud.generated.menuitems.create", compact('TableData', 'menuTypes', 'menulocation'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(MenuitemsController::class, 'store', ' Menuitems 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_menuitems')]);
|
||||
$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(MenuitemsController::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 Menuitems Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->back()->with('success', 'The Menuitems Added successfully.');
|
||||
// return redirect()->route('menuitems.index')->with('success', 'The Menuitems created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Menuitems::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 = Menuitems::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(MenuitemsController::class, 'show', ' Menuitems show');
|
||||
$data = Menuitems::findOrFail($id);
|
||||
|
||||
return view("crud.generated.menuitems.show", compact('data'));
|
||||
}
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(MenuitemsController::class, 'edit', ' Menuitems edit');
|
||||
$TableData = Menuitems::where('status', '<>', -1);
|
||||
$menulocation = $request->query("menulocation");
|
||||
if (null != $menulocation) {
|
||||
$TableData = $TableData->where('menulocations_id', $menulocation);
|
||||
}
|
||||
$TableData = $TableData->orderBy('display_order')->get();
|
||||
$menuTypes = self::$menuTypes;
|
||||
$data = Menuitems::findOrFail($id);
|
||||
return view("crud.generated.menuitems.edit", compact('data', 'TableData', 'menulocation', 'menuTypes'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(MenuitemsController::class, 'update', ' Menuitems 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);
|
||||
});
|
||||
// dd($requestData);
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(MenuitemsController::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 Menuitems updated Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('menuitems.index')->with('success', 'The Menuitems updated Successfully.');
|
||||
// return redirect()->back()->with('success', 'The Menuitems updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(MenuitemsController::class, 'destroy', ' Menuitems destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(MenuitemsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Menuitems Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
180
app/Http/Controllers/MenulocationsController.php
Normal file
180
app/Http/Controllers/MenulocationsController.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Menulocations;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class MenulocationsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Menulocations $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(MenulocationsController::class, 'index', ' Menulocations index');
|
||||
$data = Menulocations::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.menulocations.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(MenulocationsController::class, 'create', ' Menulocations create');
|
||||
$TableData = Menulocations::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.menulocations.create",compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(MenulocationsController::class, 'store', ' Menulocations 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_menulocations')]);
|
||||
$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(MenulocationsController::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 Menulocations Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('menulocations.index')->with('success','The Menulocations created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Menulocations::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 = Menulocations::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(MenulocationsController::class, 'show', ' Menulocations show');
|
||||
$data = Menulocations::findOrFail($id);
|
||||
|
||||
return view("crud.generated.menulocations.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(MenulocationsController::class, 'edit', ' Menulocations edit');
|
||||
$TableData = Menulocations::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Menulocations::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.menulocations.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.menulocations.edit", compact('data','TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(MenulocationsController::class, 'update', ' Menulocations 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('menulocation_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(MenulocationsController::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 Menulocations updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('menulocations.index')->with('success','The Menulocations updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Menulocations updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(MenulocationsController::class, 'destroy', ' Menulocations destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(MenulocationsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Menulocations Deleted 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
180
app/Http/Controllers/ShortcodesController.php
Normal file
180
app/Http/Controllers/ShortcodesController.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Shortcodes;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class ShortcodesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Shortcodes $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(ShortcodesController::class, 'index', ' Shortcodes index');
|
||||
$data = Shortcodes::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.shortcodes.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(ShortcodesController::class, 'create', ' Shortcodes create');
|
||||
$TableData = Shortcodes::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.shortcodes.create",compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(ShortcodesController::class, 'store', ' Shortcodes 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_shortcodes')]);
|
||||
$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(ShortcodesController::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 Shortcodes Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('shortcodes.index')->with('success','The Shortcodes created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Shortcodes::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 = Shortcodes::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(ShortcodesController::class, 'show', ' Shortcodes show');
|
||||
$data = Shortcodes::findOrFail($id);
|
||||
|
||||
return view("crud.generated.shortcodes.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ShortcodesController::class, 'edit', ' Shortcodes edit');
|
||||
$TableData = Shortcodes::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Shortcodes::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.shortcodes.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.shortcodes.edit", compact('data','TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ShortcodesController::class, 'update', ' Shortcodes 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('shortcode_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(ShortcodesController::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 Shortcodes updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('shortcodes.index')->with('success','The Shortcodes updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Shortcodes updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(ShortcodesController::class, 'destroy', ' Shortcodes destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(ShortcodesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Shortcodes Deleted Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
18
app/Http/Controllers/WebsiteController.php
Normal file
18
app/Http/Controllers/WebsiteController.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class WebsiteController extends Controller
|
||||
{
|
||||
private $path;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->path = config('app.client_path');
|
||||
}
|
||||
|
||||
public function home(){
|
||||
// return view($this->path.'home');
|
||||
return ('home');
|
||||
}
|
||||
}
|
68
app/Http/Kernel.php
Normal file
68
app/Http/Kernel.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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,
|
||||
],
|
||||
|
||||
'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 instead of class names 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,
|
||||
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::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 = [
|
||||
//
|
||||
];
|
||||
}
|
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 = [
|
||||
//
|
||||
];
|
||||
}
|
85
app/Http/Requests/Auth/LoginRequest.php
Normal file
85
app/Http/Requests/Auth/LoginRequest.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use Illuminate\Auth\Events\Lockout;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'email' => ['required', 'string', 'email'],
|
||||
'password' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate the request's credentials.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function authenticate(): void
|
||||
{
|
||||
$this->ensureIsNotRateLimited();
|
||||
|
||||
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
|
||||
RateLimiter::hit($this->throttleKey());
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => trans('auth.failed'),
|
||||
]);
|
||||
}
|
||||
|
||||
RateLimiter::clear($this->throttleKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the login request is not rate limited.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function ensureIsNotRateLimited(): void
|
||||
{
|
||||
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event(new Lockout($this));
|
||||
|
||||
$seconds = RateLimiter::availableIn($this->throttleKey());
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => trans('auth.throttle', [
|
||||
'seconds' => $seconds,
|
||||
'minutes' => ceil($seconds / 60),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rate limiting throttle key for the request.
|
||||
*/
|
||||
public function throttleKey(): string
|
||||
{
|
||||
return Str::transliterate(Str::lower($this->input('email')).'|'.$this->ip());
|
||||
}
|
||||
}
|
23
app/Http/Requests/ProfileUpdateRequest.php
Normal file
23
app/Http/Requests/ProfileUpdateRequest.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ProfileUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['string', 'max:255'],
|
||||
'email' => ['email', 'max:255', Rule::unique(User::class)->ignore($this->user()->id)],
|
||||
];
|
||||
}
|
||||
}
|
46
app/Mail/CustomMailer.php
Normal file
46
app/Mail/CustomMailer.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CustomMailer extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $formData;
|
||||
|
||||
public function __construct($formData)
|
||||
{
|
||||
$this->formData = $formData;
|
||||
}
|
||||
|
||||
public function enquiryform()
|
||||
{
|
||||
$viewPath = 'accessskills.emails.enquiry-submitted';
|
||||
|
||||
if (view()->exists($viewPath)) {
|
||||
return $this->subject('Received a new online enquiry from our website.')
|
||||
->markdown($viewPath, $this->formData);
|
||||
} else {
|
||||
return $this->subject('Received a new online enquiry from our website.')
|
||||
->view('emails.enquiry-submitted', $this->formData);
|
||||
}
|
||||
}
|
||||
|
||||
public function enquiryresponse()
|
||||
{
|
||||
$viewPath = 'accessskills.emails.enquiry-response';
|
||||
|
||||
if (view()->exists($viewPath)) {
|
||||
return $this->subject('Thank you from ' . env('APP_NAME'))
|
||||
->markdown($viewPath, $this->formData);
|
||||
} else {
|
||||
return $this->subject('Thank you from ' . env('APP_NAME'))
|
||||
->view('emails.enquiry-response', $this->formData);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
54
app/Mail/Registration.php
Normal file
54
app/Mail/Registration.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Registration extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $details;
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($details)
|
||||
{
|
||||
$this->details = $details;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Registration',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'ved.email.registration',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
27
app/Models/Enquiries.php
Normal file
27
app/Models/Enquiries.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Enquiries extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $primaryKey = 'enquiry_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'phone',
|
||||
'email',
|
||||
'enquiry_type',
|
||||
'message',
|
||||
'preparationclassoffers_id',
|
||||
];
|
||||
|
||||
public function class ()
|
||||
{
|
||||
return $this->belongsTo(Preparationclassoffers::class, 'preparationclassoffers_id');
|
||||
}
|
||||
}
|
36
app/Models/Log/ActivityLog.php
Normal file
36
app/Models/Log/ActivityLog.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Log;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ActivityLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
protected $primaryKey = 'activity_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'controllerName',
|
||||
'methodName',
|
||||
'actionUrl',
|
||||
'activity',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
|
||||
protected $appends = ['user_name'];
|
||||
|
||||
public function getUserNameAttribute()
|
||||
{
|
||||
$user = User::find($this->user_id);
|
||||
return $user ? $user->name : '';
|
||||
}
|
||||
}
|
31
app/Models/Log/ErrorLog.php
Normal file
31
app/Models/Log/ErrorLog.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Log;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ErrorLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'controller_name',
|
||||
'method_name',
|
||||
'errors',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
|
||||
protected $appends = [];
|
||||
|
||||
|
||||
}
|
37
app/Models/Log/LoginLog.php
Normal file
37
app/Models/Log/LoginLog.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Log;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LoginLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
protected $primaryKey = 'login_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'ip',
|
||||
'user_agent',
|
||||
'type',
|
||||
'login_at',
|
||||
'logout_at',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
|
||||
protected $appends = ['user_name'];
|
||||
|
||||
public function getUserNameAttribute()
|
||||
{
|
||||
$user = User::find($this->user_id);
|
||||
return $user ? $user->name : '';
|
||||
}
|
||||
}
|
40
app/Models/Log/OperationLog.php
Normal file
40
app/Models/Log/OperationLog.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Log;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OperationLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
protected $primaryKey = 'operation_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'refNo',
|
||||
'user_id',
|
||||
'operation_start_no',
|
||||
'operation_end_no',
|
||||
'model_name',
|
||||
'model_id',
|
||||
'operation_name',
|
||||
'previous_values',
|
||||
'new_values',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
|
||||
// protected $appends = ['operation_by'];
|
||||
|
||||
// public function getOperationByAttribute()
|
||||
// {
|
||||
// $user = User::find($this->user_id);
|
||||
// return $user ? $user->name : '';
|
||||
// }
|
||||
}
|
71
app/Models/Menuitems.php
Normal file
71
app/Models/Menuitems.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Menuitems extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'menu_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'parent_menu',
|
||||
'menulocations_id',
|
||||
'title',
|
||||
'alias',
|
||||
'type',
|
||||
'ref',
|
||||
'target',
|
||||
'display_order',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Menuitems::class, 'parent_menu')->where('status', 1);
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(Menuitems::class, 'parent_menu')->orderBy('display_order')->where('status', 1);
|
||||
}
|
||||
|
||||
public function subchildren()
|
||||
{
|
||||
return $this->hasMany(Menuitems::class, 'parent_menu')
|
||||
->where('status', 1)
|
||||
->orderBy('display_order')
|
||||
->with('children');
|
||||
}
|
||||
}
|
48
app/Models/Menulocations.php
Normal file
48
app/Models/Menulocations.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Menulocations extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'menulocation_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable =[
|
||||
'title',
|
||||
'alias',
|
||||
'display_order',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
80
app/Models/Settings.php
Normal file
80
app/Models/Settings.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Settings extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'setting_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'description',
|
||||
'url1',
|
||||
'url2',
|
||||
'email',
|
||||
'location',
|
||||
'phone',
|
||||
'secondary_phone',
|
||||
'google_map',
|
||||
'fb',
|
||||
'insta',
|
||||
'twitter',
|
||||
'tiktok',
|
||||
'youtube',
|
||||
'working_days',
|
||||
'working_hours',
|
||||
'leave_days',
|
||||
'primary_logo',
|
||||
'secondary_logo',
|
||||
'thumb',
|
||||
'icon',
|
||||
'og_image',
|
||||
'no_image',
|
||||
'copyright_text',
|
||||
'content1',
|
||||
'content2',
|
||||
'content3',
|
||||
'seo_title',
|
||||
'seo_description',
|
||||
'seo_keywords',
|
||||
'og_tags',
|
||||
'display_order',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
'recaptcha_secret_key',
|
||||
'recaptcha_site_key'
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
50
app/Models/Shortcodes.php
Normal file
50
app/Models/Shortcodes.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Shortcodes extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'shortcode_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable =[
|
||||
'title',
|
||||
'alias',
|
||||
'text',
|
||||
'description',
|
||||
'display_order',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
53
app/Models/Sitemenus.php
Normal file
53
app/Models/Sitemenus.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Sitemenus extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'menu_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable =[
|
||||
'parent_menu',
|
||||
'menulocations_id',
|
||||
'title',
|
||||
'alias',
|
||||
'type',
|
||||
'ref',
|
||||
'target',
|
||||
'display_order',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
46
app/Models/User.php
Normal file
46
app/Models/User.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'username',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* 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',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
50
app/Providers/AppServiceProvider.php
Normal file
50
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Providers\ShortcodeProcessor;
|
||||
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton(ShortcodeProcessor::class, function ($app) {
|
||||
return new ShortcodeProcessor();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Blade::directive('shortcode', function ($expression) {
|
||||
list($shortcodeName, $shortcodeAttributes) = explode(',', $expression, 2);
|
||||
return "<?php echo view('shortcodes.$shortcodeName', $shortcodeAttributes)->render(); ?>";
|
||||
});
|
||||
|
||||
Blade::directive('processshortcodes', function ($expression) {
|
||||
return "<?php echo app('App\Providers\ShortcodeProcessor')->process($expression); ?>";
|
||||
});
|
||||
|
||||
Blade::directive('customshortcode', function ($expression) {
|
||||
return "<?php echo app('App\Providers\ShortcodeProcessor')->processShortcodes($expression); ?>";
|
||||
});
|
||||
}
|
||||
|
||||
public function processShortcodes($content)
|
||||
{
|
||||
return preg_replace_callback('/\[([\w_]+)([^\]]*)\]/', function ($matches) {
|
||||
$shortcodeName = $matches[1];
|
||||
$shortcodeAttributes = str::of($matches[2])->trim()->replace("'", "\"")->__toString();
|
||||
return "@shortcode('$shortcodeName', $shortcodeAttributes)";
|
||||
}, $content);
|
||||
}
|
||||
}
|
26
app/Providers/AuthServiceProvider.php
Normal file
26
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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 = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
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;
|
||||
}
|
||||
}
|
40
app/Providers/RouteServiceProvider.php
Normal file
40
app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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 your application's "home" route.
|
||||
*
|
||||
* 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
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
}
|
21
app/Providers/ShortcodeProcessor.php
Normal file
21
app/Providers/ShortcodeProcessor.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ShortcodeProcessor
|
||||
{
|
||||
public function process($content)
|
||||
{
|
||||
return preg_replace_callback('/\[([\w_]+)([^\]]*)\]/', function ($matches) {
|
||||
$shortcodeName = $matches[1];
|
||||
$shortcodeAttributes = Str::of($matches[2])->trim()->replace("'", "\"")->__toString();
|
||||
return "@shortcode('$shortcodeName', $shortcodeAttributes)";
|
||||
}, $content);
|
||||
}
|
||||
|
||||
public function processShortcodes($content)
|
||||
{
|
||||
return $this->process($content);
|
||||
}
|
||||
}
|
220
app/Service/CommonModelService.php
Normal file
220
app/Service/CommonModelService.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
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 = 1;
|
||||
}
|
||||
});
|
||||
|
||||
// updating updated_by when model is updated
|
||||
static::updating(function ($model) {
|
||||
if (!$model->isDirty('updatedBy')) {
|
||||
$model->updatedBy = auth()->user() ? auth()->user()->id : 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
17
app/View/Components/AppLayout.php
Normal file
17
app/View/Components/AppLayout.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AppLayout extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represents the component.
|
||||
*/
|
||||
public function render(): View
|
||||
{
|
||||
return view('layouts.app');
|
||||
}
|
||||
}
|
17
app/View/Components/GuestLayout.php
Normal file
17
app/View/Components/GuestLayout.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class GuestLayout extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represents the component.
|
||||
*/
|
||||
public function render(): View
|
||||
{
|
||||
return view('layouts.guest');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user