Compare commits
7 Commits
8a9cb39352
...
4eace5b650
Author | SHA1 | Date | |
---|---|---|---|
4eace5b650 | |||
09222c8a3a | |||
6b6696ded4 | |||
4f34db3381 | |||
cfd2147536 | |||
da9f493572 | |||
c792d0a7e0 |
18
.htaccess
Normal file
18
.htaccess
Normal file
@ -0,0 +1,18 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} -d [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -f
|
||||
RewriteRule ^ ^$1 [N]
|
||||
|
||||
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
|
||||
RewriteRule ^(.*)$ public/$1
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ server.php
|
||||
</IfModule>
|
0
Modules/Attendance/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Attendance/app/Http/Controllers/.gitkeep
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Attendance\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class AttendanceController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('attendance::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('attendance::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('attendance::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('attendance::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
0
Modules/Attendance/app/Http/Requests/.gitkeep
Normal file
0
Modules/Attendance/app/Http/Requests/.gitkeep
Normal file
0
Modules/Attendance/app/Models/.gitkeep
Normal file
0
Modules/Attendance/app/Models/.gitkeep
Normal file
0
Modules/Attendance/app/Providers/.gitkeep
Normal file
0
Modules/Attendance/app/Providers/.gitkeep
Normal file
114
Modules/Attendance/app/Providers/AttendanceServiceProvider.php
Normal file
114
Modules/Attendance/app/Providers/AttendanceServiceProvider.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Attendance\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AttendanceServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'Attendance';
|
||||
|
||||
protected string $moduleNameLower = 'attendance';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerCommandSchedules();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
// $this->app->booted(function () {
|
||||
// $schedule = $this->app->make(Schedule::class);
|
||||
// $schedule->command('inspire')->hourly();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/'.$this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
|
||||
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/'.$this->moduleNameLower);
|
||||
$sourcePath = module_path($this->moduleName, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
|
||||
$componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder','')));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
|
||||
$paths[] = $path.'/modules/'.$this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
49
Modules/Attendance/app/Providers/RouteServiceProvider.php
Normal file
49
Modules/Attendance/app/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Attendance\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')->group(module_path('Attendance', '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Attendance', '/routes/api.php'));
|
||||
}
|
||||
}
|
0
Modules/Attendance/app/Repositories/.gitkeep
Normal file
0
Modules/Attendance/app/Repositories/.gitkeep
Normal file
30
Modules/Attendance/composer.json
Normal file
30
Modules/Attendance/composer.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "nwidart/attendance",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Attendance\\": "app/",
|
||||
"Modules\\Attendance\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\Attendance\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\Attendance\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/Attendance/config/.gitkeep
Normal file
0
Modules/Attendance/config/.gitkeep
Normal file
5
Modules/Attendance/config/config.php
Normal file
5
Modules/Attendance/config/config.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Attendance',
|
||||
];
|
0
Modules/Attendance/database/factories/.gitkeep
Normal file
0
Modules/Attendance/database/factories/.gitkeep
Normal file
0
Modules/Attendance/database/migrations/.gitkeep
Normal file
0
Modules/Attendance/database/migrations/.gitkeep
Normal file
0
Modules/Attendance/database/seeders/.gitkeep
Normal file
0
Modules/Attendance/database/seeders/.gitkeep
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Attendance\database\seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AttendanceDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// $this->call([]);
|
||||
}
|
||||
}
|
11
Modules/Attendance/module.json
Normal file
11
Modules/Attendance/module.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Attendance",
|
||||
"alias": "attendance",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Attendance\\Providers\\AttendanceServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
15
Modules/Attendance/package.json
Normal file
15
Modules/Attendance/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^1.1.2",
|
||||
"laravel-vite-plugin": "^0.7.5",
|
||||
"sass": "^1.69.5",
|
||||
"postcss": "^8.3.7",
|
||||
"vite": "^4.0.0"
|
||||
}
|
||||
}
|
0
Modules/Attendance/resources/assets/.gitkeep
Normal file
0
Modules/Attendance/resources/assets/.gitkeep
Normal file
0
Modules/Attendance/resources/assets/js/app.js
Normal file
0
Modules/Attendance/resources/assets/js/app.js
Normal file
0
Modules/Attendance/resources/assets/sass/app.scss
Normal file
0
Modules/Attendance/resources/assets/sass/app.scss
Normal file
0
Modules/Attendance/resources/views/.gitkeep
Normal file
0
Modules/Attendance/resources/views/.gitkeep
Normal file
7
Modules/Attendance/resources/views/index.blade.php
Normal file
7
Modules/Attendance/resources/views/index.blade.php
Normal file
@ -0,0 +1,7 @@
|
||||
@extends('attendance::layouts.master')
|
||||
|
||||
@section('content')
|
||||
<h1>Hello World</h1>
|
||||
|
||||
<p>Module: {!! config('attendance.name') !!}</p>
|
||||
@endsection
|
29
Modules/Attendance/resources/views/layouts/master.blade.php
Normal file
29
Modules/Attendance/resources/views/layouts/master.blade.php
Normal file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
<title>Attendance Module - {{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<meta name="description" content="{{ $description ?? '' }}">
|
||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
||||
<meta name="author" content="{{ $author ?? '' }}">
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
||||
|
||||
{{-- Vite CSS --}}
|
||||
{{-- {{ module_vite('build-attendance', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-attendance', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
0
Modules/Attendance/routes/.gitkeep
Normal file
0
Modules/Attendance/routes/.gitkeep
Normal file
19
Modules/Attendance/routes/api.php
Normal file
19
Modules/Attendance/routes/api.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Attendance\Http\Controllers\AttendanceController;
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------------------
|
||||
* API Routes
|
||||
*--------------------------------------------------------------------------
|
||||
*
|
||||
* Here is where you can register API routes for your application. These
|
||||
* routes are loaded by the RouteServiceProvider within a group which
|
||||
* is assigned the "api" middleware group. Enjoy building your API!
|
||||
*
|
||||
*/
|
||||
|
||||
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
|
||||
Route::apiResource('attendance', AttendanceController::class)->names('attendance');
|
||||
});
|
19
Modules/Attendance/routes/web.php
Normal file
19
Modules/Attendance/routes/web.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Attendance\Http\Controllers\AttendanceController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group([], function () {
|
||||
Route::resource('attendance', AttendanceController::class)->names('attendance');
|
||||
});
|
26
Modules/Attendance/vite.config.js
Normal file
26
Modules/Attendance/vite.config.js
Normal file
@ -0,0 +1,26 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: '../../public/build-attendance',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-attendance',
|
||||
input: [
|
||||
__dirname + '/resources/assets/sass/app.scss',
|
||||
__dirname + '/resources/assets/js/app.js'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
//export const paths = [
|
||||
// 'Modules/Attendance/resources/assets/sass/app.scss',
|
||||
// 'Modules/Attendance/resources/assets/js/app.js',
|
||||
//];
|
@ -5,16 +5,24 @@ namespace Modules\Employee\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Employee\Repositories\EmployeeInterface;
|
||||
|
||||
class EmployeeController extends Controller
|
||||
{
|
||||
|
||||
private EmployeeInterface $employeeRepository;
|
||||
|
||||
public function __construct(EmployeeInterface $employeeRepository)
|
||||
{
|
||||
$this->employeeRepository = $employeeRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('employee::index');
|
||||
$data['employees'] = $this->employeeRepository->findAll();
|
||||
return view('employee::index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -22,15 +30,32 @@ class EmployeeController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('employee::create');
|
||||
$data['title'] = 'Create Employee';
|
||||
return view('employee::create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$inputData = $request->only(['first_name', 'last_name']);
|
||||
// try {
|
||||
|
||||
if ($request->hasFile('profile_pic')) {
|
||||
$fileName = time() . '_' . $request->profile_pic->getClientOriginalName();
|
||||
$filePath = $request->file('profile_pic')->storeAs('uploads', $fileName, 'public');
|
||||
$inputData['profile_picture'] = time() . '_' . $request->profile_pic->getClientOriginalName();
|
||||
// $fileModel->file_path = '/storage/' . $filePath;
|
||||
// $fileModel->save();
|
||||
}
|
||||
|
||||
$this->employeeRepository->create($inputData);
|
||||
toastr()->success('Employee Created Succesfully');
|
||||
// } catch (\Throwable $th) {
|
||||
// toastr()->error($th->getMessage());
|
||||
// }
|
||||
return redirect()->route('employee.index');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,6 +63,7 @@ class EmployeeController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
return view('employee::show');
|
||||
}
|
||||
|
||||
@ -46,7 +72,9 @@ class EmployeeController extends Controller
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('employee::edit');
|
||||
$data['title'] = 'Edit Employee';
|
||||
$data['employee'] = $this->employeeRepository->getEmployeeById($id);
|
||||
return view('employee::edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +82,21 @@ class EmployeeController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
//
|
||||
$inputData = $request->only(['first_name', 'last_name']);
|
||||
// try {
|
||||
|
||||
if ($request->hasFile('profile_pic')) {
|
||||
$fileName = time() . '_' . $request->profile_pic->getClientOriginalName();
|
||||
$filePath = $request->file('profile_pic')->storeAs('uploads', $fileName, 'public');
|
||||
$inputData['profile_picture'] = time() . '_' . $request->profile_pic->getClientOriginalName();
|
||||
}
|
||||
|
||||
$this->employeeRepository->update($id, $inputData);
|
||||
toastr()->success('Employee Created Succesfully');
|
||||
// } catch (\Throwable $th) {
|
||||
// toastr()->error($th->getMessage());
|
||||
// }
|
||||
return redirect()->route('employee.index');
|
||||
}
|
||||
|
||||
/**
|
||||
|
0
Modules/Employee/app/Http/Requests/.gitkeep
Normal file
0
Modules/Employee/app/Http/Requests/.gitkeep
Normal file
@ -6,8 +6,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Employee extends Model
|
||||
{
|
||||
protected $table = 'employees';
|
||||
protected $primaryKey = 'employee_id';
|
||||
protected $table = 'tbl_employees';
|
||||
protected $primaryKey = 'id';
|
||||
protected $guarded = [];
|
||||
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class EmployeeServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/'.$this->moduleNameLower);
|
||||
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
@ -75,7 +75,7 @@ class EmployeeServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower . '.php')], 'config');
|
||||
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
@ -84,14 +84,14 @@ class EmployeeServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/'.$this->moduleNameLower);
|
||||
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
||||
$sourcePath = module_path($this->moduleName, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']);
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower . '-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
|
||||
$componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder','')));
|
||||
$componentNamespace = str_replace('/', '\\', config('modules.namespace') . '\\' . $this->moduleName . '\\' . ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', '')));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
@ -107,8 +107,8 @@ class EmployeeServiceProvider extends ServiceProvider
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
|
||||
$paths[] = $path.'/modules/'.$this->moduleNameLower;
|
||||
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
||||
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,6 @@ interface EmployeeInterface
|
||||
public function findAll();
|
||||
public function getEmployeeById($employeeId);
|
||||
public function delete($employeeId);
|
||||
public function create(array $EmployeeDetails);
|
||||
public function create($EmployeeDetails);
|
||||
public function update($employeeId, array $newDetails);
|
||||
}
|
||||
|
@ -21,8 +21,9 @@ class EmployeeRepository implements EmployeeInterface
|
||||
Employee::destroy($employeeId);
|
||||
}
|
||||
|
||||
public function create(array $employeeDetails)
|
||||
public function create($employeeDetails)
|
||||
{
|
||||
// dd($employeeDetails);
|
||||
return Employee::create($employeeDetails);
|
||||
}
|
||||
|
||||
@ -31,4 +32,18 @@ class EmployeeRepository implements EmployeeInterface
|
||||
return Employee::whereId($employeeId)->update($newDetails);
|
||||
}
|
||||
|
||||
// public function uploadImage($file)
|
||||
// {
|
||||
// if ($req->file()) {
|
||||
// $fileName = time() . '_' . $req->file->getClientOriginalName();
|
||||
// $filePath = $req->file('file')->storeAs('uploads', $fileName, 'public');
|
||||
// $fileModel->name = time() . '_' . $req->file->getClientOriginalName();
|
||||
// $fileModel->file_path = '/storage/' . $filePath;
|
||||
// $fileModel->save();
|
||||
// return back()
|
||||
// ->with('success', 'File has been uploaded.')
|
||||
// ->with('file', $fileName);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
0
Modules/Employee/database/factories/.gitkeep
Normal file
0
Modules/Employee/database/factories/.gitkeep
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tbl_employees', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('first_name')->nullable();
|
||||
$table->string('middle_name')->nullable();
|
||||
$table->string('last_name')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->unsignedBigInteger('genders_id')->nullable();
|
||||
$table->date('nepali_dob')->nullable();
|
||||
$table->date('dob')->nullable();
|
||||
$table->unsignedBigInteger('nationalities_id')->nullable();
|
||||
$table->text('about_me')->nullable();
|
||||
$table->string('signature')->nullable();
|
||||
$table->string('father_name')->nullable();
|
||||
$table->string('mother_name')->nullable();
|
||||
$table->string('grand_father_name')->nullable();
|
||||
$table->string('grand_mother_name')->nullable();
|
||||
$table->string('spouse')->nullable();
|
||||
$table->string('contact')->nullable();
|
||||
$table->string('alt_contact')->nullable();
|
||||
$table->string('profile_picture')->nullable();
|
||||
$table->unsignedBigInteger('users_id')->nullable();
|
||||
$table->text('skills')->nullable();
|
||||
$table->text('experience')->nullable();
|
||||
$table->text('permanent_address')->nullable();
|
||||
$table->unsignedBigInteger('permanent_city')->nullable();
|
||||
$table->text('temporary_address')->nullable();
|
||||
$table->unsignedBigInteger('temporary_city')->nullable();
|
||||
$table->text('old_system_address')->nullable();
|
||||
$table->text('education')->nullable();
|
||||
$table->unsignedBigInteger('castes_id')->nullable();
|
||||
$table->unsignedBigInteger('ethnicities_id')->nullable();
|
||||
$table->unsignedBigInteger('dags_id')->nullable();
|
||||
$table->string('status')->nullable();
|
||||
$table->string('remarks')->nullable();
|
||||
$table->unsignedBigInteger('createdby')->nullable();
|
||||
$table->unsignedBigInteger('updatedby')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('employees');
|
||||
}
|
||||
};
|
21
Modules/Employee/resources/views/create.blade.php
Normal file
21
Modules/Employee/resources/views/create.blade.php
Normal file
@ -0,0 +1,21 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
@include('layouts.partials.breadcrumb', ['title' => $title])
|
||||
<!-- end page title -->
|
||||
|
||||
{{ html()->form('POST')->route('employee.store')->class(['needs-validation'])->attributes(['novalidate', 'enctype' => 'multipart/form-data'])->open() }}
|
||||
@include('employee::partials.action')
|
||||
{{ html()->form()->close() }}
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
22
Modules/Employee/resources/views/edit.blade.php
Normal file
22
Modules/Employee/resources/views/edit.blade.php
Normal file
@ -0,0 +1,22 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
@include('layouts.partials.breadcrumb', ['title' => $title])
|
||||
<!-- end page title -->
|
||||
|
||||
{{-- {{ html()->form('POST')->route('employee.store')->class(['needs-validation'])->attributes(['novalidate', 'enctype' => 'multipart/form-data'])->open() }} --}}
|
||||
{{ html()->modelForm($employee, 'PUT')->route('employee.update', $employee->id)->class(['needs-validation'])->attributes(['novalidate', 'enctype' => 'multipart/form-data'])->open() }}
|
||||
@include('employee::partials.action')
|
||||
{{ html()->closeModelForm() }}
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
File diff suppressed because it is too large
Load Diff
147
Modules/Employee/resources/views/partials/action.blade.php
Normal file
147
Modules/Employee/resources/views/partials/action.blade.php
Normal file
@ -0,0 +1,147 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header card-primary">
|
||||
<h4 class="card-title mb-0">Personal Details</h4>
|
||||
</div>
|
||||
|
||||
<div class="card-body row gy-4">
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('First name')->class('form-label') }}
|
||||
{{ html()->text('first_name')->class('form-control')->placeholder('Enter First Name')->required() }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Middle name')->class('form-label') }}
|
||||
{{ html()->text('middle_name')->class('form-control')->placeholder('Enter Middle Name') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Last name')->class('form-label') }}
|
||||
{{ html()->text('last_name')->class('form-control')->placeholder('Enter Last Name')->required() }}
|
||||
{{ html()->div('Please enter last name')->class('invalid-feedback') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Gender')->class('form-label') }}
|
||||
{{ html()->select('gender', ['male', 'female'])->class('form-select')->placeholder('Select Gender') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Date of Birth')->class('form-label') }}
|
||||
{{ html()->date('dob')->class('form-control')->placeholder('Choose Date of Birth')->required() }}
|
||||
{{ html()->div('Please choose dob')->class('invalid-feedback') }}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Nationality')->class('form-label') }}
|
||||
{{ html()->select('nationality', ['Nepal', 'Other'])->class('form-control')->placeholder('Select Nationality') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Email')->class('form-label') }}
|
||||
{{ html()->email('email')->class('form-control')->placeholder('Enter Email')->required() }}
|
||||
{{ html()->div('Please enter email')->class('invalid-feedback') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Phone Number')->class('form-label') }}
|
||||
{{ html()->text('phone')->class('form-control')->placeholder('Enter Phone Number') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Upload Profile Pic')->class('form-label') }}
|
||||
{{ html()->file('profile_pic')->class('form-control') }}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- end card body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header card-primary">
|
||||
<h5 class="card-title mb-0">Address Detail</h5>
|
||||
</div>
|
||||
<div class="card-body row gy-2">
|
||||
{{-- <div class="col-md-4">
|
||||
{{ html()->label('Country')->class('form-label') }}
|
||||
{{ html()->select('country_id', ['Nepal'])->class('form-select')->placeholder('Select Country') }}
|
||||
</div> --}}
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('State')->class('form-label') }}
|
||||
{{ html()->select('state_id', ['Nepal'])->class('form-select')->placeholder('Select State') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('District name')->class('form-label') }}
|
||||
{{ html()->select('district_id', [])->class('form-select')->placeholder('Select District') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('City')->class('form-label') }}
|
||||
{{ html()->text('last_name')->class('form-control')->placeholder('Enter City Name') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('municipality')->class('form-label') }}
|
||||
{{ html()->select('municipality_id', [])->class('form-select')->placeholder('Select Municipality') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Ward')->class('form-label') }}
|
||||
{{ html()->text('ward')->class('form-control')->placeholder('Enter Ward no') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Permanent Address')->class('form-label') }}
|
||||
{{ html()->text('perm_address')->class('form-control')->placeholder('Enter Permanent Address') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Temporary Address')->class('form-label') }}
|
||||
{{ html()->text('temp_address')->class('form-control')->placeholder('Enter Temporary Address') }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header card-primary">
|
||||
<h5 class="card-title mb-0">Organization Detail</h5>
|
||||
</div>
|
||||
<div class="card-body row gy-2">
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Department')->class('form-label') }}
|
||||
{{ html()->select('department_id', ['Nepal'])->class('form-select')->placeholder('Select Department') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Designation')->class('form-label') }}
|
||||
{{ html()->select('designation_id', ['Nepal'])->class('form-select')->placeholder('Select Designation') }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Join Date')->class('form-label') }}
|
||||
{{ html()->date('join_date')->class('form-control')->placeholder('Choose Join Date') }}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-8">
|
||||
{{ html()->label('Remarks')->class('form-label') }}
|
||||
{{ html()->textarea('remark')->class('form-control')->placeholder('Enter Remarks') }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- end card -->
|
||||
<div class="mb-4 text-end">
|
||||
<button type="submit" class="btn btn-success w-sm">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
@ -4,21 +4,7 @@
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
|
||||
<h4 class="mb-sm-0">{{ $title }}</h4>
|
||||
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
|
||||
<li class="breadcrumb-item active">{{ $title }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@include('layouts.partials.breadcrumb', ['title' => $title])
|
||||
<!-- end page title -->
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
|
@ -84,8 +84,9 @@
|
||||
<a href="{{ route('leave.edit', $leave->leave_id) }}"
|
||||
class="link-success fs-15 edit-item-btn"><i class="ri-edit-2-line"></i></a>
|
||||
|
||||
<a href="{{ route('leave.destroy', $leave->leave_id) }}" data-id="{{ $leave->leave_id }}"
|
||||
class="link-danger fs-15 remove-item-btn"><i class="ri-delete-bin-line"></i></a>
|
||||
<a href="javascript:void(0);" data-link="{{ route('leave.destroy', $leave->leave_id) }}"
|
||||
data-id="{{ $leave->leave_id }}" class="link-danger fs-15 remove-item-btn"><i
|
||||
class="ri-delete-bin-line"></i></a>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
@ -98,48 +99,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!--end row-->
|
||||
</div>
|
||||
<!--end row-->
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
@include('leave::partials.view')
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
$('.remove-item-btn').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
let url = $(this).attr('href');
|
||||
let id = $(this).data('id');
|
||||
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You won't be able to revert this!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
success: function(response) {
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
0
Modules/User/app/Http/Controllers/.gitkeep
Normal file
0
Modules/User/app/Http/Controllers/.gitkeep
Normal file
90
Modules/User/app/Http/Controllers/UserController.php
Normal file
90
Modules/User/app/Http/Controllers/UserController.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\User\Repositories\UserRepository;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
|
||||
protected $userRepository;
|
||||
|
||||
public function __construct(UserRepository $userRepository){
|
||||
$this->userRepository = $userRepository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = User::latest()->get();
|
||||
$editable = false;
|
||||
return view('user::index', compact('data', 'editable'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = "Create User";
|
||||
$data['users'] = User::latest()->get();
|
||||
return view('user::create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'name' => 'required|min:5',
|
||||
'email' => 'required',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
$user = $this->userRepository->create($validatedData, $request->role);
|
||||
toastr()->success('User has been created!');
|
||||
return redirect()->route('users.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return view('user::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = "Edit User";
|
||||
$data['user'] = User::findOrFail($id);
|
||||
return view('user::edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
0
Modules/User/app/Http/Requests/.gitkeep
Normal file
0
Modules/User/app/Http/Requests/.gitkeep
Normal file
0
Modules/User/app/Models/.gitkeep
Normal file
0
Modules/User/app/Models/.gitkeep
Normal file
0
Modules/User/app/Providers/.gitkeep
Normal file
0
Modules/User/app/Providers/.gitkeep
Normal file
49
Modules/User/app/Providers/RouteServiceProvider.php
Normal file
49
Modules/User/app/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')->group(module_path('User', '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('User', '/routes/api.php'));
|
||||
}
|
||||
}
|
114
Modules/User/app/Providers/UserServiceProvider.php
Normal file
114
Modules/User/app/Providers/UserServiceProvider.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class UserServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'User';
|
||||
|
||||
protected string $moduleNameLower = 'user';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerCommandSchedules();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
// $this->app->booted(function () {
|
||||
// $schedule = $this->app->make(Schedule::class);
|
||||
// $schedule->command('inspire')->hourly();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/'.$this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
|
||||
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/'.$this->moduleNameLower);
|
||||
$sourcePath = module_path($this->moduleName, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
|
||||
$componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder','')));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
|
||||
$paths[] = $path.'/modules/'.$this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
0
Modules/User/app/Repositories/.gitkeep
Normal file
0
Modules/User/app/Repositories/.gitkeep
Normal file
12
Modules/User/app/Repositories/UserInterface.php
Normal file
12
Modules/User/app/Repositories/UserInterface.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Repositories;
|
||||
|
||||
interface UserInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getUserById($userId);
|
||||
public function delete($userId);
|
||||
public function create(array $UserDetails, array $role);
|
||||
public function update($userId, array $newDetails);
|
||||
}
|
35
Modules/User/app/Repositories/UserRepository.php
Normal file
35
Modules/User/app/Repositories/UserRepository.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Repositories;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class UserRepository implements UserInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return User::get();
|
||||
}
|
||||
|
||||
public function getUserById($userId)
|
||||
{
|
||||
return User::findOrFail($userId);
|
||||
}
|
||||
|
||||
public function delete($userId)
|
||||
{
|
||||
User::destroy($userId);
|
||||
}
|
||||
|
||||
public function create(array $userDetails, array $role)
|
||||
{
|
||||
$user = User::create($userDetails);
|
||||
return $user->roles()->attach($role);
|
||||
}
|
||||
|
||||
public function update($userId, array $newDetails)
|
||||
{
|
||||
return User::whereId($userId)->update($newDetails);
|
||||
}
|
||||
|
||||
}
|
30
Modules/User/composer.json
Normal file
30
Modules/User/composer.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "nwidart/user",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\User\\": "app/",
|
||||
"Modules\\User\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\User\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\User\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/User/config/.gitkeep
Normal file
0
Modules/User/config/.gitkeep
Normal file
5
Modules/User/config/config.php
Normal file
5
Modules/User/config/config.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'User',
|
||||
];
|
0
Modules/User/database/factories/.gitkeep
Normal file
0
Modules/User/database/factories/.gitkeep
Normal file
0
Modules/User/database/migrations/.gitkeep
Normal file
0
Modules/User/database/migrations/.gitkeep
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->unsignedInteger('employee_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
|
||||
});
|
||||
}
|
||||
};
|
0
Modules/User/database/seeders/.gitkeep
Normal file
0
Modules/User/database/seeders/.gitkeep
Normal file
16
Modules/User/database/seeders/UserDatabaseSeeder.php
Normal file
16
Modules/User/database/seeders/UserDatabaseSeeder.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\database\seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// $this->call([]);
|
||||
}
|
||||
}
|
11
Modules/User/module.json
Normal file
11
Modules/User/module.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "User",
|
||||
"alias": "user",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\User\\Providers\\UserServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
15
Modules/User/package.json
Normal file
15
Modules/User/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^1.1.2",
|
||||
"laravel-vite-plugin": "^0.7.5",
|
||||
"sass": "^1.69.5",
|
||||
"postcss": "^8.3.7",
|
||||
"vite": "^4.0.0"
|
||||
}
|
||||
}
|
0
Modules/User/resources/assets/.gitkeep
Normal file
0
Modules/User/resources/assets/.gitkeep
Normal file
0
Modules/User/resources/assets/js/app.js
Normal file
0
Modules/User/resources/assets/js/app.js
Normal file
0
Modules/User/resources/assets/sass/app.scss
Normal file
0
Modules/User/resources/assets/sass/app.scss
Normal file
0
Modules/User/resources/views/.gitkeep
Normal file
0
Modules/User/resources/views/.gitkeep
Normal file
43
Modules/User/resources/views/create.blade.php
Normal file
43
Modules/User/resources/views/create.blade.php
Normal file
@ -0,0 +1,43 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
|
||||
<h4 class="mb-sm-0">{{ $title }}</h4>
|
||||
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
|
||||
<li class="breadcrumb-item active">{{ $title }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('user.store') }}" class="needs-validation" novalidate method="post">
|
||||
@csrf
|
||||
@include('user::partials.action', ['btnType' => 'Save'])
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--end row-->
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
44
Modules/User/resources/views/edit.blade.php
Normal file
44
Modules/User/resources/views/edit.blade.php
Normal file
@ -0,0 +1,44 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
|
||||
<h4 class="mb-sm-0">{{ $title }}</h4>
|
||||
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
|
||||
<li class="breadcrumb-item active">{{ $title }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('user.store') }}" class="needs-validation" novalidate method="post">
|
||||
@csrf
|
||||
@include('user::partials.action', ['btnType' => 'Save'])
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--end row-->
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
|
||||
@endpush
|
63
Modules/User/resources/views/index.blade.php
Normal file
63
Modules/User/resources/views/index.blade.php
Normal file
@ -0,0 +1,63 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-users-center">
|
||||
<h5 class="card-title flex-grow-1 mb-0">User Lists</h5>
|
||||
<a href="{{ route('user.create') }}" class="btn btn-info btn-sm"><span>Add New</span></a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="buttons-datatables" class="display table-sm table-bordered table" style="width:100%">
|
||||
<thead class="">
|
||||
<tr>
|
||||
<th class="tb-col"><span class="overline-title">S.N</span></th>
|
||||
<th class="tb-col"><span class="overline-title">Name</span></th>
|
||||
<th class="tb-col"><span class="overline-title">Email</span></th>
|
||||
<th class="tb-col"><span class="overline-title">Employee</span></th>
|
||||
<th class="tb-col"><span class="overline-title">Role</span></th>
|
||||
{{-- <th class="tb-col"><span class="overline-title">Branch</span></th> --}}
|
||||
<th class="tb-col" data-sortable="false"><span class="overline-title">Action</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($data as $index => $user)
|
||||
<tr data-id="{{ $user->id }}" data-display_order="{{ $user->display_order }}"
|
||||
class="draggable-row">
|
||||
<td class="tb-col">{{ $index + 1 }}</td>
|
||||
<td class="tb-col">{{ $user->name }}</td>
|
||||
<td class="tb-col">{{ $user->email }}</td>
|
||||
<td class="tb-col">{{ optional($user->employee)->employee_id }}</td>
|
||||
<td class="tb-col">{{ $user->roles->first()->id }}</td>
|
||||
<td class="tb-col">
|
||||
<div class="hstack flex-wrap gap-3">
|
||||
<a href="javascript:void(0);" class="link-info fs-15 view-user-btn" data-bs-toggle="modal"
|
||||
data-bs-target="#viewModal">
|
||||
<i class="ri-eye-line"></i>
|
||||
</a>
|
||||
<a href="{{ route('user.edit', $user->id) }}" class="link-success fs-15 edit-user-btn"><i
|
||||
class="ri-edit-2-line"></i></a>
|
||||
|
||||
<a href="javascript:void(0);" data-link="{{ route('user.destroy', $user->id) }}"
|
||||
data-id="{{ $user->id }}" class="link-danger fs-15 remove-user-btn"><i
|
||||
class="ri-delete-bin-line"></i></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@include('user::partials.view')
|
||||
@endsection
|
29
Modules/User/resources/views/layouts/master.blade.php
Normal file
29
Modules/User/resources/views/layouts/master.blade.php
Normal file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
<title>User Module - {{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<meta name="description" content="{{ $description ?? '' }}">
|
||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
||||
<meta name="author" content="{{ $author ?? '' }}">
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
||||
|
||||
{{-- Vite CSS --}}
|
||||
{{-- {{ module_vite('build-user', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-user', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
33
Modules/User/resources/views/partials/action.blade.php
Normal file
33
Modules/User/resources/views/partials/action.blade.php
Normal file
@ -0,0 +1,33 @@
|
||||
<div class="row gy-4">
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('For Employee')->class('form-label') }}
|
||||
{{ html()->select('employee_id', ['1', '2'])->class('form-select')->placeholder('Select Employee')->required() }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Role')->class('form-label') }}
|
||||
{{ html()->select('role_id', ['1', '2'])->class('form-select')->placeholder('Select Role')->required() }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Username')->class('form-label') }}
|
||||
{{ html()->text('name')->class('form-control')->placeholder('Enter Username')->required() }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Email')->class('form-label') }}
|
||||
{{ html()->email('email')->class('form-control')->placeholder('Enter Email')->required() }}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ html()->label('Password')->class('form-label') }}
|
||||
{{ html()->password('password')->class('form-control')->placeholder('Enter Password')->required() }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="text-end">
|
||||
<button type="submit" class="btn btn-primary">{{ $btnType }}</button>
|
||||
</div>
|
16
Modules/User/resources/views/partials/view.blade.php
Normal file
16
Modules/User/resources/views/partials/view.blade.php
Normal file
@ -0,0 +1,16 @@
|
||||
<div class="modal fade" id="viewModal" tabindex="-1" aria-labelledby="viewModalLabel" aria-modal="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalgridLabel">View User</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="{{ route('user.store') }}" class="needs-validation" novalidate method="post">
|
||||
@csrf
|
||||
@include('user::partials.action', ['btnType' => 'View'])
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
0
Modules/User/routes/.gitkeep
Normal file
0
Modules/User/routes/.gitkeep
Normal file
19
Modules/User/routes/api.php
Normal file
19
Modules/User/routes/api.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\User\Http\Controllers\UserController;
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------------------
|
||||
* API Routes
|
||||
*--------------------------------------------------------------------------
|
||||
*
|
||||
* Here is where you can register API routes for your application. These
|
||||
* routes are loaded by the RouteServiceProvider within a group which
|
||||
* is assigned the "api" middleware group. Enjoy building your API!
|
||||
*
|
||||
*/
|
||||
|
||||
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
|
||||
Route::apiResource('user', UserController::class)->names('user');
|
||||
});
|
19
Modules/User/routes/web.php
Normal file
19
Modules/User/routes/web.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\User\Http\Controllers\UserController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group([], function () {
|
||||
Route::resource('user', UserController::class)->names('user');
|
||||
});
|
26
Modules/User/vite.config.js
Normal file
26
Modules/User/vite.config.js
Normal file
@ -0,0 +1,26 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: '../../public/build-user',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-user',
|
||||
input: [
|
||||
__dirname + '/resources/assets/sass/app.scss',
|
||||
__dirname + '/resources/assets/js/app.js'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
//export const paths = [
|
||||
// 'Modules/User/resources/assets/sass/app.scss',
|
||||
// 'Modules/User/resources/assets/js/app.js',
|
||||
//];
|
@ -51,7 +51,7 @@ class OMIS
|
||||
<?php echo $text; ?>
|
||||
</span></a>
|
||||
</li>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function getSiteVars()
|
||||
|
218
app/Http/Controllers/BranchesController.php
Normal file
218
app/Http/Controllers/BranchesController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Branches;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class BranchesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Branches $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'index', ' Branches index');
|
||||
$data = Branches::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.branches.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'create', ' Branches create');
|
||||
$TableData = Branches::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.branches.create",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'store', ' Branches store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$request->request->add(['alias' => slugify($request->title)]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_branches')]);
|
||||
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
|
||||
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$operationNumber = getOperationNumber();
|
||||
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(BranchesController::class, 'store', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Branches Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('branches.index')->with('success','The Branches created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Branches::find($id);
|
||||
$companyArticle->display_order = $index + 1;
|
||||
$companyArticle->save();
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200);
|
||||
}
|
||||
public function updatealias(Request $request)
|
||||
{
|
||||
|
||||
$articleId = $request->input('articleId');
|
||||
$newAlias = $request->input('newAlias');
|
||||
$companyArticle = Branches::find($articleId);
|
||||
if (!$companyArticle) {
|
||||
return response()->json(['status' => false, 'content' => 'Company article not found.'], 404);
|
||||
}
|
||||
$companyArticle->alias = $newAlias;
|
||||
$companyArticle->save();
|
||||
return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'show', ' Branches show');
|
||||
$data = Branches::findOrFail($id);
|
||||
|
||||
return view("crud.generated.branches.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'edit', ' Branches edit');
|
||||
$TableData = Branches::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Branches::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.branches.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'update', ' Branches update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('branch_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(BranchesController::class, 'update', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Branches updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('branches.index')->with('success','The Branches updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Branches updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'destroy', ' Branches destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(BranchesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Branches Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'destroy', ' Branches destroy');
|
||||
$data = Branches::findOrFail($id);
|
||||
$requestData=['status'=>($data->status==1)?0:1];
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(BranchesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Branches Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(BranchesController::class, 'clone', ' Branches clone');
|
||||
$data = Branches::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(BranchesController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Branches Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/CastesController.php
Normal file
218
app/Http/Controllers/CastesController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Castes;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class CastesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Castes $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(CastesController::class, 'index', ' Castes index');
|
||||
$data = Castes::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.castes.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(CastesController::class, 'create', ' Castes create');
|
||||
$TableData = Castes::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.castes.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(CastesController::class, 'store', ' Castes 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_castes')]);
|
||||
$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(CastesController::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 Castes Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('castes.index')->with('success','The Castes created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Castes::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 = Castes::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(CastesController::class, 'show', ' Castes show');
|
||||
$data = Castes::findOrFail($id);
|
||||
|
||||
return view("crud.generated.castes.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(CastesController::class, 'edit', ' Castes edit');
|
||||
$TableData = Castes::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Castes::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.castes.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(CastesController::class, 'update', ' Castes 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('caste_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CastesController::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 Castes updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('castes.index')->with('success','The Castes updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Castes updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CastesController::class, 'destroy', ' Castes destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CastesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Castes Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CastesController::class, 'destroy', ' Castes destroy');
|
||||
$data = Castes::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(CastesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Castes Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CastesController::class, 'clone', ' Castes clone');
|
||||
$data = Castes::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CastesController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Castes Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/CitiesController.php
Normal file
218
app/Http/Controllers/CitiesController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?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();
|
||||
$editable=false;
|
||||
return view("crud.generated.cities.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
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);
|
||||
$editable=true;
|
||||
return view("crud.generated.cities.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CitiesController::class, 'clone', ' Cities clone');
|
||||
$data = Cities::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CitiesController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Cities Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/CompaniesController.php
Normal file
218
app/Http/Controllers/CompaniesController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Companies;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class CompaniesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Companies $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(CompaniesController::class, 'index', ' Companies index');
|
||||
$data = Companies::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.companies.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(CompaniesController::class, 'create', ' Companies create');
|
||||
$TableData = Companies::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.companies.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(CompaniesController::class, 'store', ' Companies 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_companies')]);
|
||||
$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(CompaniesController::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 Companies Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('companies.index')->with('success','The Companies created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Companies::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 = Companies::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(CompaniesController::class, 'show', ' Companies show');
|
||||
$data = Companies::findOrFail($id);
|
||||
|
||||
return view("crud.generated.companies.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(CompaniesController::class, 'edit', ' Companies edit');
|
||||
$TableData = Companies::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Companies::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.companies.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(CompaniesController::class, 'update', ' Companies 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('company_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CompaniesController::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 Companies updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('companies.index')->with('success','The Companies updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Companies updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CompaniesController::class, 'destroy', ' Companies destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CompaniesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Companies Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CompaniesController::class, 'destroy', ' Companies destroy');
|
||||
$data = Companies::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(CompaniesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Companies Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CompaniesController::class, 'clone', ' Companies clone');
|
||||
$data = Companies::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CompaniesController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Companies Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/CompanytypesController.php
Normal file
218
app/Http/Controllers/CompanytypesController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Companytypes;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class CompanytypesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Companytypes $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(CompanytypesController::class, 'index', ' Companytypes index');
|
||||
$data = Companytypes::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.companytypes.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(CompanytypesController::class, 'create', ' Companytypes create');
|
||||
$TableData = Companytypes::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.companytypes.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(CompanytypesController::class, 'store', ' Companytypes 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_companytypes')]);
|
||||
$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(CompanytypesController::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 Companytypes Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('companytypes.index')->with('success','The Companytypes created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Companytypes::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 = Companytypes::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(CompanytypesController::class, 'show', ' Companytypes show');
|
||||
$data = Companytypes::findOrFail($id);
|
||||
|
||||
return view("crud.generated.companytypes.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(CompanytypesController::class, 'edit', ' Companytypes edit');
|
||||
$TableData = Companytypes::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Companytypes::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.companytypes.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(CompanytypesController::class, 'update', ' Companytypes 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('companytype_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CompanytypesController::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 Companytypes updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('companytypes.index')->with('success','The Companytypes updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Companytypes updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CompanytypesController::class, 'destroy', ' Companytypes destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CompanytypesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Companytypes Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CompanytypesController::class, 'destroy', ' Companytypes destroy');
|
||||
$data = Companytypes::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(CompanytypesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Companytypes Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CompanytypesController::class, 'clone', ' Companytypes clone');
|
||||
$data = Companytypes::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CompanytypesController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Companytypes Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
211
app/Http/Controllers/CountriesController.php
Normal file
211
app/Http/Controllers/CountriesController.php
Normal file
@ -0,0 +1,211 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Country;
|
||||
use App\Service\CommonModelService;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Log;
|
||||
|
||||
class CountriesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Country $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
// createActivityLog(CountriesController::class, 'index', ' Country index');
|
||||
$data = Country::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.countries.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
// createActivityLog(CountriesController::class, 'create', ' Country create');
|
||||
$TableData = Country::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$editable = false;
|
||||
return view("crud.generated.countries.edit", compact('TableData', 'editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
// createActivityLog(CountriesController::class, 'store', ' Country 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 Country Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('countries.index')->with('success', 'The Country created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Country::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 = Country::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', ' Country show');
|
||||
$data = Country::findOrFail($id);
|
||||
|
||||
return view("crud.generated.countries.show", compact('data'));
|
||||
}
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
// createActivityLog(CountriesController::class, 'edit', ' Country edit');
|
||||
$TableData = Country::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Country::findOrFail($id);
|
||||
$editable = true;
|
||||
return view("crud.generated.countries.edit", compact('data', 'TableData', 'editable'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// createActivityLog(CountriesController::class, 'update', ' Country 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 Country updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('countries.index')->with('success','The Country updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Country updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
// createActivityLog(CountriesController::class, 'destroy', ' Country 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 Country Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
// createActivityLog(CountriesController::class, 'destroy', ' Country destroy');
|
||||
$data = Country::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 Country Deleted Successfully.'], 200);
|
||||
}
|
||||
public function clone (Request $request, $id)
|
||||
{
|
||||
// createActivityLog(CountriesController::class, 'clone', ' Country clone');
|
||||
$data = Country::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData = $data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(CountriesController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Country Clonned Successfully.'], 200);
|
||||
}
|
||||
|
||||
}
|
218
app/Http/Controllers/DagsController.php
Normal file
218
app/Http/Controllers/DagsController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Dags;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class DagsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Dags $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'index', ' Dags index');
|
||||
$data = Dags::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.dags.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'create', ' Dags create');
|
||||
$TableData = Dags::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.dags.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'store', ' Dags store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$request->request->add(['alias' => slugify($request->title)]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_dags')]);
|
||||
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
|
||||
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$operationNumber = getOperationNumber();
|
||||
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DagsController::class, 'store', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Dags Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('dags.index')->with('success','The Dags created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Dags::find($id);
|
||||
$companyArticle->display_order = $index + 1;
|
||||
$companyArticle->save();
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200);
|
||||
}
|
||||
public function updatealias(Request $request)
|
||||
{
|
||||
|
||||
$articleId = $request->input('articleId');
|
||||
$newAlias = $request->input('newAlias');
|
||||
$companyArticle = Dags::find($articleId);
|
||||
if (!$companyArticle) {
|
||||
return response()->json(['status' => false, 'content' => 'Company article not found.'], 404);
|
||||
}
|
||||
$companyArticle->alias = $newAlias;
|
||||
$companyArticle->save();
|
||||
return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'show', ' Dags show');
|
||||
$data = Dags::findOrFail($id);
|
||||
|
||||
return view("crud.generated.dags.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'edit', ' Dags edit');
|
||||
$TableData = Dags::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Dags::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.dags.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'update', ' Dags update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('dag_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DagsController::class, 'update', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Dags updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('dags.index')->with('success','The Dags updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Dags updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'destroy', ' Dags destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DagsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Dags Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'destroy', ' Dags destroy');
|
||||
$data = Dags::findOrFail($id);
|
||||
$requestData=['status'=>($data->status==1)?0:1];
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DagsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Dags Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DagsController::class, 'clone', ' Dags clone');
|
||||
$data = Dags::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DagsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Dags Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/DepartmentsController.php
Normal file
218
app/Http/Controllers/DepartmentsController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Departments;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class DepartmentsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Departments $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(DepartmentsController::class, 'index', ' Departments index');
|
||||
$data = Departments::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.departments.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(DepartmentsController::class, 'create', ' Departments create');
|
||||
$TableData = Departments::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.departments.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(DepartmentsController::class, 'store', ' Departments 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_departments')]);
|
||||
$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(DepartmentsController::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 Departments Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('departments.index')->with('success','The Departments created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Departments::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 = Departments::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(DepartmentsController::class, 'show', ' Departments show');
|
||||
$data = Departments::findOrFail($id);
|
||||
|
||||
return view("crud.generated.departments.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(DepartmentsController::class, 'edit', ' Departments edit');
|
||||
$TableData = Departments::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Departments::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.departments.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(DepartmentsController::class, 'update', ' Departments 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('department_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DepartmentsController::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 Departments updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('departments.index')->with('success','The Departments updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Departments updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DepartmentsController::class, 'destroy', ' Departments destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DepartmentsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Departments Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DepartmentsController::class, 'destroy', ' Departments destroy');
|
||||
$data = Departments::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(DepartmentsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Departments Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DepartmentsController::class, 'clone', ' Departments clone');
|
||||
$data = Departments::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DepartmentsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Departments Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/DesignationsController.php
Normal file
218
app/Http/Controllers/DesignationsController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Designations;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class DesignationsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Designations $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(DesignationsController::class, 'index', ' Designations index');
|
||||
$data = Designations::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.designations.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(DesignationsController::class, 'create', ' Designations create');
|
||||
$TableData = Designations::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.designations.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(DesignationsController::class, 'store', ' Designations 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_designations')]);
|
||||
$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(DesignationsController::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 Designations Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('designations.index')->with('success','The Designations created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Designations::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 = Designations::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(DesignationsController::class, 'show', ' Designations show');
|
||||
$data = Designations::findOrFail($id);
|
||||
|
||||
return view("crud.generated.designations.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(DesignationsController::class, 'edit', ' Designations edit');
|
||||
$TableData = Designations::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Designations::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.designations.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(DesignationsController::class, 'update', ' Designations 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('designation_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DesignationsController::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 Designations updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('designations.index')->with('success','The Designations updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Designations updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DesignationsController::class, 'destroy', ' Designations destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DesignationsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Designations Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DesignationsController::class, 'destroy', ' Designations destroy');
|
||||
$data = Designations::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(DesignationsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Designations Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DesignationsController::class, 'clone', ' Designations clone');
|
||||
$data = Designations::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DesignationsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Designations Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/DistrictsController.php
Normal file
218
app/Http/Controllers/DistrictsController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?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();
|
||||
$editable=false;
|
||||
return view("crud.generated.districts.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
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);
|
||||
$editable=true;
|
||||
return view("crud.generated.districts.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(DistrictsController::class, 'clone', ' Districts clone');
|
||||
$data = Districts::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(DistrictsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Districts Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/EthnicitiesController.php
Normal file
218
app/Http/Controllers/EthnicitiesController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Ethnicities;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class EthnicitiesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Ethnicities $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(EthnicitiesController::class, 'index', ' Ethnicities index');
|
||||
$data = Ethnicities::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.ethnicities.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(EthnicitiesController::class, 'create', ' Ethnicities create');
|
||||
$TableData = Ethnicities::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.ethnicities.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(EthnicitiesController::class, 'store', ' Ethnicities 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_ethnicities')]);
|
||||
$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(EthnicitiesController::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 Ethnicities Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('ethnicities.index')->with('success','The Ethnicities created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Ethnicities::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 = Ethnicities::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(EthnicitiesController::class, 'show', ' Ethnicities show');
|
||||
$data = Ethnicities::findOrFail($id);
|
||||
|
||||
return view("crud.generated.ethnicities.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(EthnicitiesController::class, 'edit', ' Ethnicities edit');
|
||||
$TableData = Ethnicities::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Ethnicities::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.ethnicities.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(EthnicitiesController::class, 'update', ' Ethnicities 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('ethnicity_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(EthnicitiesController::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 Ethnicities updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('ethnicities.index')->with('success','The Ethnicities updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Ethnicities updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(EthnicitiesController::class, 'destroy', ' Ethnicities destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(EthnicitiesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Ethnicities Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(EthnicitiesController::class, 'destroy', ' Ethnicities destroy');
|
||||
$data = Ethnicities::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(EthnicitiesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Ethnicities Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(EthnicitiesController::class, 'clone', ' Ethnicities clone');
|
||||
$data = Ethnicities::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(EthnicitiesController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Ethnicities Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/GendersController.php
Normal file
218
app/Http/Controllers/GendersController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Genders;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class GendersController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Genders $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(GendersController::class, 'index', ' Genders index');
|
||||
$data = Genders::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.genders.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(GendersController::class, 'create', ' Genders create');
|
||||
$TableData = Genders::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.genders.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(GendersController::class, 'store', ' Genders 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_genders')]);
|
||||
$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(GendersController::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 Genders Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('genders.index')->with('success','The Genders created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Genders::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 = Genders::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(GendersController::class, 'show', ' Genders show');
|
||||
$data = Genders::findOrFail($id);
|
||||
|
||||
return view("crud.generated.genders.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(GendersController::class, 'edit', ' Genders edit');
|
||||
$TableData = Genders::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Genders::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.genders.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(GendersController::class, 'update', ' Genders 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('gender_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(GendersController::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 Genders updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('genders.index')->with('success','The Genders updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Genders updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(GendersController::class, 'destroy', ' Genders destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(GendersController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Genders Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(GendersController::class, 'destroy', ' Genders destroy');
|
||||
$data = Genders::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(GendersController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Genders Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(GendersController::class, 'clone', ' Genders clone');
|
||||
$data = Genders::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(GendersController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Genders Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/NationalitiesController.php
Normal file
218
app/Http/Controllers/NationalitiesController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Nationalities;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class NationalitiesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Nationalities $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(NationalitiesController::class, 'index', ' Nationalities index');
|
||||
$data = Nationalities::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.nationalities.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(NationalitiesController::class, 'create', ' Nationalities create');
|
||||
$TableData = Nationalities::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.nationalities.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(NationalitiesController::class, 'store', ' Nationalities 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_nationalities')]);
|
||||
$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(NationalitiesController::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 Nationalities Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('nationalities.index')->with('success','The Nationalities created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Nationalities::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 = Nationalities::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(NationalitiesController::class, 'show', ' Nationalities show');
|
||||
$data = Nationalities::findOrFail($id);
|
||||
|
||||
return view("crud.generated.nationalities.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(NationalitiesController::class, 'edit', ' Nationalities edit');
|
||||
$TableData = Nationalities::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Nationalities::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.nationalities.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(NationalitiesController::class, 'update', ' Nationalities 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('nationality_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(NationalitiesController::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 Nationalities updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('nationalities.index')->with('success','The Nationalities updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Nationalities updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(NationalitiesController::class, 'destroy', ' Nationalities destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(NationalitiesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Nationalities Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(NationalitiesController::class, 'destroy', ' Nationalities destroy');
|
||||
$data = Nationalities::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(NationalitiesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Nationalities Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(NationalitiesController::class, 'clone', ' Nationalities clone');
|
||||
$data = Nationalities::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(NationalitiesController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Nationalities Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/OnboardingsController.php
Normal file
218
app/Http/Controllers/OnboardingsController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Onboardings;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class OnboardingsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Onboardings $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'index', ' Onboardings index');
|
||||
$data = Onboardings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.onboardings.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'create', ' Onboardings create');
|
||||
$TableData = Onboardings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.onboardings.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'store', ' Onboardings store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$request->request->add(['alias' => slugify($request->title)]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_onboardings')]);
|
||||
$request->request->add(['created_at' => date("Y-m-d h:i:s")]);
|
||||
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$operationNumber = getOperationNumber();
|
||||
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(OnboardingsController::class, 'store', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Onboardings Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('onboardings.index')->with('success','The Onboardings created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Onboardings::find($id);
|
||||
$companyArticle->display_order = $index + 1;
|
||||
$companyArticle->save();
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200);
|
||||
}
|
||||
public function updatealias(Request $request)
|
||||
{
|
||||
|
||||
$articleId = $request->input('articleId');
|
||||
$newAlias = $request->input('newAlias');
|
||||
$companyArticle = Onboardings::find($articleId);
|
||||
if (!$companyArticle) {
|
||||
return response()->json(['status' => false, 'content' => 'Company article not found.'], 404);
|
||||
}
|
||||
$companyArticle->alias = $newAlias;
|
||||
$companyArticle->save();
|
||||
return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'show', ' Onboardings show');
|
||||
$data = Onboardings::findOrFail($id);
|
||||
|
||||
return view("crud.generated.onboardings.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'edit', ' Onboardings edit');
|
||||
$TableData = Onboardings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Onboardings::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.onboardings.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'update', ' Onboardings update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('onboarding_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(OnboardingsController::class, 'update', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Onboardings updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('onboardings.index')->with('success','The Onboardings updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Onboardings updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'destroy', ' Onboardings destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(OnboardingsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Onboardings Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'destroy', ' Onboardings destroy');
|
||||
$data = Onboardings::findOrFail($id);
|
||||
$requestData=['status'=>($data->status==1)?0:1];
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(OnboardingsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Onboardings Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(OnboardingsController::class, 'clone', ' Onboardings clone');
|
||||
$data = Onboardings::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(OnboardingsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Onboardings Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/PermissionsController.php.bak
Normal file
218
app/Http/Controllers/PermissionsController.php.bak
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Permissions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class PermissionsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Permissions $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(PermissionsController::class, 'index', ' Permissions index');
|
||||
$data = Permissions::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.permissions.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(PermissionsController::class, 'create', ' Permissions create');
|
||||
$TableData = Permissions::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.permissions.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(PermissionsController::class, 'store', ' Permissions 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_permissions')]);
|
||||
$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(PermissionsController::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 Permissions Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('permissions.index')->with('success','The Permissions created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Permissions::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 = Permissions::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(PermissionsController::class, 'show', ' Permissions show');
|
||||
$data = Permissions::findOrFail($id);
|
||||
|
||||
return view("crud.generated.permissions.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(PermissionsController::class, 'edit', ' Permissions edit');
|
||||
$TableData = Permissions::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Permissions::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.permissions.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(PermissionsController::class, 'update', ' Permissions 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('permission_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(PermissionsController::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 Permissions updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('permissions.index')->with('success','The Permissions updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Permissions updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(PermissionsController::class, 'destroy', ' Permissions destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(PermissionsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Permissions Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(PermissionsController::class, 'destroy', ' Permissions destroy');
|
||||
$data = Permissions::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(PermissionsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Permissions Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(PermissionsController::class, 'clone', ' Permissions clone');
|
||||
$data = Permissions::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(PermissionsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Permissions Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
217
app/Http/Controllers/ProvinceController.php
Normal file
217
app/Http/Controllers/ProvinceController.php
Normal file
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Province;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class ProvinceController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Province $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(ProvinceController::class, 'index', ' Province index');
|
||||
$data = Province::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.province.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(ProvinceController::class, 'create', ' Province create');
|
||||
$TableData = Province::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.province.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(ProvinceController::class, 'store', ' Province 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_province')]);
|
||||
$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(ProvinceController::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 Province Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('province.index')->with('success','The Province created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Province::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 = Province::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(ProvinceController::class, 'show', ' Province show');
|
||||
$data = Province::findOrFail($id);
|
||||
|
||||
return view("crud.generated.province.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ProvinceController::class, 'edit', ' Province edit');
|
||||
$TableData = Province::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Province::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.province.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ProvinceController::class, 'update', ' Province 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('provience_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(ProvinceController::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 Province updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('province.index')->with('success','The Province updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Province updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(ProvinceController::class, 'destroy', ' Province destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(ProvinceController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Province Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(ProvinceController::class, 'destroy', ' Province destroy');
|
||||
$data = Province::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(ProvinceController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Province Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(ProvinceController::class, 'clone', ' Province clone');
|
||||
$data = Province::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(ProvinceController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Province Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
530
app/Http/Controllers/RegistrationsController.php
Normal file
530
app/Http/Controllers/RegistrationsController.php
Normal file
@ -0,0 +1,530 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\CustomMailer;
|
||||
use App\Models\Agents;
|
||||
use App\Models\Branches;
|
||||
use App\Models\Campaigns;
|
||||
use App\Models\Countries;
|
||||
use App\Models\Leadcategories;
|
||||
use App\Models\Qrscans;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Registrations;
|
||||
use App\Models\Sources;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
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 bybranch(Request $request, $BranchAlias)
|
||||
{
|
||||
$Branch = Branches::where("alias", $BranchAlias)->first();
|
||||
$title = "Registrations By Branch : " . $Branch->title;
|
||||
$data = $this->filterRegistrations($request, null,null,null,null,null, $Branch);
|
||||
$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, $Branch=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 (isset($requestData['branch_id']) && $requestData['branch_id']) {
|
||||
$data = $data->where("branches_id", "=", $requestData['branch_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);
|
||||
}
|
||||
if ($Branch !== null) {
|
||||
$data = $data->where("branches_id", $Branch->branch_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
|
||||
'mobile' => 'required|numeric: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) {
|
||||
//$qr_code = LMS::getLeadQR($existingRegistration->registration_id);
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Mobile number already exists. Returning existing data.',
|
||||
// 'qr_code' => site_url(str_replace(public_path(), '', $qr_code)),
|
||||
'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(['created_at' => date("Y-m-d h:i:s")]);
|
||||
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
|
||||
$request->request->add(['highest_qualification' => $request->qualification]);
|
||||
$request->request->add(['highest_year' => ($request->highest_year) ? $request->highest_year : 0]);
|
||||
$request->request->add(['highest_college' => $request->board]);
|
||||
$request->request->add(['intrested_for_country' => ($request->preferred_destination) ? $request->preferred_destination : SITEVARS->Countries[0]->country_id]);
|
||||
$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' => SITEVARS->Countries[0]->country_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);
|
||||
} catch (\Exception $e) {
|
||||
dd($e->getMessage());
|
||||
DB::rollBack();
|
||||
}
|
||||
DB::commit();
|
||||
$mailer = new CustomMailer($requestData);
|
||||
if (env('SEND_EMAIL') == true) {
|
||||
// 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->registration_completed());
|
||||
}
|
||||
$msg = $Campaign->sms_message;
|
||||
$success_messsage = $Campaign->success_messsage;
|
||||
$success_messsage = str_replace('%name%', $request['name'], $success_messsage);
|
||||
// dd($Campaign);
|
||||
if (env('SEND_SMS') == true) {
|
||||
|
||||
$msg = str_replace('%name%', $request['name'], $msg);
|
||||
LMS::sendSMSWithCurl($requestData['mobile'], $msg);
|
||||
}
|
||||
LMS::SaveInGoogleSheet($requestData);
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'qr_code' => false,
|
||||
'message' => ($success_messsage) ? $success_messsage : 'The Registration Created Successfully.',
|
||||
'registration_id' => $registration->registration_id,
|
||||
], 200);
|
||||
}
|
||||
public function saveform(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' => false,
|
||||
'message' => 'Mobile number already exists',
|
||||
'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(['created_at' => date("Y-m-d h:i:s")]);
|
||||
$request->request->add(['updated_at' => date("Y-m-d h:i:s")]);
|
||||
$request->request->add(['highest_qualification' => $request->qualification]);
|
||||
$request->request->add(['highest_year' => ($request->highest_year) ? $request->highest_year : 0]);
|
||||
$request->request->add(['highest_college' => $request->board]);
|
||||
$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' => SITEVARS->Countries[0]->country_id]);
|
||||
$request->request->add(['remarks' => $request->message]);
|
||||
$requestData = $request->all();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$operationNumber = getOperationNumber();
|
||||
$registration = $this->modelService->create($operationNumber, $operationNumber, null, $requestData);
|
||||
if (env('SEND_EMAIL') == true) {
|
||||
$notify_emails = (isset($Campaign->notify_emails) && ($Campaign->notify_emails != "")) ? explode(",", $Campaign->notify_emails) : "prajwalbro@hotmail.com";
|
||||
$mailer = new CustomMailer($requestData);
|
||||
Mail::to($request['email'])->send($mailer->build());
|
||||
Mail::cc($notify_emails)->send($mailer->build());
|
||||
Mail::bcc("prajwalbro@hotmail.com")->send($mailer->build());
|
||||
}
|
||||
$success_messsage = $Campaign->success_messsage;
|
||||
if (isset($Campaign->sms_message) && ($Campaign->sms_message != "")) {
|
||||
$msg = $Campaign->sms_message;
|
||||
$success_messsage = str_replace('%name%', $request['name'], $success_messsage);
|
||||
$msg = str_replace('%name%', $request['name'], $msg);
|
||||
if (env('SEND_SMS') == true) LMS::sendSMSWithCurl($requestData['mobile'], $msg);
|
||||
}
|
||||
} 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)
|
||||
{
|
||||
$alias = str_replace("_", "-", $campaign_alias);
|
||||
$Campaign = Campaigns::where("status", "1")->where("alias", $alias)->first();
|
||||
if ($Campaign) {
|
||||
$viewPath = env("CLIENT_PATH") . ".landing.$campaign_alias";
|
||||
// echo $viewPath;die;
|
||||
if (view()->exists($viewPath))
|
||||
return view($viewPath, compact("Campaign"));
|
||||
else
|
||||
return view(env("CLIENT_PATH") . '.home', compact("Campaign"));
|
||||
}
|
||||
switch ($campaign_alias) {
|
||||
case 'office': // Student/Visitor office visit gareko bela, MOBILE bata QR Scan garera fill garne
|
||||
return view("access.office-visits");
|
||||
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:
|
||||
$Campaign = LMS::getActiveCampaign();
|
||||
if ($Campaign) {
|
||||
$viewPath = env("CLIENT_PATH") . ".landing.$Campaign->alias";
|
||||
// echo $viewPath;die;
|
||||
if (view()->exists($viewPath))
|
||||
return view($viewPath, compact("Campaign"));
|
||||
else
|
||||
return view(env("CLIENT_PATH") . '.home', compact("Campaign"));
|
||||
}
|
||||
|
||||
// $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 zapierrequest(Request $request)
|
||||
{
|
||||
//Office ko Reception Bata directly fill-in garne form
|
||||
//return view("backend.reception");
|
||||
$requiredFields = ['name', 'email', 'phone', 'qualification', 'passed', 'interest', 'source'];
|
||||
if ($this->checkFieldsPresence($request, $requiredFields)) {
|
||||
$campaign = Campaigns::orderBy("display_order", "ASC")->first();
|
||||
$source = Sources::orderBy("display_order", "ASC")->first();
|
||||
$data = [
|
||||
'name' => $request->query('name'),
|
||||
'email' => $request->query('email'),
|
||||
'phone' => $request->query('phone'),
|
||||
'mobile' => $request->query('phone'),
|
||||
'highest_qualification' => $request->query('qualification'),
|
||||
'highest_year' => $request->query('passed'),
|
||||
'intrested_course' => $request->query('interest'),
|
||||
// 'intrested_country' => $request->query('interest'),
|
||||
'leadcategories_id' => 0,
|
||||
'campaigns_id' => $campaign ? $campaign->campaign_id : null,
|
||||
'sourcess_id' => $source ? $source->source_id : null,
|
||||
'remarks' => $request->query('source')
|
||||
];
|
||||
Registrations::create($data);
|
||||
return response()->json(['message' => 'Registration successful'], Response::HTTP_OK);
|
||||
} else {
|
||||
return response()->json(['message' => 'Registration Failed. Missing required fields.'], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
private function checkFieldsPresence(Request $request, array $fields)
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
if (!$request->query($field)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
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(Request $request, $id)
|
||||
{
|
||||
// $data = '';
|
||||
if (Auth::check()) {
|
||||
$data = Registrations::where(DB::raw('md5(registration_id)'), $id)->firstOrFail();
|
||||
if ($data) {
|
||||
$qrdata = [
|
||||
'registrations_id' => $data->registration_id,
|
||||
'qrscan_type' => ($request->qrscan_type) ? $request->qrscan_type : 'mannual scan',
|
||||
'qrscan_location' => ($request->qrscan_type) ? $request->qrscan_type : 'office visit',
|
||||
// Add other columns as needed
|
||||
];
|
||||
Qrscans::create($qrdata);
|
||||
return view("access.steps.scanqr", compact('data'));
|
||||
}
|
||||
return "Sorry!!! It seems QR is INVALID";
|
||||
} else {
|
||||
// Redirect the user to the login page or handle the case where the user is not logged in
|
||||
return redirect()->route('login'); // Adjust 'login' to the actual login route in your application
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
226
app/Http/Controllers/RolepermissionsController.php.bak
Normal file
226
app/Http/Controllers/RolepermissionsController.php.bak
Normal file
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Rolepermissions;
|
||||
use App\Models\Permissions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class RolepermissionsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Rolepermissions $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(RolepermissionsController::class, 'index', ' Rolepermissions index');
|
||||
$data = Rolepermissions::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$PermissionGroups = Permissions::select('modal')
|
||||
->where('status', '<>', -1)
|
||||
->groupBy('modal')
|
||||
->get();
|
||||
foreach ($PermissionGroups as $Group) {
|
||||
$Group->Commands = Permissions::where('status', '<>', -1)->where("modal", $Group->modal)->orderBy('command')->get();
|
||||
}
|
||||
// $Permissions = Permissions::where('status', '<>', -1)->orderBy('modal')->orderBy('command')->get();
|
||||
return view("crud.generated.rolepermissions.index", compact('data', 'PermissionGroups'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(RolepermissionsController::class, 'create', ' Rolepermissions create');
|
||||
$TableData = Rolepermissions::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$editable = false;
|
||||
return view("crud.generated.rolepermissions.edit", compact('TableData', 'editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(RolepermissionsController::class, 'store', ' Rolepermissions 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_rolepermissions')]);
|
||||
$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(RolepermissionsController::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 Rolepermissions Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('rolepermissions.index')->with('success', 'The Rolepermissions created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Rolepermissions::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 = Rolepermissions::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(RolepermissionsController::class, 'show', ' Rolepermissions show');
|
||||
$data = Rolepermissions::findOrFail($id);
|
||||
|
||||
return view("crud.generated.rolepermissions.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(RolepermissionsController::class, 'edit', ' Rolepermissions edit');
|
||||
$TableData = Rolepermissions::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Rolepermissions::findOrFail($id);
|
||||
$editable = true;
|
||||
return view("crud.generated.rolepermissions.edit", compact('data', 'TableData', 'editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(RolepermissionsController::class, 'update', ' Rolepermissions 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('rolepermission_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(RolepermissionsController::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 Rolepermissions updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('rolepermissions.index')->with('success','The Rolepermissions updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Rolepermissions updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(RolepermissionsController::class, 'destroy', ' Rolepermissions destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(RolepermissionsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Rolepermissions Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(RolepermissionsController::class, 'destroy', ' Rolepermissions destroy');
|
||||
$data = Rolepermissions::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(RolepermissionsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Rolepermissions Deleted Successfully.'], 200);
|
||||
}
|
||||
public function clone (Request $request, $id)
|
||||
{
|
||||
createActivityLog(RolepermissionsController::class, 'clone', ' Rolepermissions clone');
|
||||
$data = Rolepermissions::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData = $data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(RolepermissionsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Rolepermissions Clonned Successfully.'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
218
app/Http/Controllers/RolesController.php.bak
Normal file
218
app/Http/Controllers/RolesController.php.bak
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Roles;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class RolesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Roles $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(RolesController::class, 'index', ' Roles index');
|
||||
$data = Roles::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.roles.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(RolesController::class, 'create', ' Roles create');
|
||||
$TableData = Roles::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.roles.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(RolesController::class, 'store', ' Roles 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_roles')]);
|
||||
$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(RolesController::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 Roles Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('roles.index')->with('success','The Roles created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Roles::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 = Roles::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(RolesController::class, 'show', ' Roles show');
|
||||
$data = Roles::findOrFail($id);
|
||||
|
||||
return view("crud.generated.roles.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(RolesController::class, 'edit', ' Roles edit');
|
||||
$TableData = Roles::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Roles::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.roles.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(RolesController::class, 'update', ' Roles 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('role_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(RolesController::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 Roles updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('roles.index')->with('success','The Roles updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Roles updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(RolesController::class, 'destroy', ' Roles destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(RolesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Roles Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(RolesController::class, 'destroy', ' Roles destroy');
|
||||
$data = Roles::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(RolesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Roles Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(RolesController::class, 'clone', ' Roles clone');
|
||||
$data = Roles::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(RolesController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Roles Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
198
app/Http/Controllers/SettingsController.php
Normal file
198
app/Http/Controllers/SettingsController.php
Normal file
@ -0,0 +1,198 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Settings $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'index', ' Settings index');
|
||||
$data = Settings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.settings.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'create', ' Settings create');
|
||||
$TableData = Settings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.settings.create",compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'store', ' Settings store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$request->request->add(['alias' => slugify($request->title)]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_settings')]);
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$operationNumber = getOperationNumber();
|
||||
$this->modelService->create($operationNumber, $operationNumber, null, $requestData);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(SettingsController::class, 'store', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Settings Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('settings.index')->with('success','The Settings created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Settings::find($id);
|
||||
$companyArticle->display_order = $index + 1;
|
||||
$companyArticle->save();
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200);
|
||||
}
|
||||
public function updatealias(Request $request)
|
||||
{
|
||||
|
||||
$articleId = $request->input('articleId');
|
||||
$newAlias = $request->input('newAlias');
|
||||
$companyArticle = Settings::find($articleId);
|
||||
if (!$companyArticle) {
|
||||
return response()->json(['status' => false, 'content' => 'Company article not found.'], 404);
|
||||
}
|
||||
$companyArticle->alias = $newAlias;
|
||||
$companyArticle->save();
|
||||
return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'show', ' Settings show');
|
||||
$data = Settings::findOrFail($id);
|
||||
|
||||
return view("crud.generated.settings.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'edit', ' Settings edit');
|
||||
$TableData = Settings::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Settings::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.settings.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.settings.edit", compact('data','TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'update', ' Settings update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $request->input('setting_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(SettingsController::class, 'update', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Settings updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('settings.index')->with('success','The Settings updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Settings updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'destroy', ' Settings destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(SettingsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Settings Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(SettingsController::class, 'destroy', ' Settings destroy');
|
||||
$data = Settings::findOrFail($id);
|
||||
$requestData=['status'=>($data->status==1)?0:1];
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(SettingsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Settings Deleted Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
218
app/Http/Controllers/ShiftsController.php
Normal file
218
app/Http/Controllers/ShiftsController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Shifts;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class ShiftsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Shifts $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(ShiftsController::class, 'index', ' Shifts index');
|
||||
$data = Shifts::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.shifts.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(ShiftsController::class, 'create', ' Shifts create');
|
||||
$TableData = Shifts::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.shifts.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(ShiftsController::class, 'store', ' Shifts 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_shifts')]);
|
||||
$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(ShiftsController::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 Shifts Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('shifts.index')->with('success','The Shifts created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Shifts::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 = Shifts::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(ShiftsController::class, 'show', ' Shifts show');
|
||||
$data = Shifts::findOrFail($id);
|
||||
|
||||
return view("crud.generated.shifts.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ShiftsController::class, 'edit', ' Shifts edit');
|
||||
$TableData = Shifts::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Shifts::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.shifts.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ShiftsController::class, 'update', ' Shifts 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('shift_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(ShiftsController::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 Shifts updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('shifts.index')->with('success','The Shifts updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Shifts updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(ShiftsController::class, 'destroy', ' Shifts destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(ShiftsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Shifts Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(ShiftsController::class, 'destroy', ' Shifts destroy');
|
||||
$data = Shifts::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(ShiftsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Shifts Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(ShiftsController::class, 'clone', ' Shifts clone');
|
||||
$data = Shifts::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(ShiftsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Shifts Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\DataTables\UsersDataTable;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
$roles = Role::all();
|
||||
return view('users.create', compact('roles'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'name' => 'required|min:5',
|
||||
'email' => 'required',
|
||||
'password' => 'required',
|
||||
'role' => 'required',
|
||||
]);
|
||||
$user = User::create($validatedData);
|
||||
$user->roles()->attach($request->role);
|
||||
toastr()->success('User has been created!');
|
||||
return redirect()->route('users.index');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$users = User::latest()->get();
|
||||
return view('users.index', compact('users'));
|
||||
}
|
||||
|
||||
public function destroy(string $id)
|
||||
{
|
||||
$user = User::findOrFail($id);
|
||||
$user->delete();
|
||||
toastr()->success('Data has been deleted successfully!');
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
218
app/Http/Controllers/VendorsController.php
Normal file
218
app/Http/Controllers/VendorsController.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Vendors;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class VendorsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Vendors $model)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(VendorsController::class, 'index', ' Vendors index');
|
||||
$data = Vendors::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.vendors.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(VendorsController::class, 'create', ' Vendors create');
|
||||
$TableData = Vendors::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$editable=false;
|
||||
return view("crud.generated.vendors.edit",compact('TableData','editable'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(VendorsController::class, 'store', ' Vendors 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_vendors')]);
|
||||
$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(VendorsController::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 Vendors Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('vendors.index')->with('success','The Vendors created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Vendors::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 = Vendors::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(VendorsController::class, 'show', ' Vendors show');
|
||||
$data = Vendors::findOrFail($id);
|
||||
|
||||
return view("crud.generated.vendors.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(VendorsController::class, 'edit', ' Vendors edit');
|
||||
$TableData = Vendors::where('status','<>',-1)->orderBy('display_order')->get();
|
||||
$data = Vendors::findOrFail($id);
|
||||
$editable=true;
|
||||
return view("crud.generated.vendors.edit", compact('data','TableData','editable'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(VendorsController::class, 'update', ' Vendors 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('vendor_id'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(VendorsController::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 Vendors updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('vendors.index')->with('success','The Vendors updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Vendors updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
createActivityLog(VendorsController::class, 'destroy', ' Vendors destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(VendorsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Vendors Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(VendorsController::class, 'destroy', ' Vendors destroy');
|
||||
$data = Vendors::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(VendorsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Vendors Deleted Successfully.'],200);
|
||||
}
|
||||
public function clone(Request $request,$id)
|
||||
{
|
||||
createActivityLog(VendorsController::class, 'clone', ' Vendors clone');
|
||||
$data = Vendors::findOrFail($id);
|
||||
unset($data['updatedby']);
|
||||
unset($data['createdby']);
|
||||
$requestData=$data->toArray();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->create($OperationNumber, $OperationNumber, null, $requestData);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(VendorsController::class, 'clone', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Vendors Clonned Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user