first commit

This commit is contained in:
Tanchohang 2024-04-16 15:43:24 +05:45
commit b49e06fa93
4387 changed files with 543889 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

15
.editorconfig Normal file
View File

@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2

5
.gitattributes vendored Normal file
View File

@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore

15
.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
composer.lock
.htaccess

13
.styleci.yml Normal file
View File

@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- no_unused_imports
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true

0
.vscode/ftp-sync.json vendored Normal file
View File

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"editor.bracketPairColorization.independentColorPoolPerBracketType": true
}

63
11.env Normal file
View File

@ -0,0 +1,63 @@
APP_NAME="Bibhuti LMS"
APP_ENV=local
APP_KEY=base64:gCqqRlco1ZAp8r2oR4q9rCLVZILnnEjTQfveHPeGbCs=
APP_DEBUG=true
APP_URL=http://localhost/projects/Bibhuti-LMS
DEFAULT_STORAGE_PATH=wri
CLIENT_PATH=wri
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=bib_lmswri
DB_USERNAME=root
DB_PASSWORD=
DB_TABLE_PREFIX=tbl_
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=email-smtp.eu-west-1.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=AKIAXVYPHPTCT3HPSGLS
MAIL_PASSWORD=BFQCgv4o8MxdSQYAagijuzf2IJnwIuqMyAMXn0DdOYZK
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="webmaster@wrieducation.com/"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
VITE_APP_NAME="${APP_NAME}"
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

62
README.md Normal file
View File

@ -0,0 +1,62 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
### Premium Partners
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/)**
- **[OP.GG](https://op.gg)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

BIN
app/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,48 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class RunQueueJob extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'run:queue';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Run the Queue for Send mails';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
\Log::info("Cron is working fine!");
$myfile = fopen(__DIR__."/newfile.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
$txt = "Jane Doe\n";
fwrite($myfile, $txt);
fclose($myfile);
}
}

27
app/Console/Kernel.php Normal file
View 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');
}
}

View 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) {
//
});
}
}

View 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
View 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, "", "", "");
}
}
}
}

528
app/Helpers/CCMS.php Normal file
View File

@ -0,0 +1,528 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CCMS
{
public function __construct()
{
$this->initDB();
}
//CONSULTANCY RELATED TEMP FUNCTIONS
public static function getFAQs()
{
$Rows = DB::table("faqs")
->where("status", 1)
->orderBy("display_order")->get();
return $Rows;
}
public static function getServices()
{
$Rows = DB::table("services")
->where("status", 1)
->orderBy("display_order")->get();
return $Rows;
}
public static function getSliders()
{
$Rows = DB::table("sliders")
->where("status", 1)
->orderBy("display_order")->get();
return $Rows;
}
public static function getAbout()
{
$Rows = DB::table("articles")
->where("status", 1)
->where("parent_article", 0)
->orderBy("display_order")->get();
return $Rows;
}
public static function getArticlesByParentAlias($alias)
{
$Rows = DB::table("articles")
->where("status", 1)
->where("parent_article", function ($query) use ($alias) {
$query->select('article_id')
->from('articles')
->where('alias', $alias);
})
->orderBy("display_order")
->get();
return $Rows;
}
public static function getContacts($index = -1)
{
$Rows = DB::table("contacts")->where("status", 1)->orderBy("display_order")->get();
if ($index != -1) return $Rows[$index];
return $Rows;
}
public static function getContactByBranch($branches_id)
{
$Rows = DB::table("contacts")->where("status", 1)->where("branches_id", $branches_id)->orderBy("display_order")->first();
return $Rows;
}
public static function getQuickLinks()
{
$Rows = DB::table("quicklinks")->where("status", 1)->orderBy("display_order")->get();
return $Rows;
}
public static function getBranches()
{
$Rows = DB::table("branches")->where("status", 1)->orderBy("display_order")->get();
return $Rows;
}
public static function getBranchByID($branches_id)
{
$Row = DB::table("branches")->where("status", 1)->where("branch_id", $branches_id)->orderBy("display_order")->first();
return $Row;
}
public static function getStudyAbroad($limit = null)
{
$Rows = DB::table("countries")
->where("status", 1)
->orderBy("display_order");
if ($limit !== null) {
$Rows->limit($limit);
}
$Rows = $Rows->get();
return $Rows;
}
public static function getTestPreparations($limit = null)
{
$query = DB::table("preparationclasses")
->where("status", 1)
->where("parent_preparationclass", 0)
->orderBy("display_order");
if ($limit !== null) {
$query->limit($limit);
}
$rows = $query->get();
return $rows;
}
public static function getResources()
{
$Rows = DB::table("resources")
->where("status", 1)
->where("parent_resource", 0)
->orderBy("display_order")->get();
return $Rows;
}
public static function getEvents()
{
$Rows = DB::table("events")
->where("status", 1)
->orderBy("display_order")->get();
return $Rows;
}
public static function getNews()
{
$Rows = DB::table("news")
->where("status", 1)
->orderBy("display_order")->get();
return $Rows;
}
public static function getTestimonials()
{
$Rows = DB::table("testimonials")->where("status", 1)->orderBy("display_order")->get();
return $Rows;
}
public static function getTestimonialsByBranchAlias($alias)
{
$Branch = DB::table("branches")->where("alias", $alias)->first();
if ($Branch) {
$Rows = DB::table("testimonials")
->where("status", 1)
->where("branches_id", $Branch->branch_id)
->orderBy("display_order")->get();
return $Rows;
} else {
die("Branch not found");
}
}
public static function getVisas()
{
$Rows = DB::table("visas")->where("status", 1)->orderBy("display_order")->get();
return $Rows;
}
public static function getVisasByBranchAlias($alias)
{
$Branch = DB::table("branches")->where("alias", $alias)->first();
if ($Branch) {
$Rows = DB::table("visas")
->where("status", 1)
->where("branches_id", $Branch->branch_id)
->orderBy("display_order")->get();
return $Rows;
} else {
die("Branch not found");
}
}
public static function getBlogs()
{
$Rows = DB::table("blogs")->where("status", 1)->orderBy("display_order")->get();
return $Rows;
}
public static function getGalleries()
{
$Rows = DB::table('galleries')
->where('status', 1)->get();
foreach ($Rows as $R) {
$R->Photos = DB::table("photos")->where("galleries_id", $R->gallery_id)->where("status", 1)->orderBy("display_order")->get();
}
return $Rows;
}
public static function getCustomFields($start = 0, $limit = null)
{
$query = DB::table("customfields")
->where("status", 1)
->orderBy("display_order");
if ($limit !== null) {
$query->offset($start)->limit($limit);
}
$rows = $query->get();
return $rows;
}
public static function getTopReasonsForStudyDestination($alias, $limit = null)
{
$reasons_alias = 'top-reasons-to-' . $alias;
$Rows = DB::table("countryarticles")
->where("status", 1)
->where("countries_id", function ($query) use ($alias) {
$query->select("country_id")
->from("countries")
->where("alias", $alias);
})
->where("parent_article", function ($query) use ($reasons_alias) {
$query->select("article_id")
->from("countryarticles")
->where("alias", $reasons_alias);
})
->orderBy("display_order")
->when($limit, function ($query) use ($limit) {
return $query->limit($limit);
})
->get();
return $Rows;
}
public static function getRepresentingInstitutionsByCountry($alias, $limit = null)
{
$Rows = DB::table("institutions")->where("status", 1)
->where("countries_id", function ($query) use ($alias) {
$query->select("country_id")
->from("countries")
->where("alias", $alias);
})
->orderBy("display_order")
->when($limit, function ($query) use ($limit) {
return $query->limit($limit);
})
->get();
return $Rows;
}
//END TEMP FUNCTIONS
public static function createMenuLink($text, $URL)
{
$isActive = request()->fullUrl() == $URL;
$activeClass = $isActive ? 'active' : '';
?>
<li>
<a class="nav-link menu-link <?php echo $activeClass; ?>" href="<?php echo $URL; ?>"><i class="ri-file-text-line "></i> <span data-key="t-landing"><?php echo $text; ?></span></a>
</li>
<?php
}
public static function getslider()
{
$Gallery = DB::table('sliders')->where('status', 1)->orderBy('display_order')->get();
return $Gallery;
}
public static function getarticle($alias = '')
{
$t = "select * from tbl_articles where status=1";
if ($alias != '') {
$t .= " and alias='$alias'";
// echo $t;die;
$Aboutus = DB::select($t)[0];
$q = "select * from tbl_articles where parent_article=$Aboutus->article_id";
$Aboutus->children = DB::select($q);
} else {
$Aboutus = DB::select($t);
}
//dd($Aboutus);die;
return $Aboutus;
}
static public function showMenu($menulocation_alias)
{
$MenuItems = CCMS::getMenuItems($menulocation_alias);
?>
<ul class="navbar-nav d-flex align-items-center">
<?php foreach ($MenuItems as $menuItem) : ?>
<?php $menuItem->alias = str_replace("-", "_", $menuItem->alias); ?>
<li class="nav-item <?php if (!empty($menuItem->children)) : ?> dropdown <?php endif; ?>" id="myDropdown">
<a class="nav-link <?php if (!empty($menuItem->children)) : ?> dropdown-toggle <?php endif; ?>" <?php if (!empty($menuItem->children)) : ?> data-bs-toggle="dropdown" <?php endif; ?> aria-current="page" href="<?php if ($menuItem->type != "") : ?>
<?php echo route($menuItem->alias); ?><?php else : ?><?php echo site_url(ltrim($menuItem->ref, '/')); ?><?php endif; ?>" target="<?php echo strtolower($menuItem->target) ?>">
<?php echo $menuItem->title; ?>
</a>
<?php if (!empty($menuItem->children)) : ?>
<ul class="dropdown-menu">
<?php foreach ($menuItem->children as $menu) : ?>
<li> <a class="dropdown-item" href="<?php echo route($menuItem->alias . '.' . $menu->alias) ?>" target="<?php echo strtolower($menuItem->target); ?>"> <?php echo $menu->title; ?> </a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php
}
public static function getMenuItems($menulocation_alias, $parentId = 0)
{
$menulocations_id = DB::table('menulocations')
->where('alias', $menulocation_alias)
->value('menulocation_id');
$menuItems = DB::table('menuitems')
->where('menulocations_id', $menulocations_id)
->where('parent_menu', $parentId)
->orderBy('display_order')
->get();
$result = [];
foreach ($menuItems as $menuItem) {
$children = self::getMenuItems($menulocation_alias, $menuItem->menu_id);
$menuItem->children = $children;
$result[] = $menuItem;
}
return $result;
}
public static function getSiteVars()
{
$siteVars = DB::table("settings")->where('status', 1)->orderby('display_order')->first();
$siteVars->Destinations = self::getStudyAbroad();
$siteVars->Services = self::getServices();
$siteVars->Classes = self::getTestPreparations();
$siteVars->Abouts = self::getAbout();
return $siteVars;
}
public static function getCountries()
{
$Countries = DB::table("countries")->where('status', 1)->orderby('display_order')->get();
return $Countries;
}
public static function getCountry($alias)
{
$Countries = DB::table("countries")->where('alias', $alias)->get();
return $Countries[0];
}
public static function getDemandCountries()
{
$demandCountries1 = DB::table('jobdemands')->where('status', 1)->orderby('display_order')->pluck('countries_id');
$demandCountries2 = DB::table('paperdemands')->where('status', 1)->orderby('display_order')->pluck('countries_id');
$demandCountries = $demandCountries1->concat($demandCountries2);
// pre($demandCountries2,true);
$demandCountries = DB::table("countries")->where('status', 1)->orderby('display_order')->whereIn('country_id', $demandCountries)->get();
return $demandCountries;
}
public static function getCertificates()
{
$Certificates = DB::table("certificates")->where('status', 1)->orderby('display_order')->get();
return $Certificates;
}
public static function getCertificate($alias)
{
$Certificate = DB::table("certificates")->where('alias', $alias)->get()[0];
return $Certificate;
}
public static function getTeams()
{
$Teams = DB::table("teams")->where('status', 1)->orderby('display_order')->get();
return $Teams;
}
public static function getTeamsByBranch($alias)
{
$Branch = DB::table("branches")->where("alias", $alias)->first();
if ($Branch) {
$Teams = DB::table("teams")
->where('status', 1)
->where('branches_id', $Branch->branch_id)
->orderby('display_order')->get();
return $Teams;
} else {
die("Branch Not Found");
}
}
public static function getTeam($alias)
{
$Team = DB::table("teams")->where('alias', $alias)->get()[0];
return $Team;
}
public static function getPaperDemands()
{
$PaperDemands = DB::table("paperdemands")->where('status', 1)->orderby('display_order')->get();
return $PaperDemands;
}
public static function getPaperDemand($alias)
{
$PaperDemand = DB::table("paperdemands")->where('alias', $alias)->get()[0];
return $PaperDemand;
}
public static function getJobCategories()
{
$JobCategories = DB::table("job_categories")->where('status', 1)->orderby('display_order')->get();
return $JobCategories;
}
public static function getJobCategory($alias)
{
$JobCategory = DB::table("job_categories")->where('alias', $alias)->get()[0];
return $JobCategory;
}
public static function getCompanies()
{
$Companies = DB::table("companies")->where('status', 1)->orderby('display_order')->get();
return $Companies;
}
public static function getCompany($alias)
{
$Company = DB::table("companies")->where('alias', $alias)->get()[0];
return $Company;
}
public static function showForm($formID)
{
if (is_numeric($formID)) {
$Form = DB::table("forms")->where('form_id', $formID)->first();
} else {
$Form = DB::table("forms")->where('alias', $formID)->first();
}
if (!$Form) {
// Handle the case where the form with the given ID/alias doesn't exist
return "Error: Form (ID/Alias: $formID) not found.";
}
$csrfToken = csrf_token();
if (session('success')) {
echo '<div class="alert alert-success" role="alert">';
echo session('success');
echo '</div>';
}
echo '<form class="mt-5" action="' . route("form.submit") . '" method="POST">';
echo '<input type="hidden" name="_token" value="' . $csrfToken . '">';
echo '<input type="hidden" name="form_id" value="' . $Form->form_id . '">';
$form_fields = json_decode($Form->form_fields);
foreach ($form_fields as $field) {
$fieldAlias = strtolower($field->fieldAlias);
$fieldName = strtolower($field->fieldName);
$fieldType = $field->fieldType;
$fieldDefault = $field->fieldDefault;
$fieldCss = $field->fieldCss;
echo '<div class="mb-3 ' . $fieldCss . '">';
echo '<label for="' . $fieldAlias . '" class="form-label">' . ucfirst($fieldName) . '</label>';
// Check if the "required" class is present in $fieldCss and add the required attribute
$isRequired = strpos($fieldCss, 'required') !== false;
if ($fieldType === 'textarea') {
echo '<textarea class="form-control ' . ($isRequired ? 'required' : '') . '" id="' . $fieldAlias . '" name="' . $fieldAlias . '" ' . ($isRequired ? 'required' : '') . '>' . $fieldDefault . '</textarea>';
} else {
echo '<input type="' . $fieldType . '" class="form-control ' . ($isRequired ? 'required' : '') . '" id="' . $fieldAlias . '" name="' . $fieldAlias . '" value="' . $fieldDefault . '" ' . ($isRequired ? 'required' : '') . '>';
}
echo '</div>';
}
echo '<button type="submit" class="btn btn-primary">Submit</button>';
echo '</form>';
}
private function initDB()
{
static $initialized = false;
if (!$initialized) {
DB::statement('
CREATE TABLE IF NOT EXISTS `tbl_subscribers` (
`subscriber_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(255) NOT NULL,
`alias` varchar(250) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`email` varchar(255) NOT NULL,
`display_order` int(11) NOT NULL,
`status` int(11) NOT NULL,
`createdby` int(11) DEFAULT NULL,
`updatedby` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
');
DB::statement('
CREATE TABLE IF NOT EXISTS `tbl_faqs` (
`faq_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`title` varchar(250) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`text` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`display_order` int(11) NOT NULL,
`status` int(11) NOT NULL,
`createdby` int(11) DEFAULT NULL,
`updatedby` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
');
DB::statement('
CREATE TABLE IF NOT EXISTS `tbl_successstories` (
`successstory_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`countries_id` int(11) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`alias` varchar(200) DEFAULT NULL,
`image` varchar(255) DEFAULT NULL,
`text` text DEFAULT NULL,
`remarks` varchar(255) DEFAULT NULL,
`display_order` int(11) DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`university` varchar(255) DEFAULT NULL,
`faculty` varchar(255) DEFAULT NULL,
`createdby` varchar(255) DEFAULT NULL,
`created_at` varchar(255) DEFAULT NULL,
`updatedby` varchar(255) DEFAULT NULL,
`updated_at` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
');
$initialized = true;
}
}
}

1602
app/Helpers/LMS.php Normal file

File diff suppressed because it is too large Load Diff

1320
app/Helpers/_LMS.php Normal file

File diff suppressed because it is too large Load Diff

694
app/Helpers/bibHelper.php Normal file
View File

@ -0,0 +1,694 @@
<?php
use App\Helpers\BibClass;
use App\Http\Controllers\NepaliDictonary\DictonaryController;
use App\Models\Log\ActivityLog;
use App\Models\Log\ErrorLog;
use App\Models\Log\OperationLog;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
function pre($object, $die = false)
{
echo "<pre>";
print_r($object);
echo "</pre>";
if ($die) die;
}
function label($text, $echo = true)
{
if ($echo) {
echo $text;
} else {
return $text;
}
}
function template($filepath)
{
$filepath = env("APP_URL") .'/' .env("CLIENT_PATH") . '/' . $filepath;
// $filepath=str_replace('\\','/',env("APP_URL")."/layout/".$filepath);
echo $filepath;
// return
}
if (!function_exists('N2')) {
function N2($N)
{
return number_format($N, 2, '.', ',');
}
}
if (!function_exists('slugify')) {
function slugify($text, $tableName = null)
{
// Generate the initial slug from the text
$slug = preg_replace('/[^a-zA-Z0-9\-]/', '-', $text);
$slug = preg_replace('/-+/', '-', $slug);
$slug = trim($slug, '-');
$slug = strtolower($slug);
// If the table name is provided, check for uniqueness and modify the slug if needed
if ($tableName) {
$originalSlug = $slug;
$count = 1;
while (isSlugExists($tableName, $slug)) {
$slug = $originalSlug . '-' . $count;
$count++;
}
}
return $slug;
}
}
if (!function_exists('isSlugExists')) {
function isSlugExists($tableName, $slug)
{
$aliasField = 'alias';
$count = DB::table($tableName)
->where($aliasField, $slug)
->count();
return $count > 0;
}
}
function createButton($class = "", $type = "submit", $display = "Submit", $url = "")
{
if (!$url) :
?>
<button class="btn <?php echo $class; ?>" type="<?php echo ($display == "Submit") ? $display : $type; ?>">
<?php echo label($display) ?>
</button>
<?php
else :
?>
<a class="btn <?php echo $class; ?>" href="<?php echo $url; ?>">
<?php echo label($display) ?>
</a>
<?php
endif;
}
function createText($name, $id, $display, $class = "", $value = "", $placeHolder = "", $readonly = "", $required = "")
{
?>
<?php if ($display != "") : ?><label for="<?php echo $id; ?>" class="form-label col-form-label"> <?php echo label($display); ?> </label><?php endif; ?>
<div class="form-control-wrap">
<input type="text" id="<?php echo $id; ?>" <?php echo $readonly; ?> placeholder="<?php echo $placeHolder; ?>" name="<?php echo $name; ?>" class="form-control <?php echo $class; ?>" value="<?php echo $value; ?>" <?php if ($required != "") : ?>required<?php endif; ?>>
</div>
<p id='error_<?php echo $name; ?>' class='text-danger custom-error'></p>
<?php
}
/**
* $tableName = Name of table
* $pk = primary key of table
* $name = table select column name
* $class = extra class
* $data = Existing data or for edit case showing selected data
* $display = Displaying name or showing label name.
*/
function getSelectForForeignColumn($tableName, $pk, $name, $class = "form-control", $data = null, $display = null, $customColumnName = null)
{
$tableName = strtolower(trim($tableName));
$pk = trim($pk);
$name = trim($name);
$class = trim($class);
$systems = DB::table($tableName)->where('status', '<>', -1)->orderBy($pk, 'asc')->pluck($name, $pk);
$customColumnName = !empty($customColumnName) ? $customColumnName : $pk; //if we pass column name other then primary key.
customCreateSelect($pk, $pk, $class, $display ?? $name, $systems, ($data) ? $data->$customColumnName : null);
}
function customCreateSelect($name, $id, $class = "form-control", $display = '', $values = array(), $defaultValue = '')
{
$disabled = (in_array("DISABLED", explode(" ", strtoupper($class)))) ? "Disabled" : false;
$required = (in_array("REQUIRED", explode(" ", strtoupper($class)))) ? "Required" : false;
?><label for="<?php echo $id; ?>" class="form-label col-form-label"> <?php echo label($display); ?> </label>
<?php if ($disabled) : ?>
<input type="hidden" name="<?php echo $name; ?>" value="<?php echo $defaultValue; ?>" /><?php endif; ?>
<select class="form-select <?php echo $class ?>" name="<?php echo $name; ?>" data-search="true" id="<?php echo $name; ?>" aria-label="Default select example" <?php echo ($disabled) ? "Disabled" : ""; ?> <?php echo ($required) ? "Required" : ""; ?>>
<option value=""><?php label("Select Option"); ?></option>
<?php foreach ($values as $key => $value) { ?>
<option value="<?= $key ?>" <?php echo $defaultValue == $key ? 'selected' : '' ?>><?= $value ?></option>
<?php } ?>
</select>
<p id='error_<?php echo $name; ?>' class='text-danger custom-error'></p>
<?php
}
function createCustomSelectFromArray($Array, $displayTextForLabel, $HTMLElementName, $defaultValueSelected = '', $additionalClass = "form-control")
{
$disabled = (in_array("DISABLED", explode(" ", strtoupper($additionalClass)))) ? "Disabled" : false;
$required = (in_array("REQUIRED", explode(" ", strtoupper($additionalClass)))) ? "Required" : false;
?>
<label for="<?php echo $HTMLElementName; ?>" class="form-label col-form-label"> <?php echo label($displayTextForLabel); ?> </label>
<?php if ($disabled) : ?>
<input type="hidden" name="<?php echo $HTMLElementName; ?>" value="<?php echo $defaultValueSelected; ?>" />
<?php endif; ?>
<select class="form-select <?php echo $additionalClass ?>" name="<?php echo $HTMLElementName; ?>" data-search="true" id="<?php echo $HTMLElementName; ?>" aria-label="Default select example" <?php echo ($disabled) ? "Disabled" : ""; ?> <?php echo ($required) ? "Required" : ""; ?>>
<option <?php if ($required) : ?>value="-1" <?php endif; ?>><?php label("Select Option"); ?></option>
<?php foreach ($Array as $option) : ?>
<option value="<?php echo $option['value']; ?>" <?php echo $defaultValueSelected == $option['value'] ? 'selected' : ''; ?>>
<?php echo $option['display']; ?>
</option>
<?php endforeach; ?>
</select>
<p id='error_<?php echo $HTMLElementName; ?>' class='text-danger custom-error'></p>
<?php
}
function createCustomSelect($tableName, $fieldNameToDisplay, $fieldNameForValue, $defaultValueSelected, $displayTextForLabel, $HTMLElementName, $additionalClass = "form-control", $defaultCondition = null, $extra = null)
{
// Supply conditions as $defaultCondition = "column_name = 'value'";
$tableName = strtolower(trim($tableName));
$fieldNameToDisplay = trim($fieldNameToDisplay);
$fieldNameForValue = trim($fieldNameForValue);
$additionalClass = trim($additionalClass);
$query = DB::table(DB::raw("`$tableName`"))->where('status', '<>', -1);
if ($defaultCondition) {
$query->whereRaw($defaultCondition);
}
$systems = $query->orderBy($fieldNameForValue, 'asc')->pluck($fieldNameToDisplay, $fieldNameForValue);
?><?php if ($displayTextForLabel != '') : ?><label class="form-label col-form-label"><?php echo label($displayTextForLabel); ?></label><?php endif; ?>
<select class="form-select <?php echo $additionalClass; ?>" name="<?php echo $HTMLElementName; ?>" data-search="true" aria-label="" <?php if (stripos($additionalClass, 'required') !== false) {
echo "REQUIRED";
} ?> <?php echo $extra; ?>>
<?php if (stripos($additionalClass, 'required') !== false) { ?>
<option value=""><?php label("Select Option"); ?></option>
<?php } else { ?>
<option value="0"><?php label("Select Option"); ?></option>
<?php } ?>
<?php foreach ($systems as $key => $value) { ?>
<option value="<?= $key ?>" <?php echo $defaultValueSelected == $key ? 'selected' : '' ?>><?= $value ?></option>
<?php } ?>
</select>
<p id='error_<?php echo $fieldNameForValue; ?>' class='text-danger custom-error'></p>
<?php
}
function createImageInput($name, $display = "", $class = "", $default = "")
{
?>
<div class="input-group">
<span class="input-group-btn">
<a id="<?php echo $name; ?>" data-input="<?php echo $name; ?>_url" data-preview="<?php echo $name; ?>holder" class="btn btn-primary">
<i class="fa fa-picture-o"></i> <?php echo ($display != "") ? $display : "Upload"; ?>
</a>
</span>
<input id="<?php echo $name; ?>_url" class="form-control lfm <?php echo $class; ?>" type="text" name="<?php echo $name; ?>" <?php if ($default != "") : ?> value="<?php echo env("APP_URL") . "/" . $default; ?>" <?php endif; ?> multiple>
</div>
<div id="<?php echo $name; ?>holder" style="margin-top:15px;max-height:80px;overflow:hidden;">
<?php if ($default != "") : ?> <img src="<?php echo env("APP_URL") . "/" . $default; ?>" style="height: 5rem" /> <?php endif; ?>
</div>
<?php
collectScripts(function () use ($name) {
?>
<script>
lfm('<?php echo $name; ?>', 'image', {
prefix: '<?php echo env("APP_URL"); ?>/files'
});
</script>
<?php });
}
function createMultiImageInput($name, $display = "", $class = "", $default = "")
{
?>
<div class="input-group">
<span class="input-group-btn">
<a id="<?php echo $name; ?>" data-input="<?php echo $name; ?>_url" data-preview="<?php echo $name; ?>holder" class="btn btn-primary">
<i class="fa fa-picture-o"></i> <?php echo ($display != "") ? $display : "Choose Photo"; ?>
</a>
</span>
<input id="<?php echo $name; ?>_url" class="form-control lfm <?php echo $class; ?>" type="text" name="<?php echo $name; ?>" <?php if ($default != "") : ?> value="<?php echo env("APP_URL") . "/" . $default; ?>" <?php endif; ?> multiple>
</div>
<div id="<?php echo $name; ?>holder" style="margin-top:15px;max-height:80px;overflow:hidden;">
<?php if ($default != "") : ?> <img src="<?php echo env("APP_URL") . "/" . $default; ?>" style="height: 5rem" /> <?php endif; ?>
</div>
<?php
collectScripts(function () use ($name) {
?>
<script>
lfm('<?php echo $name; ?>', 'image', {
prefix: '<?php echo env("APP_URL"); ?>/files',
type: 'file',
multi_selection: true
});
</script>
<?php });
}
function site_url($url = "")
{
return env("APP_URL") . "/" . trim($url, "/");
}
function base_url($url = "")
{
return env("APP_URL") . "/" . trim($url, "/");
}
function showImageThumb($url)
{ ?>
<div style="max-height:40px;overflow:hidden">
<?php if ($url != "") : ?> <img src="<?php echo env("APP_URL") . "/" . $url; ?>" style="height: 40px;" class="img-fluid" /> <?php endif; ?>
</div>
<?php
}
function getFieldData($tableName, $returnField, $referenceFieldName, $referenceValue)
{
$tableName = strtolower(trim($tableName));
$returnField = trim($returnField);
$referenceFieldName = trim($referenceFieldName);
$query = DB::table(DB::raw("`$tableName`"))->where($referenceFieldName, $referenceValue);
$fieldData = ($query->value($returnField)) ? $query->value($returnField) : "N/A";
return $fieldData;
}
function createErrorParagraph($name, $class = null)
{
echo "<p id='error_$name' class='text-danger custom-error $class'></p>";
}
function createActivityLog($controllerName, $methodName, $activity)
{
$user_id = (auth()->user()) ? auth()->user()->id : "0";
ActivityLog::create([
'user_id' => $user_id,
'controllerName' => $controllerName,
'methodName' => $methodName,
'actionUrl' => request()->fullUrl(),
'activity' => $activity,
]);
}
function getOperationNumber()
{
$startNumber = date('YmdHis') . rand(1000, 9999);
$isExists = OperationLog::where('operation_end_no', $startNumber)->first();
while ($isExists) {
$startNumber = date('YmdHis') . rand(1000, 9999);
$isExists = OperationLog::where('operation_end_no', $startNumber)->first();
}
return $startNumber;
}
function createOperationLog($startOperationNumber, $endOperationNumber, $modelName, $modelId, $operationName, $previousValues, $newValues)
{
$operationId = getOperationNumber();
$user_id = (auth()->user()) ? auth()->user()->id : "0";
OperationLog::create([
'user_id' => $user_id,
'operation_start_no' => $startOperationNumber,
'operation_end_no' => $endOperationNumber,
'model_name' => $modelName,
'model_id' => $modelId,
'operation_name' => $operationName,
'previous_values' => $previousValues ? json_encode($previousValues) : null,
'new_values' => $newValues ? json_encode($newValues) : null,
]);
}
function createErrorLog($controllerName, $methodName, $errors)
{
$user_id = (auth()->user()) ? auth()->user()->id : "0";
ErrorLog::create([
'user_id' => $user_id,
'controller_name' => $controllerName,
'method_name' => $methodName,
'errors' => $errors,
]);
}
function createDate($name, $display = "", $class = "datepicker", $default = "")
{
?>
<div class="form-group">
<label for="<?php echo $name; ?>" class="form-label col-form-label"><?php echo label($display); ?></label>
<div class="form-control-wrap">
<input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" class="form-control datepicker<?php echo $class; ?>" value="<?php echo $default; ?>" />
</div>
</div>
<?php
}
function createPassword($name, $display = "", $class = "password", $default = "")
{
?>
<div class="form-group">
<label for="<?php echo $name; ?>" class="form-label col-form-label"><?php echo label($display); ?></label>
<div class="form-control-wrap">
<input type="password" name="<?php echo $name; ?>" id="<?php echo $name; ?>" class="form-control <?php echo $class; ?>" value="<?php echo $default; ?>" />
</div>
</div>
<?php
}
function createTextArea($name, $class = "", $display = "", $default = "", $row = "")
{
$hasCkeditorClassic = strpos($class, 'ckeditor-classic') !== false;
$uploadUrlAttribute = $hasCkeditorClassic ? ' data-upload-url="' . route('upload') . '"' : '';
?>
<div class="form-group">
<label for="<?php echo $name; ?>" class="form-label col-form-label"><?php echo label($display); ?></label>
<div class="form-control-wrap">
<textarea class="form-control text-area <?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" rows="<?php echo $row; ?>" <?php echo $uploadUrlAttribute; ?>><?php if (isset($default)) {
echo ($default);
} ?></textarea>
</div>
</div>
<?php
}
function createPlainTextArea($name, $class = "", $display = "", $default = "", $row = "")
{
?>
<div class="form-group">
<label for="<?php echo $name; ?>" class="form-label col-form-label"><?php echo label($display); ?></label>
<div class="form-control-wrap">
<textarea class="form-control text-area <?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" rows="<?php echo $row; ?>"><?php if (isset($default)) {
echo ($default);
} ?></textarea>
</div>
</div>
<?php
}
function getDisplayOrder($tableName)
{
// echo $tableName;die;
$maxDisplayOrder = DB::select("select max(display_order) as display_order from $tableName")[0]->display_order;
$nextDisplayOrder = $maxDisplayOrder + 1;
return $nextDisplayOrder;
}
function getAlias($textField, $tableName)
{
$maxDisplayOrder = DB::select("select max(display_order) as display_order from $tableName")[0]->display_order;
$nextDisplayOrder = $maxDisplayOrder + 1;
return $nextDisplayOrder;
}
if (!function_exists('myDate')) {
function myDate($originalDate)
{
return date("F d Y", strtotime($originalDate));
}
}
if (!function_exists('dbDate')) {
function dbDate($date)
{
return date("Y-m-d", strtotime($date));
}
}
if (!function_exists('myTime')) {
function myTime($originalDate)
{
return date("g:i A", strtotime($originalDate));
}
}
if (!function_exists('myDateTime')) {
function myDateTime($originalDate)
{
return date("F d Y g:i A", strtotime($originalDate));
}
}
if (!function_exists('myDaysDiff')) {
function myDaysDiff($fromDate, $toDate)
{
$fromDate = strtotime($fromDate);
$toDate = strtotime($toDate);
$datediff = $toDate - $fromDate;
return round($datediff / (60 * 60 * 24));
}
}
if (!function_exists('firstDayOfNepaliMonth')) {
function firstDayOfNepaliMonth($engDate = "")
{
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
$NepaliDate = NepaliDate($engDate);
$nD = explode("-", $NepaliDate);
$Day = '1';
$Month = $nD[1];
$Year = $nD[0];
$t = "select bs_date from tbl_nepengcalendar where bs_date='" . $Year . "-" . $Month . "-" . $Day . "'";
return DB::select($t)[0]->bs_date;
}
}
if (!function_exists('firstDayOfNepaliMonth1')) {
function firstDayOfNepaliMonth1($engDate = "")
{
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
$NepaliDate = NepaliDate($engDate);
$nD = explode("-", $NepaliDate);
$Day = '1';
$Month = ($nD[1] < 10) ? '0' . $nD[1] : $nD[1];
$Year = $nD[0];
$t = "select ad_date from tbl_nepengcalendar where bs_date='" . $Year . "-" . $Month . "-" . $Day . "'";
return DB::select($t)[0]->ad_date;
}
}
if (!function_exists('lastDayOfNepaliMonth')) {
function lastDayOfNepaliMonth($engDate = "")
{
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
$NepaliDate = NepaliDate1($engDate);
$nD = explode("-", $NepaliDate);
$Day = '1';
$Month = $nD[1];
$Year = $nD[0];
$t = "select ad_date from tbl_nepengcalendar where bs_date like '" . $Year . "-" . $Month . "-%' order by ad_date";
$dates = DB::select($t);
$date = end($dates);
return $date->ad_date;
}
}
if (!function_exists('EnglishDate')) {
function EnglishDate($NepaliYear, $NepaliMonth, $NepaliDay)
{
if ($NepaliMonth < 10) {
$NepaliMonth = "0" . $NepaliMonth;
}
$bs_date = $NepaliYear . "-" . $NepaliMonth . "-" . $NepaliDay;
$t = "select ad_date from tbl_nepengcalendar where bs_date='$bs_date'";
$q = DB::select($t);
return $q[0]->ad_date;
}
}
if (!function_exists('Today')) {
function Today()
{
return date("Y-m-d");
}
}
if (!function_exists('NepaliToEnglishDate')) {
function NepaliToEnglishDate($NepaliDate)
{
$NepaliDate = trim($NepaliDate);
if (trim($NepaliDate) == "") {
return date("Y-m-d");
}
$NepaliDate = explode("-", $NepaliDate);
$NepaliMonth = intval($NepaliDate[1]);
$NepaliYear = intval($NepaliDate[0]);
$NepaliDay = intval($NepaliDate[2]);
if ($NepaliMonth < 10) {
$NepaliMonth = "0" . $NepaliMonth;
}
$bs_date = $NepaliYear . "-" . $NepaliMonth . "-" . $NepaliDay;
$t = "select ad_date from tbl_nepengcalendar where bs_date='$bs_date'";
$q = DB::select($t);
return $q[0]->ad_date;
}
}
if (!function_exists('NepaliDate')) {
function NepaliDate($engDate = "")
{
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
if ($engDate != "0000-00-00") {
// return str_replace("-0", "-", DB::table('tbl_nepengcalendar')->where('ad_date', $engDate)->first()->bs_date);
$result = DB::table('tbl_nepengcalendar')->where('ad_date', $engDate)->first();
if ($result) {
$bsDate = $result->bs_date;
$convertedDate = convertNumbersToUnicode(str_replace("-", "-", $bsDate));
return $convertedDate;
} else {
// Handle the case when the query result is null
return null;
}
} else {
return "";
}
}
}
function convertNumbersToUnicode($number = "2080-10-13")
{
$unicodeDigits = [
'0' => '',
'1' => '१',
'2' => '२',
'3' => '३',
'4' => '४',
'5' => '५',
'6' => '६',
'7' => '७',
'8' => '८',
'9' => '९',
];
$converted = '';
$digits = str_split((string)$number);
foreach ($digits as $digit) {
if (isset($unicodeDigits[$digit])) {
$converted .= $unicodeDigits[$digit];
} elseif ($digit === '-') {
$converted .= '-';
} else {
$converted .= $digit;
}
}
//dd($converted);
return $converted;
}
if (!function_exists('NepaliMonth')) {
function NepaliMonth($engDate = "")
{
$NepaliDate = NepaliDate($engDate);
$nD = explode("-", $NepaliDate);
$Month = $nD[1];
return intval($Month);
}
}
if (!function_exists('NepaliYear')) {
function NepaliYear($engDate = "")
{
$NepaliDate = NepaliDate($engDate);
$nD = explode("-", $NepaliDate);
$Year = $nD[0];
return intval($Year);
}
}
if (!function_exists('NepaliMonthNameByNumber')) {
function NepaliMonthNameByNumber($number)
{
$MonthNames = array(
"Baisakh", "Jestha", "Ashad", "Shrawan", "Bhadra", "Asoj",
"Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra"
);
return $MonthNames[$number - 1];
}
}
if (!function_exists('NepaliMonthName')) {
function NepaliMonthName($engDate = "")
{
$Month = NepaliMonth($engDate);
$MonthNames = array(
"Baisakh", "Jestha", "Ashad", "Shrawan", "Bhadra", "Asoj",
"Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra"
);
return $MonthNames[$Month - 1];
}
}
if (!function_exists('N2')) {
function N2($N)
{
return number_format($N, 2, '.', ',');
}
}
function collectScripts(callable $callback)
{
ob_start();
$callback();
$script = ob_get_clean();
if (!empty($script)) {
pushScriptToFooter($script);
}
}
function pushScriptToFooter($script)
{
if (!isset($GLOBALS['scripts'])) {
$GLOBALS['scripts'] = [];
}
$GLOBALS['scripts'][] = $script;
}
function sectionHeader($text, $sectiontitle = null)
{
$texts = explode(" ", $text);
?>
<div class="row text-center intro">
<div class="col-12">
<?php if ($sectiontitle) : ?>
<span class="pre-title"><?php echo $sectiontitle; ?></span>
<?php endif; ?>
<h2 class="ylw-clr"><?php echo $texts[0];
unset($texts[0]); ?> <span class="featured"><span><?php echo implode(" ", $texts); ?></span></span></h2>
</div>
</div>
<?php
}
if (!function_exists('replace_img_src')) {
function replace_img_src($content)
{
return preg_replace(
'/src="storage(\/[^"]*)"/',
'src="' . site_url() . 'storage$1"',
$content
);
}
}
function processForShortcode($content)
{
$content = replace_img_src($content);
return preg_replace_callback('/\[([\w_]+)([^]]*)\]/', function ($matches) {
$shortcodeName = $matches[1];
$shortcodeAttributes = [];
$mandatoryAttributes = ['alias', 'css', 'title'];
preg_match_all('/\s*(\w+)\s*=\s*(?:"([^"]*)"|\'([^\']*)\'|([^"\'][^\s]*))/', $matches[2], $attrMatches, PREG_SET_ORDER);
foreach ($attrMatches as $attrMatch) {
$attrName = $attrMatch[1];
$attrValue = $attrMatch[2] ?: ($attrMatch[3] ?: $attrMatch[4]); // Use non-empty capture group as the attribute value
$attrValue = trim($attrValue, "\"'"); // Remove both single and double quotes from the attribute value
$shortcodeAttributes[$attrName] = $attrValue;
}
// Fill in missing mandatory attributes with empty strings
foreach ($mandatoryAttributes as $attribute) {
if (!isset($shortcodeAttributes[$attribute])) {
$shortcodeAttributes[$attribute] = '';
}
}
return view("shortcodes." . $shortcodeName, $shortcodeAttributes);
}, $content);
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Agents;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class AgentsController extends Controller
{
protected $modelService;
public function __construct(Agents $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(AgentsController::class, 'index', ' Agents index');
$data = Agents::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.agents.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(AgentsController::class, 'create', ' Agents create');
$TableData = Agents::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.agents.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(AgentsController::class, 'store', ' Agents 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_agents')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(AgentsController::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 Agents Created Successfully.'], 200);
}
return redirect()->route('agents.index')->with('success','The Agents created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Agents::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 = Agents::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(AgentsController::class, 'show', ' Agents show');
$data = Agents::findOrFail($id);
return view("crud.generated.agents.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(AgentsController::class, 'edit', ' Agents edit');
$TableData = Agents::where('status','<>',-1)->orderBy('display_order')->get();
$data = Agents::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.agents.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.agents.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(AgentsController::class, 'update', ' Agents 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('agent_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(AgentsController::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 Agents updated Successfully.'], 200);
}
// return redirect()->route('agents.index')->with('success','The Agents updated Successfully.');
return redirect()->back()->with('success', 'The Agents updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(AgentsController::class, 'destroy', ' Agents destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(AgentsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Agents Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(AgentsController::class, 'destroy', ' Agents destroy');
$data = Agents::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(AgentsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Agents Deleted Successfully.'],200);
}
}

View 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('/');
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ConfirmsPasswords;
class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/
use ConfirmsPasswords;
/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}

View 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);
}
}

View File

@ -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');
}
}

View File

@ -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');
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
}

View File

@ -0,0 +1,51 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
// protected function credentials(Request $request)
// {
// return ['email'=>$request->email, 'password' => $request->password, 'status' => 'active'];
// }
protected function credentials(Request $request)
{
return ['email'=>$request->email, 'password' => $request->password, 'status' => 'active'];
}
}

View 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)]);
}
}

View 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');
}
}

View 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)]);
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\Modules\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\Models\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}

View 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);
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
}

View File

@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

View 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');
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Branches;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class BranchesController extends Controller
{
protected $modelService;
public function __construct(Branches $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(BranchesController::class, 'index', ' Branches index');
$data = Branches::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.branches.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(BranchesController::class, 'create', ' Branches create');
$TableData = Branches::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.branches.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(BranchesController::class, 'store', ' Branches store');
$validator = Validator::make($request->all(), [
//ADD REQUIRED FIELDS FOR VALIDATION
]);
if ($validator->fails()) {
return response()->json([
'error' => $validator->errors(),
],500);
}
$request->request->add(['alias' => slugify($request->title)]);
$request->request->add(['display_order' => getDisplayOrder('tbl_branches')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(BranchesController::class, 'store', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
if ($request->ajax()) {
return response()->json(['status' => true, 'message' => 'The Branches Created Successfully.'], 200);
}
return redirect()->route('branches.index')->with('success','The Branches created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Branches::find($id);
$companyArticle->display_order = $index + 1;
$companyArticle->save();
}
return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200);
}
public function updatealias(Request $request)
{
$articleId = $request->input('articleId');
$newAlias = $request->input('newAlias');
$companyArticle = Branches::find($articleId);
if (!$companyArticle) {
return response()->json(['status' => false, 'content' => 'Company article not found.'], 404);
}
$companyArticle->alias = $newAlias;
$companyArticle->save();
return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200);
}
public function show(Request $request, $id)
{
createActivityLog(BranchesController::class, 'show', ' Branches show');
$data = Branches::findOrFail($id);
return view("crud.generated.branches.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(BranchesController::class, 'edit', ' Branches edit');
$TableData = Branches::where('status','<>',-1)->orderBy('display_order')->get();
$data = Branches::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.branches.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.branches.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(BranchesController::class, 'update', ' Branches update');
$validator = Validator::make($request->all(), [
//ADD VALIDATION FOR REQIRED FIELDS
]);
if ($validator->fails()) {
return response()->json([
'error' => $validator->errors(),
],500);
}
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('branch_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(BranchesController::class, 'update', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
if ($request->ajax()) {
return response()->json(['status' => true, 'message' => 'The Branches updated Successfully.'], 200);
}
// return redirect()->route('branches.index')->with('success','The Branches updated Successfully.');
return redirect()->back()->with('success', 'The Branches updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(BranchesController::class, 'destroy', ' Branches destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(BranchesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Branches Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(BranchesController::class, 'destroy', ' Branches destroy');
$data = Branches::findOrFail($id);
$requestData=['status'=>($data->status==1)?0:1];
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(BranchesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Branches Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Campaignarticles;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class CampaignarticlesController extends Controller
{
protected $modelService;
public function __construct(Campaignarticles $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(CampaignarticlesController::class, 'index', ' Campaignarticles index');
$data = Campaignarticles::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.campaignarticles.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(CampaignarticlesController::class, 'create', ' Campaignarticles create');
$TableData = Campaignarticles::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.campaignarticles.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(CampaignarticlesController::class, 'store', ' Campaignarticles 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_campaignarticles')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CampaignarticlesController::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 Campaignarticles Created Successfully.'], 200);
}
return redirect()->route('campaignarticles.index')->with('success','The Campaignarticles created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Campaignarticles::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 = Campaignarticles::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(CampaignarticlesController::class, 'show', ' Campaignarticles show');
$data = Campaignarticles::findOrFail($id);
return view("crud.generated.campaignarticles.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(CampaignarticlesController::class, 'edit', ' Campaignarticles edit');
$TableData = Campaignarticles::where('status','<>',-1)->orderBy('display_order')->get();
$data = Campaignarticles::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.campaignarticles.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.campaignarticles.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(CampaignarticlesController::class, 'update', ' Campaignarticles 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('campaignarticle_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CampaignarticlesController::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 Campaignarticles updated Successfully.'], 200);
}
// return redirect()->route('campaignarticles.index')->with('success','The Campaignarticles updated Successfully.');
return redirect()->back()->with('success', 'The Campaignarticles updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(CampaignarticlesController::class, 'destroy', ' Campaignarticles destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CampaignarticlesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Campaignarticles Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(CampaignarticlesController::class, 'destroy', ' Campaignarticles destroy');
$data = Campaignarticles::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(CampaignarticlesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Campaignarticles Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Campaigns;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class CampaignsController extends Controller
{
protected $modelService;
public function __construct(Campaigns $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(CampaignsController::class, 'index', ' Campaigns index');
$data = Campaigns::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.campaigns.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(CampaignsController::class, 'create', ' Campaigns create');
$TableData = Campaigns::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.campaigns.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(CampaignsController::class, 'store', ' Campaigns 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_campaigns')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CampaignsController::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 Campaigns Created Successfully.'], 200);
}
return redirect()->route('campaigns.index')->with('success','The Campaigns created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Campaigns::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 = Campaigns::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(CampaignsController::class, 'show', ' Campaigns show');
$data = Campaigns::findOrFail($id);
return view("crud.generated.campaigns.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(CampaignsController::class, 'edit', ' Campaigns edit');
$TableData = Campaigns::where('status','<>',-1)->orderBy('display_order')->get();
$data = Campaigns::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.campaigns.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.campaigns.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(CampaignsController::class, 'update', ' Campaigns 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('campaign_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CampaignsController::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 Campaigns updated Successfully.'], 200);
}
// return redirect()->route('campaigns.index')->with('success','The Campaigns updated Successfully.');
return redirect()->back()->with('success', 'The Campaigns updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(CampaignsController::class, 'destroy', ' Campaigns destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CampaignsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Campaigns Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(CampaignsController::class, 'destroy', ' Campaigns destroy');
$data = Campaigns::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(CampaignsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Campaigns Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Cities;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class CitiesController extends Controller
{
protected $modelService;
public function __construct(Cities $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(CitiesController::class, 'index', ' Cities index');
$data = Cities::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.cities.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(CitiesController::class, 'create', ' Cities create');
$TableData = Cities::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.cities.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(CitiesController::class, 'store', ' Cities 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_cities')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CitiesController::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 Cities Created Successfully.'], 200);
}
return redirect()->route('cities.index')->with('success','The Cities created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Cities::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 = Cities::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(CitiesController::class, 'show', ' Cities show');
$data = Cities::findOrFail($id);
return view("crud.generated.cities.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(CitiesController::class, 'edit', ' Cities edit');
$TableData = Cities::where('status','<>',-1)->orderBy('display_order')->get();
$data = Cities::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.cities.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.cities.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(CitiesController::class, 'update', ' Cities 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('city_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CitiesController::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 Cities updated Successfully.'], 200);
}
// return redirect()->route('cities.index')->with('success','The Cities updated Successfully.');
return redirect()->back()->with('success', 'The Cities updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(CitiesController::class, 'destroy', ' Cities destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CitiesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Cities Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(CitiesController::class, 'destroy', ' Cities destroy');
$data = Cities::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(CitiesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Cities Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,199 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Contactus;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class ContactusController extends Controller
{
protected $modelService;
public function __construct(Contactus $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(ContactusController::class, 'index', ' Contactus index');
$data = Contactus::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.contactus.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(ContactusController::class, 'create', ' Contactus create');
$TableData = Contactus::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.contactus.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(ContactusController::class, 'store', ' Contactus 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_contactus')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(ContactusController::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 Contactus Created Successfully.'], 200);
}
return redirect()->route('contactus.index')->with('success','The Contactus created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Contactus::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 = Contactus::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(ContactusController::class, 'show', ' Contactus show');
$data = Contactus::findOrFail($id);
return view("crud.generated.contactus.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(ContactusController::class, 'edit', ' Contactus edit');
$TableData = Contactus::where('status','<>',-1)->orderBy('display_order')->get();
$data = Contactus::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.contactus.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.contactus.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(ContactusController::class, 'update', ' Contactus 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('inquiries_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(ContactusController::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 Contactus updated Successfully.'], 200);
}
// return redirect()->route('contactus.index')->with('success','The Contactus updated Successfully.');
return redirect()->back()->with('success', 'The Contactus updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(ContactusController::class, 'destroy', ' Contactus destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(ContactusController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Contactus Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(ContactusController::class, 'destroy', ' Contactus destroy');
$data = Contactus::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(ContactusController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Contactus Deleted Successfully.'],200);
}
}

View 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;
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Countries;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class CountriesController extends Controller
{
protected $modelService;
public function __construct(Countries $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(CountriesController::class, 'index', ' Countries index');
$data = Countries::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.countries.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(CountriesController::class, 'create', ' Countries create');
$TableData = Countries::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.countries.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(CountriesController::class, 'store', ' Countries 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_countries')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CountriesController::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 Countries Created Successfully.'], 200);
}
return redirect()->route('countries.index')->with('success','The Countries created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Countries::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 = Countries::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(CountriesController::class, 'show', ' Countries show');
$data = Countries::findOrFail($id);
return view("crud.generated.countries.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(CountriesController::class, 'edit', ' Countries edit');
$TableData = Countries::where('status','<>',-1)->orderBy('display_order')->get();
$data = Countries::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.countries.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.countries.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(CountriesController::class, 'update', ' Countries 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('country_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CountriesController::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 Countries updated Successfully.'], 200);
}
// return redirect()->route('countries.index')->with('success','The Countries updated Successfully.');
return redirect()->back()->with('success', 'The Countries updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(CountriesController::class, 'destroy', ' Countries destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(CountriesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Countries Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(CountriesController::class, 'destroy', ' Countries destroy');
$data = Countries::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(CountriesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Countries Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Districts;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class DistrictsController extends Controller
{
protected $modelService;
public function __construct(Districts $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(DistrictsController::class, 'index', ' Districts index');
$data = Districts::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.districts.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(DistrictsController::class, 'create', ' Districts create');
$TableData = Districts::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.districts.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(DistrictsController::class, 'store', ' Districts 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_districts')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(DistrictsController::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 Districts Created Successfully.'], 200);
}
return redirect()->route('districts.index')->with('success','The Districts created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Districts::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 = Districts::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(DistrictsController::class, 'show', ' Districts show');
$data = Districts::findOrFail($id);
return view("crud.generated.districts.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(DistrictsController::class, 'edit', ' Districts edit');
$TableData = Districts::where('status','<>',-1)->orderBy('display_order')->get();
$data = Districts::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.districts.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.districts.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(DistrictsController::class, 'update', ' Districts 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('district_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(DistrictsController::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 Districts updated Successfully.'], 200);
}
// return redirect()->route('districts.index')->with('success','The Districts updated Successfully.');
return redirect()->back()->with('success', 'The Districts updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(DistrictsController::class, 'destroy', ' Districts destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(DistrictsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Districts Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(DistrictsController::class, 'destroy', ' Districts destroy');
$data = Districts::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(DistrictsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Districts Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Faqs;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class FaqsController extends Controller
{
protected $modelService;
public function __construct(Faqs $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(FaqsController::class, 'index', ' Faqs index');
$data = Faqs::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.faqs.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(FaqsController::class, 'create', ' Faqs create');
$TableData = Faqs::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.faqs.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(FaqsController::class, 'store', ' Faqs 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_faqs')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(FaqsController::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 Faqs Created Successfully.'], 200);
}
return redirect()->route('faqs.index')->with('success','The Faqs created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Faqs::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 = Faqs::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(FaqsController::class, 'show', ' Faqs show');
$data = Faqs::findOrFail($id);
return view("crud.generated.faqs.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(FaqsController::class, 'edit', ' Faqs edit');
$TableData = Faqs::where('status','<>',-1)->orderBy('display_order')->get();
$data = Faqs::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.faqs.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.faqs.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(FaqsController::class, 'update', ' Faqs 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('faq_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(FaqsController::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 Faqs updated Successfully.'], 200);
}
// return redirect()->route('faqs.index')->with('success','The Faqs updated Successfully.');
return redirect()->back()->with('success', 'The Faqs updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(FaqsController::class, 'destroy', ' Faqs destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(FaqsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Faqs Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(FaqsController::class, 'destroy', ' Faqs destroy');
$data = Faqs::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(FaqsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Faqs Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace App\Http\Controllers\FileManager;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class FileManagerController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
return view('filemanager.index');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Followups;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class FollowupsController extends Controller
{
protected $modelService;
public function __construct(Followups $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(FollowupsController::class, 'index', ' Followups index');
$data = Followups::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.followups.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(FollowupsController::class, 'create', ' Followups create');
$TableData = Followups::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.followups.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(FollowupsController::class, 'store', ' Followups 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_followups')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(FollowupsController::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 Followups Created Successfully.'], 200);
}
return redirect()->route('followups.index')->with('success','The Followups created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Followups::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 = Followups::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(FollowupsController::class, 'show', ' Followups show');
$data = Followups::findOrFail($id);
return view("crud.generated.followups.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(FollowupsController::class, 'edit', ' Followups edit');
$TableData = Followups::where('status','<>',-1)->orderBy('display_order')->get();
$data = Followups::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.followups.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.followups.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(FollowupsController::class, 'update', ' Followups 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('followup_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(FollowupsController::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 Followups updated Successfully.'], 200);
}
// return redirect()->route('followups.index')->with('success','The Followups updated Successfully.');
return redirect()->back()->with('success', 'The Followups updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(FollowupsController::class, 'destroy', ' Followups destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(FollowupsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Followups Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(FollowupsController::class, 'destroy', ' Followups destroy');
$data = Followups::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(FollowupsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Followups Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,131 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Mail\CustomMailer;
use App\Models\Registrations;
use App\Service\CommonModelService;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Mail;
class FormsController extends Controller
{
protected $modelService;
public function __construct(Registrations $model)
{
$this->modelService = new CommonModelService($model);
}
function saveregistration(Request $r)
{
$requestData=$r->all();
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(ProvincesController::class, 'store', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
// $FormData = array(
// "name" => isset($r['name']) ? $r['name'] : "",
// "email" => isset($r['email']) ? $r['email'] : "",
// "phone" => isset($r['phone']) ? $r['phone'] : "",
// "preferred_destination" => isset($r['preferred_destination']) ? $r['preferred_destination'] : "",
// "mode_of_counselling" => isset($r['mode_of_counselling']) ? $r['mode_of_counselling'] : "",
// "nearest_branch" => isset($r['nearest_branch']) ? $r['nearest_branch'] : "",
// "message" => isset($r['message']) ? $r['message'] : ""
// );
// DB::table('enquiries')->insert($FormData);
// $mailer = new CustomMailer($FormData);
// Mail::to("prajwalbro@hotmail.com")->send($mailer->enquiryform());
// Mail::to($r['email'])->send($mailer->enquiryresponse());
// Respond back to the customer
return response()->json(['success' => true, 'message' => 'Form submitted successfully!']);
}
function submitenquiry(Request $r)
{
$r = $r->all();
if (!Schema::hasTable('enquiries')) {
try {
Schema::create('enquiries', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email');
$table->string('phone');
$table->string('preferred_destination');
$table->string('mode_of_counselling');
$table->string('nearest_branch');
$table->text('message');
$table->timestamps();
});
} catch (QueryException $e) {
return response()->json(['error' => 'Error creating the table: ' . $e->getMessage()], 500);
}
}
$FormData = array(
"name" => isset($r['name']) ? $r['name'] : "",
"email" => isset($r['email']) ? $r['email'] : "",
"phone" => isset($r['phone']) ? $r['phone'] : "",
"preferred_destination" => isset($r['preferred_destination']) ? $r['preferred_destination'] : "",
"mode_of_counselling" => isset($r['mode_of_counselling']) ? $r['mode_of_counselling'] : "",
"nearest_branch" => isset($r['nearest_branch']) ? $r['nearest_branch'] : "",
"message" => isset($r['message']) ? $r['message'] : ""
);
DB::table('enquiries')->insert($FormData);
$mailer = new CustomMailer($FormData);
Mail::to("prajwalbro@hotmail.com")->send($mailer->enquiryform());
Mail::to($r['email'])->send($mailer->enquiryresponse());
// Respond back to the customer
return response()->json(['success' => true, 'message' => 'Form submitted successfully!']);
}
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!');
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Institutions;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class InstitutionsController extends Controller
{
protected $modelService;
public function __construct(Institutions $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(InstitutionsController::class, 'index', ' Institutions index');
$data = Institutions::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.institutions.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(InstitutionsController::class, 'create', ' Institutions create');
$TableData = Institutions::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.institutions.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(InstitutionsController::class, 'store', ' Institutions 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_institutions')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(InstitutionsController::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 Institutions Created Successfully.'], 200);
}
return redirect()->route('institutions.index')->with('success','The Institutions created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Institutions::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 = Institutions::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(InstitutionsController::class, 'show', ' Institutions show');
$data = Institutions::findOrFail($id);
return view("crud.generated.institutions.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(InstitutionsController::class, 'edit', ' Institutions edit');
$TableData = Institutions::where('status','<>',-1)->orderBy('display_order')->get();
$data = Institutions::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.institutions.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.institutions.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(InstitutionsController::class, 'update', ' Institutions 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('institution_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(InstitutionsController::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 Institutions updated Successfully.'], 200);
}
// return redirect()->route('institutions.index')->with('success','The Institutions updated Successfully.');
return redirect()->back()->with('success', 'The Institutions updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(InstitutionsController::class, 'destroy', ' Institutions destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(InstitutionsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Institutions Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(InstitutionsController::class, 'destroy', ' Institutions destroy');
$data = Institutions::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(InstitutionsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Institutions Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Institutiontypes;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class InstitutiontypesController extends Controller
{
protected $modelService;
public function __construct(Institutiontypes $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(InstitutiontypesController::class, 'index', ' Institutiontypes index');
$data = Institutiontypes::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.institutiontypes.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(InstitutiontypesController::class, 'create', ' Institutiontypes create');
$TableData = Institutiontypes::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.institutiontypes.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(InstitutiontypesController::class, 'store', ' Institutiontypes 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_institutiontypes')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(InstitutiontypesController::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 Institutiontypes Created Successfully.'], 200);
}
return redirect()->route('institutiontypes.index')->with('success','The Institutiontypes created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Institutiontypes::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 = Institutiontypes::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(InstitutiontypesController::class, 'show', ' Institutiontypes show');
$data = Institutiontypes::findOrFail($id);
return view("crud.generated.institutiontypes.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(InstitutiontypesController::class, 'edit', ' Institutiontypes edit');
$TableData = Institutiontypes::where('status','<>',-1)->orderBy('display_order')->get();
$data = Institutiontypes::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.institutiontypes.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.institutiontypes.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(InstitutiontypesController::class, 'update', ' Institutiontypes 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('institutiontype_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(InstitutiontypesController::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 Institutiontypes updated Successfully.'], 200);
}
// return redirect()->route('institutiontypes.index')->with('success','The Institutiontypes updated Successfully.');
return redirect()->back()->with('success', 'The Institutiontypes updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(InstitutiontypesController::class, 'destroy', ' Institutiontypes destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(InstitutiontypesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Institutiontypes Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(InstitutiontypesController::class, 'destroy', ' Institutiontypes destroy');
$data = Institutiontypes::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(InstitutiontypesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Institutiontypes Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Leadcategories;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class LeadcategoriesController extends Controller
{
protected $modelService;
public function __construct(Leadcategories $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(LeadcategoriesController::class, 'index', ' Leadcategories index');
$data = Leadcategories::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.leadcategories.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(LeadcategoriesController::class, 'create', ' Leadcategories create');
$TableData = Leadcategories::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.leadcategories.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(LeadcategoriesController::class, 'store', ' Leadcategories 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_leadcategories')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(LeadcategoriesController::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 Leadcategories Created Successfully.'], 200);
}
return redirect()->route('leadcategories.index')->with('success','The Leadcategories created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Leadcategories::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 = Leadcategories::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(LeadcategoriesController::class, 'show', ' Leadcategories show');
$data = Leadcategories::findOrFail($id);
return view("crud.generated.leadcategories.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(LeadcategoriesController::class, 'edit', ' Leadcategories edit');
$TableData = Leadcategories::where('status','<>',-1)->orderBy('display_order')->get();
$data = Leadcategories::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.leadcategories.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.leadcategories.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(LeadcategoriesController::class, 'update', ' Leadcategories 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('leadcategory_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(LeadcategoriesController::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 Leadcategories updated Successfully.'], 200);
}
// return redirect()->route('leadcategories.index')->with('success','The Leadcategories updated Successfully.');
return redirect()->back()->with('success', 'The Leadcategories updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(LeadcategoriesController::class, 'destroy', ' Leadcategories destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(LeadcategoriesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Leadcategories Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(LeadcategoriesController::class, 'destroy', ' Leadcategories destroy');
$data = Leadcategories::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(LeadcategoriesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Leadcategories Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,216 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Offerapplications;
use App\Models\Requireddocuments;
use App\Service\CommonModelService;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
class OfferapplicationsController extends Controller
{
protected $modelService;
public function __construct(Offerapplications $model)
{
$this->modelService = new CommonModelService($model);
}
public function fetchRequiredDocuments()
{
$requiredDocuments = Requireddocuments::where('status', '<>', -1)->get();
return response()->json($requiredDocuments);
}
public function index(Request $request)
{
createActivityLog(OfferapplicationsController::class, 'index', ' Offerapplications index');
$data = Offerapplications::where('status', '<>', -1)->orderBy('display_order')->get();
return view("crud.generated.offerapplications.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(OfferapplicationsController::class, 'create', ' Offerapplications create');
$mandatoryDocuments = Requireddocuments::where('status', '<>', -1)->orderBy('display_order')->get();
$TableData = Offerapplications::where('status', '<>', -1)->orderBy('display_order')->get();
return view("crud.generated.offerapplications.create", compact('mandatoryDocuments', 'TableData'));
}
public function store(Request $request)
{
createActivityLog(OfferapplicationsController::class, 'store', ' Offerapplications store');
$validator = Validator::make($request->all(), [
// ADD REQUIRED FIELDS FOR VALIDATION
]);
if ($validator->fails()) {
return response()->json([
'error' => $validator->errors(),
], 500);
}
$requiredDocumentsID = $request->input('required_documents', []);
$requiredDocumentsTitles = implode(', ', $requiredDocumentsID);
// Check if no services are selected, and set to null if true
if (empty($requiredDocumentsTitle)) {
$requiredDocumentsTitle = null;
}
$additionalDocuments = $request->input('additional_documents', []);
$additionalDocumentsCSV = implode(', ', $additionalDocuments);
$request->request->add(['requireddocuments_id' => $requiredDocumentsTitles]);
$request->request->add(['additional_documents' => $additionalDocumentsCSV]); // Update the additional_documents column
$request->request->add(['alias' => slugify($request->title)]);
$request->request->add(['display_order' => getDisplayOrder('tbl_offerapplications')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData = $request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL') . '/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(OfferapplicationsController::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 Offerapplications Created Successfully.'], 200);
}
return redirect()->route('offerapplications.index')->with('success', 'The Offerapplications created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Offerapplications::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 = Offerapplications::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(OfferapplicationsController::class, 'show', ' Offerapplications show');
$data = Offerapplications::findOrFail($id);
return view("crud.generated.offerapplications.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(OfferapplicationsController::class, 'edit', ' Offerapplications edit');
$TableData = Offerapplications::where('status', '<>', -1)->orderBy('display_order')->get();
$data = Offerapplications::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.offerapplications.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.offerapplications.edit", compact('data', 'TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(OfferapplicationsController::class, 'update', ' Offerapplications 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('offerapplication_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(OfferapplicationsController::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 Offerapplications updated Successfully.'], 200);
}
// return redirect()->route('offerapplications.index')->with('success','The Offerapplications updated Successfully.');
return redirect()->back()->with('success', 'The Offerapplications updated successfully.');
}
public function destroy(Request $request, $id)
{
createActivityLog(OfferapplicationsController::class, 'destroy', ' Offerapplications destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(OfferapplicationsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status' => true, 'message' => 'The Offerapplications Deleted Successfully.'], 200);
}
public function toggle(Request $request, $id)
{
createActivityLog(OfferapplicationsController::class, 'destroy', ' Offerapplications destroy');
$data = Offerapplications::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(OfferapplicationsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status' => true, 'message' => 'The Offerapplications Deleted Successfully.'], 200);
}
}

View File

@ -0,0 +1,259 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Options;
use App\Service\CommonModelService;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
class OptionsController extends Controller
{
protected $modelService;
public function __construct(Options $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(OptionsController::class, 'index', ' Options index');
$data = Options::where('status', '<>', -1)->orderBy('display_order')->get();
return view("crud.generated.options.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(OptionsController::class, 'create', ' Options create');
$programs = DB::table('programs')
->where('status', '<>', -1)
->orderBy('title') // Sort by title in alphabetical order
->get();
return view("crud.generated.options.create", compact('programs'));
}
public function issued_create(Request $request)
{
createActivityLog(OptionsController::class, 'create', ' Options create');
$programs = DB::table('programs')
->where('status', '<>', -1)
->orderBy('title') // Sort by title in alphabetical order
->get();
return view("crud.generated.options.issued_create", compact('programs'));
}
public function store(Request $request)
{
createActivityLog(OptionsController::class, 'store', 'Options store');
// Validate the request if needed
$validator = Validator::make($request->all(), [
]);
if ($validator->fails()) {
return response()->json([
'error' => $validator->errors(),
], 500);
}
// Get the JavaScript arrays from hidden fields
$programsData = json_decode($request->input('programsData'));
$advicesData = json_decode($request->input('advicesData'));
$descriptionsData = json_decode($request->input('descriptionsData'));
// Initialize an array to store the created option records
$createdOptions = [];
$valid = true;
if (is_int($programsData)) {
$valid = false;
}
// Loop through the JavaScript arrays and save data to the database
if ($valid) {
foreach ($programsData as $key => $programData) {
$programId = $programData;
$advice = isset($advicesData[$key]) ? $advicesData[$key] : '';
$description = isset($descriptionsData[$key]) ? $descriptionsData[$key] : '';
// Your code to save data for each row
$newOption = [
'alias' => slugify($request->title),
'display_order' => getDisplayOrder('tbl_options'),
'created_at' => now(),
'updated_at' => now(),
'students_id' => $request->input('students_id'),
'programs_id' => $programId,
'advice' => $advice,
'description' => $description,
];
// Add the new option to the createdOptions array
$createdOptions[] = $newOption;
}
}
if (!empty($request->input('advices')) && !empty($request->input('descriptions'))) {
$newOption = [
'alias' => slugify($request->title),
'display_order' => getDisplayOrder('tbl_options'),
'created_at' => now(),
'updated_at' => now(),
'students_id' => $request->input('students_id'),
'programs_id' => $request->input('programs_id'),
'advice' => $request->input('advices'),
'description' => $request->input('descriptions'),
];
$createdOptions[] = $newOption;
}
// Now you have an array of options to save
// You can use Eloquent or any other method to save the data to the database
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
// Create option records in a loop
foreach ($createdOptions as $optionData) {
$this->modelService->create($operationNumber, $operationNumber, null, $optionData);
}
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(OptionsController::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 Options Created Successfully.'], 200);
}
return redirect()->route('options.index')->with('success', 'The Options created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Options::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 = Options::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(OptionsController::class, 'show', ' Options show');
$data = Options::where('students_id', $id)->get();
$student_id = $id;
return view("crud.generated.options.show", compact('data', 'student_id'));
}
public function edit(Request $request, $id)
{
createActivityLog(OptionsController::class, 'edit', ' Options edit');
$TableData = Options::where('status', '<>', -1)->orderBy('display_order')->get();
$data = Options::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.options.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.options.edit", compact('data', 'TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(OptionsController::class, 'update', ' Options 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('option_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(OptionsController::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 Options updated Successfully.'], 200);
}
// return redirect()->route('options.index')->with('success','The Options updated Successfully.');
return redirect()->back()->with('success', 'The Options updated successfully.');
}
public function destroy(Request $request, $id)
{
createActivityLog(OptionsController::class, 'destroy', ' Options destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(OptionsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status' => true, 'message' => 'The Options Deleted Successfully.'], 200);
}
public function toggle(Request $request, $id)
{
createActivityLog(OptionsController::class, 'destroy', ' Options destroy');
$data = Options::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(OptionsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status' => true, 'message' => 'The Options Deleted Successfully.'], 200);
}
}

View File

@ -0,0 +1,294 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Campaigns;
use App\Models\Countries;
use App\Models\Registrations;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use setasign\Fpdi\Fpdi;
use Intervention\Image\Facades\Image;
use Endroid\QrCode\Color\Color;
use Endroid\QrCode\Encoding\Encoding;
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelLow;
use Endroid\QrCode\QrCode;
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
use Endroid\QrCode\Writer\PngWriter;
class PdfController extends Controller
{
public function generateMultipagePdf(Request $request, $ids)
{
$registration_ids = $ids;
$ids = explode(",", $ids);
foreach ($ids as $id) {
$data = Registrations::findOrFail($id);
$name = slugify($data->name);
$pdfTemplatePath = public_path(env("CLIENT_PATH") . '/form.pdf');
$filledPdfPath = public_path(env("CLIENT_PATH") . '/generated/' . $name . '-registration-form-' . $id . '.pdf');
if (!file_exists($filledPdfPath)) {
$pdf = new Fpdi();
// Add a page
$pdf->AddPage();
// Set the template file
$pdf->setSourceFile($pdfTemplatePath);
$tplIdx = $pdf->importPage(1);
// Use the template
$pdf->useTemplate($tplIdx);
// Set form field values based on your data
$pdf->SetFont('Arial');
$pdf->SetXY(102, 7);
$pdf->Write(0, $data->name);
$pdf->SetFont('Arial');
$pdf->SetFontSize('7');
$pdf->SetXY(102, 22);
$pdf->Write(0, $data->email);
$pdf->SetXY(162, 22);
$pdf->Write(0, $data->mobile);
$pdf->SetXY(118, 34);
$pdf->Write(0, $data->highest_qualification);
$pdf->SetXY(177, 34);
$pdf->Write(0, ($data->highest_grade) ? $data->highest_grade : "");
$pdf->SetXY(108, 46);
$pdf->Write(0, ($data->preparation_class) ? $data->preparation_class : "");
$pdf->SetXY(177, 46);
$pdf->Write(0, ($data->preparation_score) ? $data->preparation_score : "");
$pdf->SetXY(118, 60);
$pdf->Write(0, ($data->intrested_for_country) ? $data->intrested_for_country : "AAA");
$pdf->SetXY(68, 25);
$pdf->SetFontSize('14');
$pdf->Write(0, ($data->registration_id) ? $data->registration_id : "AAA");
// Repeat the above steps for other form fields
// Output or download the filled PDF
$pdf->Output($filledPdfPath, 'F'); //D for Download
}
}
//return response()->file($filledPdfPath)->deleteFileAfterSend(true);
}
public function generatePdf(Request $request)
{
$registration_id = $request->query('id');
$data = Registrations::findOrFail($registration_id);
$name = slugify($data->name);
$pdfTemplatePath = public_path(env("CLIENT_PATH") . '/inquiry-form-org.pdf');
$filledPdfPath = public_path(env("CLIENT_PATH") . '/generated/' . $name . '-enquiry-form-' . $registration_id . '.pdf');
if (!file_exists($filledPdfPath)) {
$pdf = new Fpdi();
// $pdf->SetMargins(float $left, float $top, float $right = -1, bool $resetPage = true);
$pdf->SetMargins(0,0,0);
$pdf->SetAutoPageBreak(false);
$pdf->AddPage('potrait', 'A5');
$border=0;
$pdf->setSourceFile($pdfTemplatePath);
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx);
$pdf->SetFont('Arial');
$pdf->SetFontSize('7');
$pdf->SetXY(13, 32);
$pdf->Cell(13, 3, "Registration ID: " . (($data->registration_id) ? $data->registration_id : "ID"), $border, 1, "L");
$pdf->SetXY(23, 41.5);
$pdf->Cell(113, 3, ($data->name) ? $data->name : "", $border, 1, "L");
$pdf->SetXY(30, 46.5);
$pdf->Cell(34, 3, ($data->dob) ? $data->dob : "", $border, 1, "L");
$pdf->SetXY(77, 46.5);
$pdf->Cell(15, 3, ($data->gender) ? $data->gender : "", $border, 1, "L");
$pdf->SetXY(111, 46.5);
$pdf->Cell(25, 3, ($data->marital_status) ? $data->marital_status : "", $border, 1, "L");
$pdf->SetXY(39, 52);
$pdf->Cell(37, 3, ($data->mobile) ? $data->mobile : "", $border, 1, "L");
$pdf->SetXY(88, 52);
$pdf->Cell(48, 3, ($data->email) ? $data->email : "", $border, 1, "L");
$pdf->SetXY(26, 57.7);
$pdf->Cell(110, 3, ($data->address) ? $data->address : "", $border, 1, "L");
$pdf->SetXY(37, 63);
$pdf->Cell(56, 3, ($data->guardian_name) ? $data->guardian_name : "", $border, 1, "L");
$pdf->SetXY(106, 63);
$pdf->Cell(30, 3, ($data->phone) ? $data->phone : "", $border, 1, "L");
$pdf->SetXY(53, 69);
$pdf->Cell(83, 3, ($data->applied_before) ? $data->applied_before : "", $border, 1, "L");
$pdf->SetXY(96, 78);
$pdf->Cell(40, 3, $data->highest_qualification, $border, 1, "R"); //$pdf->Cell(float $w, float $h = 0, string $txt = '', mixed $border = 0, int $ln = 0, string $align = '', bool $fill = false, mixed $link = '')
$pdf->SetXY(41, 86.5);
$pdf->Cell(28, 3, ($data->see_stream) ? $data->see_stream : "", $border, 1, "C");
$pdf->SetXY(72, 86.5);
$pdf->Cell(28, 3, ($data->see_school) ? $data->see_school : "", $border, 1, "C");
$pdf->SetXY(102, 86.5);
$pdf->Cell(16.5, 3, ($data->see_grade) ? $data->see_grade : "", $border, 1, "C");
$pdf->SetXY(120.5, 86.5);
$pdf->Cell(15, 3, ($data->see_year) ? $data->see_year : "", $border, 1, "C");
$lineY=91.5;
$pdf->SetXY(41, $lineY);
$pdf->Cell(28, 3, ($data->plus2_stream) ? $data->plus2_stream : "", $border, 1, "C");
$pdf->SetXY(72, $lineY);
$pdf->Cell(28, 3, ($data->plus2_college) ? $data->plus2_college : "", $border, 1, "C");
$pdf->SetXY(102, $lineY);
$pdf->Cell(16.5, 3, ($data->plus2_grade) ? $data->plus2_grade : "", $border, 1, "C");
$pdf->SetXY(120.5, $lineY);
$pdf->Cell(15, 3, ($data->plus2_year) ? $data->plus2_year : "", $border, 1, "C");
$lineY=97;
$pdf->SetXY(41, $lineY);
$pdf->Cell(28, 3, ($data->bachelors_stream) ? $data->bachelors_stream : "", $border, 1, "C");
$pdf->SetXY(72, $lineY);
$pdf->Cell(28, 3, ($data->bachelors_college) ? $data->bachelors_college : "", $border, 1, "C");
$pdf->SetXY(102, $lineY);
$pdf->Cell(16.5, 3, ($data->bachelors_grade) ? $data->bachelors_grade : "", $border, 1, "C");
$pdf->SetXY(120.5, $lineY);
$pdf->Cell(15, 3, ($data->bachelors_year) ? $data->bachelors_year : "", $border, 1, "C");
$lineY=102.5;
$pdf->SetXY(41, $lineY);
$pdf->Cell(28, 3, ($data->highest_stream) ? $data->highest_stream : "", $border, 1, "C");
$pdf->SetXY(72, $lineY);
$pdf->Cell(28, 3, ($data->highest_college) ? $data->highest_college : "", $border, 1, "C");
$pdf->SetXY(102, $lineY);
$pdf->Cell(16.5, 3, ($data->highest_grade) ? $data->highest_grade : "", $border, 1, "C");
$pdf->SetXY(120.5, $lineY);
$pdf->Cell(15, 3, ($data->highest_year) ? $data->highest_year : "", $border, 1, "C");
$pdf->SetXY(36, 109.7);
$pdf->Cell(100, 3, ($data->experience) ? $data->experience : "", $border, 1, "L");
$pdf->SetXY(44, 115.7);
$pdf->Cell(92, 3, ($data->intrested_for_country) ? Countries::where("country_id",$data->intrested_for_country)->first()->title : "", $border, 1, "L");
$pdf->SetXY(36, 123.7);
$pdf->Cell(29, 3, ($data->preparation_class) ? $data->preparation_class : "", $border, 1, "L");
$pdf->SetXY(80, 123.7);
$pdf->Cell(56, 3, ($data->preparation_score) ? $data->preparation_score : "", $border, 1, "L");
$pdf->SetXY(50, 133.5);
$pdf->Cell(38, 3, ($data->how_you_know) ? $data->how_you_know : "", $border, 1, "L");
$pdf->SetXY(105, 133.5);
$pdf->Cell(18, 3, ($data->reference) ? $data->reference : "", $border, 1, "L");
$pdf->SetXY(15, 196);
$pdf->Cell(25, 3, "", $border, 1, "L");
$pdf->SetXY(70, 196);
$pdf->Cell(21, 3, (($data->created_at) ? date('Y-m-d', strtotime($data->created_at)) : "date"), $border, 1, "C");
$pdf->SetXY(120, 196);
$pdf->Cell(25, 3, "", $border, 1, "L");
// $pdf->Cell(0, 10, json_encode($data), 0, 1, 'R');
//$pdf->Write(float $h, string $txt, mixed $link = '');
//$pdf->Cell(float $w, float $h = 0, string $txt = '', mixed $border = 0, int $ln = 0, string $align = '', bool $fill = false, mixed $link = '')
// $pdf->MultiCell(float $w, float $h, string $txt, mixed $border = 0, string $align = 'J', bool $fill = false);
// $pdf->MultiCell(120, 3, json_encode($data), 0, "R", false);
// Repeat the above steps for other form fields
// Output or download the filled PDF
$pdf->Output($filledPdfPath, 'D'); //D for Download
}
}
//return response()->file($filledPdfPath)->deleteFileAfterSend(true);
public function generatePass(Request $request)
{
$registration_id = $request->query('id');
$data = Registrations::findOrFail($registration_id);
$registration = DB::table("registrations")
->where('status', 1)
->where('registration_id', $registration_id)
->orderBy('display_order')
->first();
if (!$registration) {
// Handle the case where the registration is not found
return;
}
$Campaign = Campaigns::findOrFail($registration->campaigns_id);
$QRURL = route("registration.view", md5($registration_id));
$writer = new PngWriter();
$qrCode = QrCode::create($QRURL)
->setEncoding(new Encoding('UTF-8'))
->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
->setSize(150)
->setMargin(1)
->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
->setForegroundColor(new Color(0, 0, 0))
->setBackgroundColor(new Color(255, 255, 255));
$result = $writer->write($qrCode);
$dataUri = $result->getDataUri();
if ($Campaign->pass_layout != "") {
$pass_layout = storage_path(str_replace("storage/", "app/public/", $Campaign->pass_layout));
$backgroundImage = Image::make($pass_layout);
} else {
$backgroundImage = Image::make(public_path(env("CLIENT_PATH") . '/assets/images/pass.png'));
}
$qrCodeImage = Image::make($dataUri);
$qrCodePosition = ($Campaign->qr_position != "") ? $Campaign->qr_position : "100,100";
$qrCodePosition = explode(",", $qrCodePosition);
$backgroundImage->insert($qrCodeImage, 'top-left', $qrCodePosition[0], $qrCodePosition[1]);
$text = $registration->registration_id;
$idPosition = ($Campaign->id_position != "") ? $Campaign->id_position : "100,100";
$idPosition = explode(",", $idPosition);
$fontPath = public_path('assets/fonts/Poppins-Regular.ttf'); // Replace with the actual font path
$backgroundImage->text($text, $idPosition[0], $idPosition[1], function ($font) use ($fontPath) {
$font->file($fontPath);
$font->size(16);
$font->color('#000');
$font->align('left');
$font->valign('top');
});
$text = $registration->name;
$namePosition = ($Campaign->name_position != "") ? $Campaign->name_position : "100,100";
$namePosition = explode(",", $namePosition);
$fontPath = public_path('assets/fonts/Poppins-Regular.ttf'); // Replace with the actual font path
$backgroundImage->text($text, $namePosition[0], $namePosition[1], function ($font) use ($fontPath) {
$font->file($fontPath);
$font->size(24);
$font->color('#ffffff');
$font->align('left');
$font->valign('top');
});
$text = $registration->email;
$emailPosition = ($Campaign->email_position != "") ? $Campaign->email_position : "100,100";
$emailPosition = explode(",", $emailPosition);
$fontPath = public_path('assets/fonts/Poppins-Regular.ttf'); // Replace with the actual font path
$backgroundImage->text($text, $emailPosition[0], $emailPosition[1], function ($font) use ($fontPath) {
$font->file($fontPath);
$font->size(20);
$font->color('#fff');
$font->align('left');
$font->valign('top');
});
$outputPath = public_path(env("CLIENT_PATH") . '/assets/images/generated/pass_' . date("ymdhis") . '_image.png');
$backgroundImage->save($outputPath);
$qr_code=$outputPath;
$downloadFileName = env("CLIENT_PATH").'_pass.png';
return response()->download($qr_code, $downloadFileName);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Programs;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class ProgramsController extends Controller
{
protected $modelService;
public function __construct(Programs $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(ProgramsController::class, 'index', ' Programs index');
$data = Programs::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.programs.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(ProgramsController::class, 'create', ' Programs create');
$TableData = Programs::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.programs.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(ProgramsController::class, 'store', ' Programs 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_programs')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(ProgramsController::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 Programs Created Successfully.'], 200);
}
return redirect()->route('programs.index')->with('success','The Programs created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Programs::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 = Programs::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(ProgramsController::class, 'show', ' Programs show');
$data = Programs::findOrFail($id);
return view("crud.generated.programs.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(ProgramsController::class, 'edit', ' Programs edit');
$TableData = Programs::where('status','<>',-1)->orderBy('display_order')->get();
$data = Programs::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.programs.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.programs.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(ProgramsController::class, 'update', ' Programs 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('program_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(ProgramsController::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 Programs updated Successfully.'], 200);
}
// return redirect()->route('programs.index')->with('success','The Programs updated Successfully.');
return redirect()->back()->with('success', 'The Programs updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(ProgramsController::class, 'destroy', ' Programs destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(ProgramsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Programs Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(ProgramsController::class, 'destroy', ' Programs destroy');
$data = Programs::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(ProgramsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Programs Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Provinces;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class ProvincesController extends Controller
{
protected $modelService;
public function __construct(Provinces $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(ProvincesController::class, 'index', ' Provinces index');
$data = Provinces::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.provinces.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(ProvincesController::class, 'create', ' Provinces create');
$TableData = Provinces::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.provinces.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(ProvincesController::class, 'store', ' Provinces 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_provinces')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(ProvincesController::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 Provinces Created Successfully.'], 200);
}
return redirect()->route('provinces.index')->with('success','The Provinces created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Provinces::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 = Provinces::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(ProvincesController::class, 'show', ' Provinces show');
$data = Provinces::findOrFail($id);
return view("crud.generated.provinces.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(ProvincesController::class, 'edit', ' Provinces edit');
$TableData = Provinces::where('status','<>',-1)->orderBy('display_order')->get();
$data = Provinces::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.provinces.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.provinces.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(ProvincesController::class, 'update', ' Provinces 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('province_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(ProvincesController::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 Provinces updated Successfully.'], 200);
}
// return redirect()->route('provinces.index')->with('success','The Provinces updated Successfully.');
return redirect()->back()->with('success', 'The Provinces updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(ProvincesController::class, 'destroy', ' Provinces destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(ProvincesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Provinces Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(ProvincesController::class, 'destroy', ' Provinces destroy');
$data = Provinces::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(ProvincesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Provinces Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Qualifications;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class QualificationsController extends Controller
{
protected $modelService;
public function __construct(Qualifications $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(QualificationsController::class, 'index', ' Qualifications index');
$data = Qualifications::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.qualifications.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(QualificationsController::class, 'create', ' Qualifications create');
$TableData = Qualifications::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.qualifications.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(QualificationsController::class, 'store', ' Qualifications 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_qualifications')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(QualificationsController::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 Qualifications Created Successfully.'], 200);
}
return redirect()->route('qualifications.index')->with('success','The Qualifications created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Qualifications::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 = Qualifications::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(QualificationsController::class, 'show', ' Qualifications show');
$data = Qualifications::findOrFail($id);
return view("crud.generated.qualifications.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(QualificationsController::class, 'edit', ' Qualifications edit');
$TableData = Qualifications::where('status','<>',-1)->orderBy('display_order')->get();
$data = Qualifications::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.qualifications.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.qualifications.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(QualificationsController::class, 'update', ' Qualifications 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('qualification_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(QualificationsController::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 Qualifications updated Successfully.'], 200);
}
// return redirect()->route('qualifications.index')->with('success','The Qualifications updated Successfully.');
return redirect()->back()->with('success', 'The Qualifications updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(QualificationsController::class, 'destroy', ' Qualifications destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(QualificationsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Qualifications Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(QualificationsController::class, 'destroy', ' Qualifications destroy');
$data = Qualifications::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(QualificationsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Qualifications Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,380 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Mail\CustomMailer;
use App\Models\Agents;
use App\Models\Campaigns;
use App\Models\Countries;
use App\Models\Leadcategories;
use Illuminate\Http\Request;
use App\Models\Registrations;
use App\Models\Sources;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Log;
use App\Service\CommonModelService;
use Exception;
use Illuminate\Support\Facades\Mail;
use LMS;
use NewRegistrationAdminNotification;
class RegistrationsController extends Controller
{
protected $modelService;
public function __construct(Registrations $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
$data = $this->filterRegistrations($request);
return view("crud.generated.registrations.index", compact('data', 'request'));
}
public function bycampaign(Request $request, $CampaignAlias)
{
$Campaign = Campaigns::where("status", 1)->where("alias", $CampaignAlias)->first();
$title = "Registrations By Campaign : " . $Campaign->title;
$data = $this->filterRegistrations($request, $Campaign);
return view("crud.generated.registrations.index", compact('data', 'title', 'request'));
}
public function bycategory(Request $request, $CategoryAlias)
{
$LeadCategory = Leadcategories::where("alias", $CategoryAlias)->first();
$title = "Registrations By Lead Category : " . $LeadCategory->title;
$data = $this->filterRegistrations($request, null, $LeadCategory);
$reques = $request->all();
return view("crud.generated.registrations.index", compact('data', 'title', 'request'));
}
public function bysource(Request $request, $SourceAlias)
{
$Source = Sources::where("alias", $SourceAlias)->first();
$title = "Registrations By Source : " . $Source->title;
$data = $this->filterRegistrations($request, null, null, $Source);
$reques = $request->all();
return view("crud.generated.registrations.index", compact('data', 'title', 'request'));
}
public function bycountry(Request $request, $CountryAlias)
{
$Country = Countries::where("alias", $CountryAlias)->first();
$title = "Registrations By Country : " . $Country->title;
$data = $this->filterRegistrations($request, null, null, null, $Country);
$reques = $request->all();
return view("crud.generated.registrations.index", compact('data', 'title', 'request'));
}
public function byagent(Request $request, $AgentAlias)
{
$Agent = Agents::where("alias", $AgentAlias)->first();
$title = "Registrations By Agency : " . $Agent->title;
$data = $this->filterRegistrations($request, null, null, null, null, $Agent);
$reques = $request->all();
return view("crud.generated.registrations.index", compact('data', 'title', 'request'));
}
private function filterRegistrations($request, $Campaign = null, $LeadCategory = null, $Source = null, $Country = null, $Agent = null)
{
DB::enableQueryLog();
$requestData = $request->all();
// dd($requestData);
$data = Registrations::where('status', '<>', -1);
if (isset($requestData['from']) && $requestData['from']) {
$data = $data->whereDate("created_at", ">=", $requestData['from']);
}
if (isset($requestData['to'])) {
$data = $data->whereDate("created_at", "<", $requestData['to']);
}
if (isset($requestData['source_id']) && $requestData['source_id'] != 0) {
$data = $data->where("sources_id", "=", $requestData['source_id']);
}
if (isset($requestData['country_id']) && $requestData['country_id'] != 0) {
$data = $data->where("countries_id", "=", $requestData['country_id']);
}
if (isset($requestData['leadcategory_id']) && $requestData['leadcategory_id']) {
$data = $data->where("leadcategories_id", "=", $requestData['leadcategory_id']);
}
if ($Campaign !== null) {
$data = $data->where("campaigns_id", $Campaign->campaign_id);
}
if ($LeadCategory !== null) {
$data = $data->where("leadcategories_id", $LeadCategory->leadcategory_id);
}
if ($Source !== null) {
$data = $data->where("sources_id", $Source->source_id);
}
if ($Country !== null) {
$data = $data->where("countries_id", $Country->country_id);
}
if ($Agent !== null) {
$data = $data->where("agents_id", $Agent->agent_id);
}
$data = $data->orderBy('display_order');
$sqlQuery = $data->toSql();
$data = $data->get();
$data->RawQuery = DB::getQueryLog();
return $data;
}
public function create(Request $request)
{
createActivityLog(RegistrationsController::class, 'create', ' Registrations create');
$TableData = Registrations::where('status', '<>', -1)->orderBy('display_order')->get();
return view("crud.generated.registrations.create", compact('TableData'));
}
public function store(Request $request)
{
$validator = Validator::make($request->all(), [
'mobile' => 'required|numeric|unique:registrations,mobile', // Assuming 'users' is your table name and 'mobile' is the column
]);
$Campaign = Campaigns::findOrFail($request->campaigns_id);
if ($validator->fails()) {
$existingRegistration = Registrations::where('mobile', $request->mobile)->first();
if ($existingRegistration) {
return response()->json([
'status' => true,
'message' => 'Mobile number already exists. Returning existing data.',
'registration' => $existingRegistration,
'registration_id' => $existingRegistration->registration_id,
], 200);
}
return response()->json([
'status' => false,
'errors' => $validator->errors(),
'message' => 'Form validation failed.',
], 200); // 422 Unprocessable Entity
}
$request->request->add(['alias' => slugify($request->title)]);
$request->request->add(['display_order' => getDisplayOrder('tbl_registrations')]);
$request->request->add(['intrested_for_country' => $request->preferred_destination]);
$request->request->add(['sources_id' => ($request->sources_id) ? $request->sources_id : 2]);
$request->request->add(['campaigns_id' => ($request->campaigns_id) ? $request->campaigns_id : SITEVARS->Campaigns[0]->campaign_id]);
$request->request->add(['countries_id' => $request->countries_id]);
$request->request->add(['remarks' => $request->message]);
$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();
$registration = $this->modelService->create($operationNumber, $operationNumber, null, $requestData);
if (env("SEND_EMAIL")) {
$mailer = new CustomMailer($requestData);
Mail::bcc("prajwalbro@hotmail.com")->send($mailer->build());
Mail::to($request['email'])->send($mailer->build());
$notify_emails = isset($Campaign->notify_emails) ? explode(",", $Campaign->notify_emails) : "prajwalbro@hotmail.com";
Mail::cc($notify_emails)->send($mailer->build());
}
$msg = $Campaign->sms_message;
$success_messsage = $Campaign->success_messsage;
if (env("SEND_SMS")) {
$success_messsage = str_replace('%name%', $request['name'], $success_messsage);
$msg = str_replace('%name%', $request['name'], $msg);
LMS::oldsendSMSWithCurl($requestData['mobile'], $msg);
}
LMS::SaveInGoogleSheet($requestData);
} catch (\Exception $e) {
dd($e->getMessage());
DB::rollBack();
}
DB::commit();
return response()->json([
'status' => true,
'message' => ($success_messsage) ? $success_messsage : 'The Registration Created Successfully.',
'registration_id' => $registration->registration_id,
], 200);
}
function sendbulksms(Request $request)
{
$validator = Validator::make($request->all(), [
'message' => 'required', // Assuming 'users' is your table name and 'mobile' is the column
]);
if ($validator->fails()) {
return response()->json([
'status' => false,
'errors' => $validator->errors(),
'message' => 'Form validation failed.',
], 200); // 422 Unprocessable Entity
}
$mobile_nos = explode(",", $request->mobile);
//dd($mobile_nos);
$msg = $request->message;
foreach ($mobile_nos as $mobile) {
LMS::sendSMSWithCurl($mobile, $msg);
}
}
public function home(Request $request, $campaign_alias = null)
{
switch ($campaign_alias) {
case 'office': // Student/Visitor office visit gareko bela, MOBILE bata QR Scan garera fill garne
return view(env("CLIENT_PATH") . ".home");
case 'spin_the_wheel': // Student/Visitor office visit gareko bela, MOBILE bata QR Scan garera fill garne
return view("games.spin_the_wheel.game");
case 'direct': //Office ko Reception Bata directly fill-in garne form
return view("backend.reception");
case 'online': //Adv etc run garda online default landing bata fill-in garne form
return view(env("CLIENT_PATH") . ".home");
default:
if ($campaign_alias != "") {
$Campaign = LMS::getCampaignByAlias($campaign_alias);
} else {
$Campaign = LMS::getActiveCampaign();
}
if ($Campaign != null) {
$viewPath = env("CLIENT_PATH") . ".landing";
if (view()->exists($viewPath))
return view($viewPath, compact("Campaign"));
else
return view(env("CLIENT_PATH") . '.home', compact("Campaign"));
} else {
$Campaign = LMS::getActiveCampaign();
$viewPath = env("CLIENT_PATH") . ".landing";
if (view()->exists($viewPath))
return view($viewPath, compact("Campaign"));
else
return view(env("CLIENT_PATH") . '.home', compact("Campaign"));
}
}
}
public function reception(Request $request)
{
//Office ko Reception Bata directly fill-in garne form
return view("backend.reception");
}
public function reception_registrations(Request $request)
{
$data = $this->filterRegistrations($request);
//Office ko Reception Bata directly fill-in garne form
return view("backend.reception.registrations", compact('data'));
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Registrations::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 = Registrations::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 view($id)
{
$data = '';
$data = Registrations::where(DB::raw('md5(registration_id)'), $id)->firstOrFail();
return view("lms.view", compact('data'));
}
public function confirmation($id)
{
$data = '';
$data = Registrations::where(DB::raw('md5(registration_id)'), $id)->firstOrFail();
return view("lms.confirmation", compact('data'));
}
public function show(Request $request, $id)
{
createActivityLog(RegistrationsController::class, 'show', ' Registrations show');
$data = Registrations::findOrFail($id);
return view("crud.generated.registrations.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(RegistrationsController::class, 'edit', ' Registrations edit');
$TableData = Registrations::where('status', '<>', -1)->orderBy('display_order')->get();
$data = Registrations::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.registrations.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.registrations.edit", compact('data', 'TableData'));
}
public function ajaxedit(Request $request, $id)
{
createActivityLog(RegistrationsController::class, 'edit', ' Registrations edit');
$TableData = Registrations::where('status', '<>', -1)->orderBy('display_order')->get();
$data = Registrations::findOrFail($id);
return view("crud.generated.registrations.ajaxedit", compact('data', 'TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(RegistrationsController::class, 'update', ' Registrations 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('registration_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(RegistrationsController::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 Registrations updated Successfully.'], 200);
}
// return redirect()->route('registrations.index')->with('success','The Registrations updated Successfully.');
return redirect()->back()->with('success', 'The Registrations updated successfully.');
}
public function destroy(Request $request, $id)
{
createActivityLog(RegistrationsController::class, 'destroy', ' Registrations destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(RegistrationsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status' => true, 'message' => 'The Registrations Deleted Successfully.'], 200);
}
public function toggle(Request $request, $id)
{
createActivityLog(RegistrationsController::class, 'destroy', ' Registrations destroy');
$data = Registrations::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(RegistrationsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status' => true, 'message' => 'The Registrations Deleted Successfully.'], 200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Requireddocuments;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class RequireddocumentsController extends Controller
{
protected $modelService;
public function __construct(Requireddocuments $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(RequireddocumentsController::class, 'index', ' Requireddocuments index');
$data = Requireddocuments::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.requireddocuments.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(RequireddocumentsController::class, 'create', ' Requireddocuments create');
$TableData = Requireddocuments::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.requireddocuments.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(RequireddocumentsController::class, 'store', ' Requireddocuments 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_requireddocuments')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(RequireddocumentsController::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 Requireddocuments Created Successfully.'], 200);
}
return redirect()->route('requireddocuments.index')->with('success','The Requireddocuments created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Requireddocuments::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 = Requireddocuments::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(RequireddocumentsController::class, 'show', ' Requireddocuments show');
$data = Requireddocuments::findOrFail($id);
return view("crud.generated.requireddocuments.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(RequireddocumentsController::class, 'edit', ' Requireddocuments edit');
$TableData = Requireddocuments::where('status','<>',-1)->orderBy('display_order')->get();
$data = Requireddocuments::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.requireddocuments.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.requireddocuments.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(RequireddocumentsController::class, 'update', ' Requireddocuments 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('requireddocument_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(RequireddocumentsController::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 Requireddocuments updated Successfully.'], 200);
}
// return redirect()->route('requireddocuments.index')->with('success','The Requireddocuments updated Successfully.');
return redirect()->back()->with('success', 'The Requireddocuments updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(RequireddocumentsController::class, 'destroy', ' Requireddocuments destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(RequireddocumentsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Requireddocuments Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(RequireddocumentsController::class, 'destroy', ' Requireddocuments destroy');
$data = Requireddocuments::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(RequireddocumentsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Requireddocuments Deleted Successfully.'],200);
}
}

View 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);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Sources;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class SourcesController extends Controller
{
protected $modelService;
public function __construct(Sources $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(SourcesController::class, 'index', ' Sources index');
$data = Sources::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.sources.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(SourcesController::class, 'create', ' Sources create');
$TableData = Sources::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.sources.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(SourcesController::class, 'store', ' Sources 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_sources')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(SourcesController::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 Sources Created Successfully.'], 200);
}
return redirect()->route('sources.index')->with('success','The Sources created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Sources::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 = Sources::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(SourcesController::class, 'show', ' Sources show');
$data = Sources::findOrFail($id);
return view("crud.generated.sources.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(SourcesController::class, 'edit', ' Sources edit');
$TableData = Sources::where('status','<>',-1)->orderBy('display_order')->get();
$data = Sources::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.sources.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.sources.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(SourcesController::class, 'update', ' Sources 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('source_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(SourcesController::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 Sources updated Successfully.'], 200);
}
// return redirect()->route('sources.index')->with('success','The Sources updated Successfully.');
return redirect()->back()->with('success', 'The Sources updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(SourcesController::class, 'destroy', ' Sources destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(SourcesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Sources Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(SourcesController::class, 'destroy', ' Sources destroy');
$data = Sources::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(SourcesController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Sources Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Spinthewheelwinners;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class SpinthewheelwinnersController extends Controller
{
protected $modelService;
public function __construct(Spinthewheelwinners $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(SpinthewheelwinnersController::class, 'index', ' Spinthewheelwinners index');
$data = Spinthewheelwinners::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.spinthewheelwinners.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(SpinthewheelwinnersController::class, 'create', ' Spinthewheelwinners create');
$TableData = Spinthewheelwinners::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.spinthewheelwinners.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(SpinthewheelwinnersController::class, 'store', ' Spinthewheelwinners 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_spinthewheelwinners')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(SpinthewheelwinnersController::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 Spinthewheelwinners Created Successfully.'], 200);
}
return redirect()->route('spinthewheelwinners.index')->with('success','The Spinthewheelwinners created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Spinthewheelwinners::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 = Spinthewheelwinners::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(SpinthewheelwinnersController::class, 'show', ' Spinthewheelwinners show');
$data = Spinthewheelwinners::findOrFail($id);
return view("crud.generated.spinthewheelwinners.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(SpinthewheelwinnersController::class, 'edit', ' Spinthewheelwinners edit');
$TableData = Spinthewheelwinners::where('status','<>',-1)->orderBy('display_order')->get();
$data = Spinthewheelwinners::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.spinthewheelwinners.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.spinthewheelwinners.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(SpinthewheelwinnersController::class, 'update', ' Spinthewheelwinners 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('spinthewheelwinner_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(SpinthewheelwinnersController::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 Spinthewheelwinners updated Successfully.'], 200);
}
// return redirect()->route('spinthewheelwinners.index')->with('success','The Spinthewheelwinners updated Successfully.');
return redirect()->back()->with('success', 'The Spinthewheelwinners updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(SpinthewheelwinnersController::class, 'destroy', ' Spinthewheelwinners destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(SpinthewheelwinnersController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Spinthewheelwinners Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(SpinthewheelwinnersController::class, 'destroy', ' Spinthewheelwinners destroy');
$data = Spinthewheelwinners::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(SpinthewheelwinnersController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Spinthewheelwinners Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,287 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Agents;
use App\Models\Campaigns;
use App\Models\Countries;
use App\Models\Leadcategories;
use App\Models\Sources;
use Illuminate\Http\Request;
use App\Models\Students;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
class StudentsController extends Controller
{
protected $modelService;
public function __construct(Students $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(StudentsController::class, 'index', ' Students index');
$data = Students::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.students.index", compact('data'));
}
public function bycampaign(Request $request, $CampaignAlias)
{
$Campaign = Campaigns::where("status", 1)->where("alias", $CampaignAlias)->first();
$title = "Students By Campaign : " . $Campaign->title;
$data = $this->filterStudents($request, $Campaign);
return view("crud.generated.students.index", compact('data', 'title', 'request'));
}
public function bycategory(Request $request, $CategoryAlias)
{
$LeadCategory = Leadcategories::where("alias", $CategoryAlias)->first();
$title = "Registrations By Lead Category : " . $LeadCategory->title;
$data = $this->filterStudents($request, null, $LeadCategory);
$reques = $request->all();
return view("crud.generated.students.index", compact('data', 'title', 'request'));
}
public function bysource(Request $request, $SourceAlias)
{
$Source = Sources::where("alias", $SourceAlias)->first();
$title = "Registrations By Source : " . $Source->title;
$data = $this->filterStudents($request, null, null, $Source);
$reques = $request->all();
return view("crud.generated.students.index", compact('data', 'title', 'request'));
}
public function bycountry(Request $request, $CountryAlias)
{
$Country = Countries::where("alias", $CountryAlias)->first();
$title = "Registrations By Country : " . $Country->title;
$data = $this->filterStudents($request, null, null, null, $Country);
$reques = $request->all();
return view("crud.generated.students.index", compact('data', 'title', 'request'));
}
public function byagent(Request $request, $AgentAlias)
{
$Agent = Agents::where("alias", $AgentAlias)->first();
$title = "Registrations By Agency : " . $Agent->title;
$data = $this->filterStudents($request, null, null, null, null, $Agent);
$reques = $request->all();
return view("crud.generated.students.index", compact('data', 'title', 'request'));
}
private function filterStudents($request, $Campaign = null, $LeadCategory = null, $Source = null, $Country = null, $Agent = null)
{
DB::enableQueryLog();
$requestData = $request->all();
// dd($requestData);
$data = Students::where('status', '<>', -1);
if (isset($requestData['from']) && $requestData['from']) {
$data = $data->whereDate("created_at", ">=", $requestData['from']);
}
if (isset($requestData['to'])) {
$data = $data->whereDate("created_at", "<", $requestData['to']);
}
if (isset($requestData['source_id']) && $requestData['source_id'] != 0) {
$data = $data->where("sources_id", "=", $requestData['source_id']);
}
if (isset($requestData['country_id']) && $requestData['country_id'] != 0) {
$data = $data->where("countries_id", "=", $requestData['country_id']);
}
if (isset($requestData['leadcategory_id']) && $requestData['leadcategory_id']) {
$data = $data->where("leadcategories_id", "=", $requestData['leadcategory_id']);
}
if ($Campaign !== null) {
$data = $data->where("campaigns_id", $Campaign->campaign_id);
}
if ($LeadCategory !== null) {
$data = $data->where("leadcategories_id", $LeadCategory->leadcategory_id);
}
if ($Source !== null) {
$data = $data->where("sources_id", $Source->source_id);
}
if ($Country !== null) {
$data = $data->where("countries_id", $Country->country_id);
}
if ($Agent !== null) {
$data = $data->where("agents_id", $Agent->agent_id);
}
$data = $data->orderBy('display_order');
$sqlQuery = $data->toSql();
$data = $data->get();
$data->RawQuery = DB::getQueryLog();
return $data;
}
public function create(Request $request)
{
createActivityLog(StudentsController::class, 'create', ' Students create');
$TableData = Students::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.students.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(StudentsController::class, 'store', ' Students 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_students')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL').'/', '', $value);
});
array_walk_recursive($requestData, function (&$value) {
$value = str_replace(env('APP_URL'), '', $value);
});
DB::beginTransaction();
try {
$operationNumber = getOperationNumber();
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
} catch (\Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(StudentsController::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 Students Created Successfully.'], 200);
}
return redirect()->route('students.index')->with('success','The Students created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Students::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 = Students::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(StudentsController::class, 'show', ' Students show');
$data = Students::findOrFail($id);
return view("crud.generated.students.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(StudentsController::class, 'edit', ' Students edit');
$TableData = Students::where('status','<>',-1)->orderBy('display_order')->get();
$data = Students::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.students.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.students.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(StudentsController::class, 'update', ' Students 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('student_id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(StudentsController::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 Students updated Successfully.'], 200);
}
// return redirect()->route('students.index')->with('success','The Students updated Successfully.');
return redirect()->back()->with('success', 'The Students updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(StudentsController::class, 'destroy', ' Students destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(StudentsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Students Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(StudentsController::class, 'destroy', ' Students destroy');
$data = Students::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(StudentsController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Students Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,162 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Http\Requests\User\UserRequest;
use App\Modules\Service\Permission\PermissionService;
use App\Modules\Service\Role\RoleService;
use App\Modules\Service\User\UserService;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
use Illuminate\Http\Request;
class UserController extends Controller
{
protected $user, $role, $permission;
function __construct(UserService $user, RoleService $role, PermissionService $permission)
{
$this->user = $user;
$this->role = $role;
$this->permission = $permission;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$user = $this->user->paginate();
return view('user.index',compact('user'));
}
public function getAllData()
{
// dd($this->user);
return $this->user->getAllData();
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
$roles =$this->role->paginate();
$permissions =$this->permission->paginate();
return view('user.create',compact('roles','permissions'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(UserRequest $request)
{
if($user = $this->user->create($request->all())) {
if($request->hasFile('image')) {
$this->uploadFile($request, $user);
}
$user->assignRole($request->input('roles'));
// $user->syncPermissions($request->input('permissions'));
Toastr()->success('User Created Successfully','Success');
return redirect()->route('user.index');
}
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
$user = $this->user->getBySlug($id);
$userRoles =$this->user->getUserRoles($user->id);
$roles =$this->role->paginate();
return view('user.edit',compact('user','roles','userRoles'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
$user = $this->user->find($id);
$input = $request->except('roles');
$user->syncRoles($request->input('roles'));
$user = $this->user->update($id,$input);
return redirect()->route('user.index');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
$user = $this->user->delete($id);
return response()->json(['status'=>true]);
}
public function profileUpdate() {
return view('user.profile-update');
}
public function profileUpdateStore(Request $request, $id) {
if($user = $this->user->profileUpdate($request->all(), $id)) {
// $user->syncPermissions($request->input('permissions'));
Toastr()->success('User Profile Updated Successfully','Success');
return redirect()->route('dashboard');
}
}
public function forgetPassword(Request $request) {
return view('auth.passwords.reset');
}
public function updatePassword(Request $request) {
$user = $this->user->passwordUpdate($request->all());
if($user == true) {
Toastr()->success('Password has been Updated Successfully','Success');
return redirect()->route('login');
} else {
return redirect()->back();
}
}
}

View File

@ -0,0 +1,204 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Users;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Service\CommonModelService;
use Log;
use Exception;
use Illuminate\Support\Facades\Hash;
class UsersController extends Controller
{
protected $modelService;
public function __construct(Users $model)
{
$this->modelService = new CommonModelService($model);
}
public function index(Request $request)
{
createActivityLog(UsersController::class, 'index', ' Users index');
$data = Users::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.users.index", compact('data'));
}
public function create(Request $request)
{
createActivityLog(UsersController::class, 'create', ' Users create');
$TableData = Users::where('status','<>',-1)->orderBy('display_order')->get();
return view("crud.generated.users.create",compact('TableData'));
}
public function store(Request $request)
{
createActivityLog(UsersController::class, 'store', ' Users 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_users')]);
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
$requestData=$request->all();
if (isset($requestData['password'])) {
$requestData['password'] = Hash::make($requestData['password']);
}
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(UsersController::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 Users Created Successfully.'], 200);
}
return redirect()->route('users.index')->with('success','The Users created Successfully.');
}
public function sort(Request $request)
{
$idOrder = $request->input('id_order');
foreach ($idOrder as $index => $id) {
$companyArticle = Users::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 = Users::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(UsersController::class, 'show', ' Users show');
$data = Users::findOrFail($id);
return view("crud.generated.users.show", compact('data'));
}
public function edit(Request $request, $id)
{
createActivityLog(UsersController::class, 'edit', ' Users edit');
$TableData = Users::where('status','<>',-1)->orderBy('display_order')->get();
$data = Users::findOrFail($id);
if ($request->ajax()) {
$html = view("crud.generated.users.ajax.edit", compact('data'))->render();
return response()->json(['status' => true, 'content' => $html], 200);
}
return view("crud.generated.users.edit", compact('data','TableData'));
}
public function update(Request $request, $id)
{
createActivityLog(UsersController::class, 'update', ' Users 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('id'));
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(UsersController::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 Users updated Successfully.'], 200);
}
// return redirect()->route('users.index')->with('success','The Users updated Successfully.');
return redirect()->back()->with('success', 'The Users updated successfully.');
}
public function destroy(Request $request,$id)
{
createActivityLog(UsersController::class, 'destroy', ' Users destroy');
DB::beginTransaction();
try {
$OperationNumber = getOperationNumber();
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
} catch (Exception $e) {
DB::rollBack();
Log::info($e->getMessage());
createErrorLog(UsersController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Users Deleted Successfully.'],200);
}
public function toggle(Request $request,$id)
{
createActivityLog(UsersController::class, 'destroy', ' Users destroy');
$data = Users::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(UsersController::class, 'destroy', $e->getMessage());
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
}
DB::commit();
return response()->json(['status'=>true,'message'=>'The Users Deleted Successfully.'],200);
}
}

View File

@ -0,0 +1,421 @@
<?php
namespace App\Http\Controllers;
use CCMS;
use Exception;
use Illuminate\Http\Request; // Import the Request class
use Illuminate\Support\Facades\DB;
class WebsiteController extends Controller
{
private $path;
public function __construct(){
$this->path = config("app.client_path");
}
public function home(){
return view($this->path.".home");
}
public static function index(Request $request, $menu_id = "")
{
$pathInfo = ltrim($request->getPathInfo(), '/');
$r = explode('/', $pathInfo);
$menu_alias = end($r);
$menu_alias1 = str_replace("_", "-", $menu_alias);
$menuItem = DB::table("menuitems")->where("alias", $menu_alias)->orWhere("alias", $menu_alias1)->get()[0];
switch ($menuItem->type) {
case 'tbl_contacts':
$contact = DB::table("contacts")->where("contact_id", $menuItem->ref)->get()[0];
return view("client.jupiter.inside.contact", compact('contact'));
// break;
case 'tbl_countries':
//$countries=DB::table("countries")->where("article_id",$menuItem->ref)->get()[0];
//return view("client.jupiter.inside.article",compact('article'));
//break;
case 'tbl_articles':
$article = DB::table("articles")->where("article_id", $menuItem->ref)->get()[0];
return view("client.jupiter.inside.article", compact('article'));
//break;
case '':
default:
// echo $menuItem->alias;die;
if ($menuItem->ref == "/")
return view("client.jupiter.welcome");
else if ($menuItem->ref == "#")
return view("client.jupiter.welcome");
else
return view("client.jupiter.inside" . ltrim($menuItem->ref));
}
}
function showDestinations(Request $r)
{
return view(env("CLIENT_PATH") . ".destinations");
}
function showDestination(Request $r, $alias, $subalias = null)
{
$data = DB::table("countries")->where("alias", $alias)->first();
$data->Childrens = DB::table("countryarticles")
->where("countries_id", $data->country_id)
->whereNotIn("article_id", function ($query) {
$query->select("parent_article")
->from("countryarticles");
})
->whereNotIn("article_id", function ($query) use ($alias) {
$query->select("article_id")
->from("countryarticles")->where("parent_article", function ($query) use ($alias) {
$query->select("article_id")
->from("countryarticles")->where("alias", "top-reasons-to-" . $alias);
});
})
->get();
if ($subalias) {
$data->Article = DB::table("countryarticles")->where("alias", $subalias)->first();
$siblings = DB::table("countryarticles")
->where("countries_id", $data->country_id)
->where("article_id", "<>", $data->Article->article_id)
->whereNotIn("article_id", function ($query) {
$query->select("parent_article")
->from("countryarticles");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".destination.inside", compact('data'));
}
switch ($alias) {
case 'study-in-new-zealand':
return view(env("CLIENT_PATH") . ".destination.new-zealand", compact('data'));
case 'study-in-australia':
return view(env("CLIENT_PATH") . ".destination.australia", compact('data'));
case 'study-in-canada':
return view(env("CLIENT_PATH") . ".destination.canada", compact('data'));
case 'study-in-uk':
return view(env("CLIENT_PATH") . ".destination.uk", compact('data'));
case 'study-in-usa':
return view(env("CLIENT_PATH") . ".destination.usa", compact('data'));
default:
return view(env("CLIENT_PATH") . ".destination.single",compact('data'));
}
}
function showpreparationclasses(Request $r)
{
return view(env("CLIENT_PATH") . ".preparationclasses.preparationclasses");
}
function showpreparationclass(Request $r, $alias, $subalias = null)
{
try {
$data = DB::table("preparationclasses")->where("alias", $alias)->first();
$data->Childrens = DB::table("preparationclasses")->where("parent_preparationclass", $data->preparationclass_id)->get();
if ($subalias) {
$data->Article = DB::table("preparationclasses")->where("alias", $subalias)->first();
$siblings = DB::table("preparationclasses")
->where("parent_preparationclass", $data->preparationclass_id)
->where("preparationclass_id", "<>", $data->Article->preparationclass_id)
->whereNotIn("preparationclass_id", function ($query) {
$query->select("parent_preparationclass")
->from("preparationclasses");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".preparationclasses.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".preparationclasses.single", compact('data'));
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showresources(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("resources")->where("alias", $alias)->first();
$data->Childrens = DB::table("resources")->where("parent_resource", $data->resource_id)->get();
if ($subalias) {
$data->Article = DB::table("resources")->where("alias", $subalias)->first();
$siblings = DB::table("resources")
->where("parent_resource", $data->resource_id)
->where("resource_id", "<>", $data->Article->resource_id)
->whereNotIn("resource_id", function ($query) {
$query->select("parent_resource")
->from("resources");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".resources.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".resources.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".resources.resources");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showblogs(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("blogs")->where("alias", $alias)->first();
$data->Childrens = DB::table("blogs")->where("parent_blog", $data->blog_id)->get();
if ($subalias) {
$data->Article = DB::table("blogs")->where("alias", $subalias)->first();
$siblings = DB::table("blogs")
->where("parent_blog", $data->blog_id)
->where("blog_id", "<>", $data->Article->blog_id)
->whereNotIn("blog_id", function ($query) {
$query->select("parent_blog")
->from("blogs");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".blogs.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".blogs.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".blogs.blogs");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showfaqs(Request $r, $alias = null, $subalias = null)
{
try {
return view(env("CLIENT_PATH") . ".faqs");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showservices(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("services")->where("alias", $alias)->first();
$data->Childrens = DB::table("services")->where("parent_service", $data->service_id)->get();
if ($subalias) {
$data->Article = DB::table("services")->where("alias", $subalias)->first();
$siblings = DB::table("services")
->where("parent_service", $data->service_id)
->where("service_id", "<>", $data->Article->service_id)
->whereNotIn("service_id", function ($query) {
$query->select("parent_service")
->from("services");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".services.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".services.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".services.services");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showevents(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("events")->where("alias", $alias)->first();
$data->Childrens = DB::table("events")->where("parent_event", $data->event_id)->get();
if ($subalias) {
$data->Article = DB::table("events")->where("alias", $subalias)->first();
$siblings = DB::table("events")
->where("parent_event", $data->blog_id)
->where("event_id", "<>", $data->Article->event_id)
->whereNotIn("event_id", function ($query) {
$query->select("parent_event")
->from("events");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".events.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".events.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".events.events");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function shownews(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("news")->where("alias", $alias)->first();
$data->Childrens = DB::table("news")->where("parent_news", $data->news_id)->get();
if ($subalias) {
$data->Article = DB::table("news")->where("alias", $subalias)->first();
$siblings = DB::table("news")
->where("parent_news", $data->blog_id)
->where("news_id", "<>", $data->Article->news_id)
->whereNotIn("news_id", function ($query) {
$query->select("parent_news")
->from("news");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".news.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".news.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".news.list");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showprofile(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("articles")->where("alias", $alias)->first();
$data->Childrens = DB::table("articles")->where("parent_article", $data->article_id)->get();
if ($subalias) {
$data->Article = DB::table("articles")->where("alias", $subalias)->first();
$siblings = DB::table("articles")
->where("parent_article", $data->article_id)
->where("article_id", "<>", $data->Article->article_id)
->whereNotIn("article_id", function ($query) {
$query->select("parent_article")
->from("articles");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".articles.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".articles.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".articles.list");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showsuccessstories(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("successstories")->where("alias", $alias)->first();
return view(env("CLIENT_PATH") . ".successstories.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".successstories.list");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showsuccessstories", $e->getMessage());
echo $e->getMessage();
}
}
function showoffices(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("branches")->where("alias", $alias)->first();
$data->Childrens = DB::table("brancharticles")->where("status", 1)->where("branches_id", $data->branch_id)->get();
if ($subalias) {
$data->Article = DB::table("articles")->where("alias", $subalias)->first();
$siblings = DB::table("articles")
->where("parent_article", $data->article_id)
->where("article_id", "<>", $data->Article->article_id)
->whereNotIn("article_id", function ($query) {
$query->select("parent_article")
->from("articles");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".articles.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".offices.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".offices.list");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showcontact(Request $r, $alias = null, $subalias = null)
{
try {
return view(env("CLIENT_PATH") . ".contact");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showgalleries(Request $r, $alias = null, $subalias = null)
{
try {
return view(env("CLIENT_PATH") . ".galleries.list");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showapplyform(Request $r, $alias = null, $subalias = null)
{
try {
return view(env("CLIENT_PATH") . ".forms.apply");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
}

68
app/Http/Kernel.php Normal file
View 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,
];
}

View 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');
}
}

View 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 = [
//
];
}

View 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 = [
//
];
}

View 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);
}
}

View 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',
];
}

View 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(),
];
}
}

View 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;
}

View 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',
];
}

View 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 = [
//
];
}

View File

@ -0,0 +1,54 @@
<?php
namespace App\Http\Requests\Admission;
use Illuminate\Foundation\Http\FormRequest;
class AdmissionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'student_id'=>'required',
'country_id' => 'required|',
'state_id' => 'required|',
'college_id' => 'required|',
'fees' => 'required|',
'intake_year' => 'required|',
'intake_month' => 'required|',
];
return $rules;
}
public function data()
{
$data = [
'student_id' => $this->get('student_id'),
'college_id' => $this->get('college_id'),
'fees' => $this->get('fees'),
'country_id' => $this->get('country_id'),
'state_id' => $this->get('state_id'),
'intake_year' => $this->get('intake_year'),
'intake_month' => $this->get('intake_month'),
];
return $data;
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace App\Http\Requests\Agent;
use Illuminate\Foundation\Http\FormRequest;
class AgentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
];
}
public function data()
{
$data = [
'name' => $this->get('name'),
'email' => $this->get('email'),
'phone' => $this->get('phone'),
];
return $data;
}
}

View 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());
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace App\Http\Requests\Campaign;
use Illuminate\Foundation\Http\FormRequest;
class CampaignRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'name'=>'required'
];
return $rules;
}
public function data(){
$inputs=[
'name' => $this->get('name'),
'alias' => $this->get('alias'),
'details' => $this->get('details'),
'starts' => $this->get('starts'),
'ends' => $this->get('ends'),
'success_message' => $this->get('success_message'),
'email_success' => $this->get('email_success'),
'sms_message' => $this->get('sms_message'),
'coupon_codes' => $this->get('coupon_codes'),
'url' => $this->get('url'),
'keywords' => $this->get('keywords'),
'ogtags' => $this->get('ogtags'),
'headers' => $this->get('headers'),
'description' => $this->get('description'),
'status' => ($this->get('status') ? $this->get('status') : '') == 'on' ? 'active' : 'in_active',
'created_by' => Auth()->user()->id,
];
if($this->get('offered_course')) {
$offered_course = collect($this->get('offered_course'));
}
if(isset($offered_course)) {
$inputs['offered_course'] = $offered_course->implode(',');
}
if($this->get('keywords')) {
$keywords = collect($this->get('keywords'));
}
if(isset($keywords)) {
$inputs['keywords'] = $keywords->implode(',');
}
if ($this->has('status')) {
$inputs['status'] = "active";
}
return $inputs;
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\DocumentCheckList;
use Illuminate\Foundation\Http\FormRequest;
class DocumentCheckListRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'applicant' => 'required',
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Permission;
use Illuminate\Foundation\Http\FormRequest;
class PermissionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'name'=>'required'
];
return $rules;
}
}

View 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)],
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests\Role;
use Illuminate\Foundation\Http\FormRequest;
class RoleRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'name'=>'required'
];
return $rules;
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests\Student;
use Illuminate\Foundation\Http\FormRequest;
class StudentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'applicant' => 'required',
];
}
public function data()
{
$data = [
'applicant' => $this->get('applicant'),
'email' => $this->get('email'),
'phone' => $this->get('phone'),
'program' => $this->get('program'),
'intake_year' => $this->get('intake_year'),
'intake_month' => $this->get('intake_month'),
];
return $data;
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Requests\User;
use Illuminate\Foundation\Http\FormRequest;
class UserRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'name'=>'required',
'email' => 'required|email|unique:users,email',
'password' => 'required|',
];
return $rules;
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace App\Jobs;
use App\Mail\SendNewsLetterMail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;
class SendNewsLetterJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
protected $registration,$newsletter;
public function __construct($registration, $newsletter)
{
//
$this->registration = $registration;
$this->newsletter = $newsletter;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
$registration = $this->registration ;
$newsletter = $this->newsletter;
Mail::to($registration->email)->later(10,new SendNewsLetterMail($registration,$newsletter));
}
}

52
app/Jobs/SendSMSJob.php Normal file
View File

@ -0,0 +1,52 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SendSMSJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
protected $registration,$campaign,$sms_message;
public function __construct($registration, $campaign, $sms_message)
{
//
$this->registration = $registration;
$this->campaign = $campaign;
$this->sms_message = $sms_message;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
$registration = $this->registration;
$campaign = $this->campaign;
$sms_message = $this->sms_message;
$url = setting('sms_api') ?? 'https://sms.aakashsms.com/sms/v3/send';
$data = array(
'auth_token' => setting('sms_token') ?? '28a22c64768a49ee5f539fa2924a8c278bb9ff16d7798496adbb87278d1c7e70',
'from' => setting('sms_from') ?? '31001',
'to' => $registration->phone,
'text' => $sms_message
);
$response = smsPost($url, $data);
}
}

45
app/Mail/CustomMailer.php Normal file
View File

@ -0,0 +1,45 @@
<?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 build()
{
$t = $this->subject('Congratulations !!!')->markdown(env("CLIENT_PATH").'.emails.registration-completed', ['formData' => $this->formData]);
if (isset($formData['qr_code_path'])) {
$t = $t->attach($this->formData['qr_code_path']);
}
return $t;
}
public function registration_completed()
{
// dd($this->formData);
return $this->subject('Recived a new online enquiry from our website.')->markdown(env("CLIENT_PATH").'.emails.registration-completed', $this->formData);
}
public function enquiryform()
{
return $this->subject('Recived a new online enquiry from our website.')->markdown(env("CLIENT_PATH").'.emails.enquiry-submitted', $this->formData);
}
public function enquiryresponse()
{
return $this->subject('Thankyou from ' . env('APP_NAME'))->markdown(env("CLIENT_PATH").'.emails.enquiry-response', $this->formData);
}
}

View File

@ -0,0 +1,49 @@
<?php
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class NewRegistrationAdminNotification extends Mailable
{
use Queueable, SerializesModels;
public $registration;
public function __construct($registration)
{
$this->registration = $registration;
}
public function build()
{
$smtpSettings = [
'driver' => 'smtp',
'host' => SITEVARS->smtp_server,
'port' => SITEVARS->smtp_port,
'from' => ['address' => SITEVARS->smtp_user, 'name' => 'Admin'],
'encryption' => SITEVARS->smtp_security,
'username' => SITEVARS->smtp_user,
'password' => SITEVARS->smtp_password,
];
Config::set('mail', $smtpSettings);
return $this->from(config('mail.from.address'))
->subject('New Registration Created')
->view('emails.new_registration_admin_notification');
}
public function registrationSuccess()
{
$smtpSettings = [
'driver' => 'smtp',
'host' => SITEVARS->smtp_server,
'port' => SITEVARS->smtp_port,
'from' => ['address' => SITEVARS->smtp_user, 'name' => 'Admin'],
'encryption' => SITEVARS->smtp_security,
'username' => SITEVARS->smtp_user,
'password' => SITEVARS->smtp_password,
];
Config::set('mail', $smtpSettings);
return $this->from(config('mail.from.address'))
->subject('New Registration Created')
->view('emails.new_registration_admin_notification');
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class SendContactInfo extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$data = $this->data;
return $this->from($this->data['email_address'], $this->data['full_name'])->view('mail.contact',compact('data'));
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class SendNewsLetterMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
protected $registration,$newsletter;
public function __construct($registration, $newsletter)
{
//
$this->registration = $registration;
$this->newsletter = $newsletter;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$registration = $this->registration ;
$newsletter = $this->newsletter;
return $this->from('noreply@consultancy.com','Consultancy')->view('mail.sendnewsletter',compact('registration','newsletter'));
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class StudentEnquiryMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data, $emaildeliver, $registration)
{
$this->data = $data;
$this->emaildeliver = $emaildeliver;
$this->registration = $registration;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$data = $this->data;
$emaildeliver = $this->emaildeliver;
$registration = $this->registration;
return $this->from($this->data['email'], $this->data['name'])->view('mail.registrationenquiry',compact('data','emaildeliver','registration'));
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class StudentNotifyMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$data = $this->data;
return $this->from("webmaster@accessedu.net", "Access Education Network - Event Registrations")->view('mail.notifystudent',compact('data'));
}
}

50
app/Models/Agents.php Normal file
View 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 Agents extends Model
{
use HasFactory, CreatedUpdatedBy;
protected $primaryKey = 'agent_id';
public $timestamps = true;
protected $fillable =[
'title',
'alias',
'description',
'display_order',
'status',
'remarks',
'created_at',
'createdby',
'updated_at',
'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 : '',
);
}
}

57
app/Models/Branches.php Normal file
View File

@ -0,0 +1,57 @@
<?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 Branches extends Model
{
use HasFactory, CreatedUpdatedBy;
protected $primaryKey = 'branch_id';
public $timestamps = true;
protected $fillable =[
'title',
'alias',
'description',
'email',
'telephone',
'phone1',
'phone2',
'address',
'company_reg',
'is_main',
'display_order',
'status',
'remarks',
'created_at',
'createdby',
'updated_at',
'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 : '',
);
}
}

View File

@ -0,0 +1,54 @@
<?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 Campaignarticles extends Model
{
use HasFactory, CreatedUpdatedBy;
protected $primaryKey = 'campaignarticle_id';
public $timestamps = true;
protected $fillable =[
'campaigns_id',
'parent_article',
'title',
'alias',
'text',
'link',
'cover_photo',
'thumb',
'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 : '',
);
}
}

73
app/Models/Campaigns.php Normal file
View File

@ -0,0 +1,73 @@
<?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 Campaigns extends Model
{
use HasFactory, CreatedUpdatedBy;
protected $primaryKey = 'campaign_id';
public $timestamps = true;
protected $fillable = [
'title',
'alias',
'description',
'details',
'cover_photo',
'thumb',
'starts',
'ends',
'success_message',
'sms_message',
'coupon_codes',
'offered_choices',
'og_image',
'seo_title',
'seo_keywords',
'seo_description',
'meta_tags',
'display_order',
'status',
'remarks',
'created_at',
'createdby',
'updated_at',
'updatedby',
'pass_layout',
'qr_position',
'id_position',
'name_position',
'email_position',
'notify_emails',
'google_sheet_id',
'google_sheet_worksheet',
];
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 : '',
);
}
}

51
app/Models/Cities.php Normal file
View File

@ -0,0 +1,51 @@
<?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 Cities extends Model
{
use HasFactory, CreatedUpdatedBy;
protected $primaryKey = 'city_id';
public $timestamps = true;
protected $fillable =[
'districts_id',
'title',
'alias',
'description',
'display_order',
'status',
'remarks',
'created_at',
'createdby',
'updated_at',
'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 : '',
);
}
}

55
app/Models/Contactus.php Normal file
View File

@ -0,0 +1,55 @@
<?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 Contactus extends Model
{
use HasFactory, CreatedUpdatedBy;
protected $primaryKey = 'inquiries_id';
public $timestamps = true;
protected $table = 'contactus';
protected $fillable = [
'title',
'email',
'phone',
'country_interested',
'study_background',
'terms_and_condition',
'display_order',
'status',
'remarks',
'created_at',
'createdby',
'updated_at',
'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 : '',
);
}
}

Some files were not shown because too many files have changed in this diff Show More