Compare commits
10 Commits
8253440371
...
tancho_bra
Author | SHA1 | Date | |
---|---|---|---|
|
f85671cd4c | ||
|
25760ad989 | ||
|
5b3c44aa33 | ||
|
adfc826e9c | ||
|
5554837c97 | ||
|
9bb573169d | ||
|
50b8768a34 | ||
|
613dfd1834 | ||
|
fcbaa0f679 | ||
|
cb99bedac6 |
34
app/Console/Commands/GeneratePermissions.php
Normal file
34
app/Console/Commands/GeneratePermissions.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Repositories\PermissionRepository;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class GeneratePermissions extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'permissions:generate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate Permissions From Named Route';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info('Generating Permissions');
|
||||
PermissionRepository::generatePermissionFromRoutes();
|
||||
$this->info('Permissions generated successfully!');
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ class Kernel extends ConsoleKernel
|
||||
protected function commands(): void
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
// $this->load(__DIR__.'/Commands/GeneratePermissions.php');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
@@ -33,23 +33,213 @@ class CCMS
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
// private function initDB()
|
||||
// {
|
||||
// static $initialized = false;
|
||||
// if (!$initialized) {
|
||||
|
||||
function getRouteList()
|
||||
{
|
||||
$routes = Route::getRoutes();
|
||||
$ignoreRoutes = ['debugbar', 'login', 'register', 'logout', 'post', 'sanctum', 'ignition', 'unisharp', 'errorpage', 'form7', 'master', 'hr', 'setting', 'nepalidictonary', 'api'];
|
||||
$routeNameArr = [];
|
||||
foreach ($routes as $value) {
|
||||
if (!is_null($value)) {
|
||||
$routeName = explode('.', $value->getName());
|
||||
if (is_array($routeName) && !empty($routeName[0])) {
|
||||
if (!in_array($routeName[0], $ignoreRoutes)) {
|
||||
$routeNameArr[$routeName[0]][] = $value->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $routeNameArr;
|
||||
}
|
||||
|
||||
// if (!(DB::table('users')->first())) {
|
||||
// DB::statement("INSERT INTO `tbl_users` (`name`,`email`,`username`,`password`,`status`) VALUES ('Prajwal Adhikari','prajwalbro@hotmail.com','prajwalbro@hotmail.com','$2y$10$3zlF9VeXexzWKRDPZuDio.W7RZIC3tU.cjwMoLzG8ki8bVwAQn1WW','1');");
|
||||
// }
|
||||
// if (!(DB::table('settings')->first())) {
|
||||
// DB::statement("INSERT INTO `tbl_settings` (`title`, `description`, `status`) values ('Bibhuti LMS', '', '1');");
|
||||
// }
|
||||
// if (!(DB::table('articles')->first())) {
|
||||
// DB::statement("INSERT INTO `tbl_articles` (`title`,`alias`, `text`, `status`) VALUES ('Company Profile', 'company-profile','Welcome Article', '1');");
|
||||
// }
|
||||
function generateEstimateNumber()
|
||||
{
|
||||
$lastEstimate = Estimate::withTrashed()->latest()->first();
|
||||
|
||||
// $initialized = true;
|
||||
// }
|
||||
// }
|
||||
if ($lastEstimate) {
|
||||
$newEstimateNumber = intval($lastEstimate->id) + 1;
|
||||
return 'EST-' . activeFiscalYear('code') . '-' . str_pad($newEstimateNumber, 4, '0', STR_PAD_LEFT);
|
||||
|
||||
} else {
|
||||
return 'EST-' . activeFiscalYear('code') . '-' . str_pad(1, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
function generateCreditNoteNumber()
|
||||
{
|
||||
$lastCreditNote = CreditNote::withTrashed()->latest()->first();
|
||||
|
||||
if ($lastCreditNote) {
|
||||
$newCreditNoteNumber = intval($lastCreditNote->id) + 1;
|
||||
return 'CN-' . activeFiscalYear('code') . '-' . str_pad($newCreditNoteNumber, 4, '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
return 'CN-' . activeFiscalYear('code') . '-' . str_pad(1, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
function generateInvoiceNumber()
|
||||
{
|
||||
$lastInvoice = Invoice::withTrashed()->latest()->first();
|
||||
|
||||
if ($lastInvoice) {
|
||||
$newInvoiceNumber = intval($lastInvoice->id) + 1;
|
||||
return 'INV-' . activeFiscalYear('code') . '-' . str_pad($newInvoiceNumber, 4, '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
return 'INV-' . activeFiscalYear('code') . '-' . str_pad(1, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
function generateReceivedInvoiceNumber()
|
||||
{
|
||||
$lastReceivedInvoice = ReceivedInvoice::withTrashed()->latest()->first();
|
||||
|
||||
if ($lastReceivedInvoice) {
|
||||
$newReceivedInvoiceNumber = intval($lastReceivedInvoice->id) + 1;
|
||||
return 'RI-' . activeFiscalYear('code') . '-' . str_pad($newReceivedInvoiceNumber, 4, '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
return 'RI-' . activeFiscalYear('code') . '-' . str_pad(1, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
function generateCashReceivedNumber()
|
||||
{
|
||||
$lastCastReceived = CashReceived::withTrashed()->latest()->first();
|
||||
|
||||
if ($lastCastReceived) {
|
||||
$newCastReceivedNumber = intval($lastCastReceived->id) + 1;
|
||||
return 'CR-' . activeFiscalYear('code') . '-' . str_pad($newCastReceivedNumber, 4, '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
return 'CR-' . activeFiscalYear('code') . '-' . str_pad(1, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
function generateDebitNoteNumber()
|
||||
{
|
||||
$lastDebitNote = DebitNote::withTrashed()->latest()->first();
|
||||
|
||||
if ($lastDebitNote) {
|
||||
$newDebitNoteNumber = intval($lastDebitNote->id) + 1;
|
||||
return 'CR-' . activeFiscalYear('code') . '-' . str_pad($newDebitNoteNumber, 4, '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
return 'CR-' . activeFiscalYear('code') . '-' . str_pad(1, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (!function_exists('sendNotification')) {
|
||||
// function sendNotification($user, $notification = [])
|
||||
// {
|
||||
// \Notification::send($user, new SendNotification($notification));
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!function_exists('uploadImage')) {
|
||||
function uploadImage($file)
|
||||
{
|
||||
$fileName = time() . '_' . $file->getClientOriginalName();
|
||||
$filePath = Storage::disk('public')->putFileAs('uploads', $file, $fileName);
|
||||
return $filePath;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('activeFiscalYear')) {
|
||||
function activeFiscalYear($select)
|
||||
{
|
||||
$fiscalYearModel = FiscalYear::whereStatus(11)->first();
|
||||
return $fiscalYearModel->$select ?? null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('setting')) {
|
||||
function setting($key = '')
|
||||
{
|
||||
// Cache::forget('setting');
|
||||
$setting = Cache::has('setting') ? Cache::get('setting') : Cache::rememberForever('setting', function () {
|
||||
return Setting::get()->mapWithKeys(function ($setting) {
|
||||
return [$setting->key => $setting->value];
|
||||
});;
|
||||
});
|
||||
return $setting->has($key) ? $setting[$key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
function convertAmountInWords($amount): string
|
||||
{
|
||||
$units = [
|
||||
'kharab' => 100000000000,
|
||||
'arab' => 1000000000,
|
||||
'crore' => 10000000,
|
||||
'lakh' => 100000,
|
||||
'thousand' => 1000,
|
||||
'hundred' => 100,
|
||||
];
|
||||
|
||||
$words = [];
|
||||
|
||||
foreach ($units as $unit => $value) {
|
||||
if ($amount >= $value) {
|
||||
$count = floor($amount / $value);
|
||||
$remaining = $amount % $value;
|
||||
$words[] = convertCount($count) . ' ' . $unit;
|
||||
$amount = $remaining;
|
||||
}
|
||||
}
|
||||
|
||||
if ($amount > 0) {
|
||||
$words[] = convertCount($amount);
|
||||
}
|
||||
|
||||
return implode(' ', $words) . ' only /-';
|
||||
}
|
||||
|
||||
function convertCount($count)
|
||||
{
|
||||
$ones = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
|
||||
$teens = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'];
|
||||
$tens = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
|
||||
|
||||
$words = [];
|
||||
|
||||
if ($count >= 100) {
|
||||
$words[] = $ones[floor($count / 100)] . ' hundred';
|
||||
$count %= 100;
|
||||
if ($count > 0) {
|
||||
$words[] = 'and';
|
||||
}
|
||||
}
|
||||
|
||||
if ($count >= 20) {
|
||||
$tensPlace = $tens[floor($count / 10) - 2];
|
||||
$onesPlace = $count % 10;
|
||||
if ($onesPlace > 0) {
|
||||
$words[] = $tensPlace . '-' . $ones[$onesPlace];
|
||||
} else {
|
||||
$words[] = $tensPlace;
|
||||
}
|
||||
} elseif ($count >= 10) {
|
||||
$words[] = $teens[$count - 10];
|
||||
} elseif ($count > 0) {
|
||||
$words[] = $ones[$count];
|
||||
}
|
||||
|
||||
return implode(' ', $words);
|
||||
}
|
||||
|
||||
function getAllKeys($data)
|
||||
{
|
||||
$keys = [];
|
||||
|
||||
foreach ($data as $item) {
|
||||
if (is_object($item)) {
|
||||
$item = (array) $item;
|
||||
}
|
||||
|
||||
if (is_array($item)) {
|
||||
$subKeys = getAllKeys($item);
|
||||
$keys = array_merge($keys, $subKeys);
|
||||
} else {
|
||||
$keys[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($keys);
|
||||
}
|
||||
|
196
app/Http/Controllers/AdcategoriesController.php
Normal file
196
app/Http/Controllers/AdcategoriesController.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\AdCategoryRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Adcategories;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class AdcategoriesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $adCategoryRepository;
|
||||
public function __construct(Adcategories $model, AdCategoryRepository $adCategoryRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->adCategoryRepository = $adCategoryRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(AdcategoriesController::class, 'index', ' Adcategories index');
|
||||
$data = Adcategories::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.adcategories.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(AdcategoriesController::class, 'create', ' Adcategories create');
|
||||
$TableData = Adcategories::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.adcategories.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(AdcategoriesController::class, 'store', ' Adcategories store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_adcategories')]);
|
||||
$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);
|
||||
});
|
||||
|
||||
$requestData['createdBy'] = Auth::user()->id;
|
||||
$requestData['updatedBy'] = Auth::user()->id;
|
||||
|
||||
$this->adCategoryRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Adcategories Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('adcategories.index')->with('success', 'The Adcategories created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Adcategories::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 = Adcategories::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(AdcategoriesController::class, 'show', ' Adcategories show');
|
||||
$data = Adcategories::findOrFail($id);
|
||||
|
||||
return view("crud.generated.adcategories.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AdcategoriesController::class, 'edit', ' Adcategories edit');
|
||||
$TableData = Adcategories::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Adcategories::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.adcategories.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.adcategories.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AdcategoriesController::class, 'update', ' Adcategories update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$filterData = $request->except(['_token', '_method']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
|
||||
$this->adCategoryRepository->update($id, $filterData);
|
||||
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Adcategories updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('adcategories.index')->with('success','The Adcategories updated Successfully.');
|
||||
return redirect()->route('adcategories.index')->with('success', 'The Adcategories updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AdcategoriesController::class, 'destroy', ' Adcategories destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(AdcategoriesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Adcategories Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AdcategoriesController::class, 'destroy', ' Adcategories destroy');
|
||||
$data = Adcategories::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(AdcategoriesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Adcategories Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
203
app/Http/Controllers/AdvertisementsController.php
Normal file
203
app/Http/Controllers/AdvertisementsController.php
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\AdvertisementRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Advertisements;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class AdvertisementsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $advertisementRepository;
|
||||
public function __construct(Advertisements $model, AdvertisementRepository $advertisementRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->advertisementRepository = $advertisementRepository;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(AdvertisementsController::class, 'index', ' Advertisements index');
|
||||
$data = Advertisements::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.advertisements.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(AdvertisementsController::class, 'create', ' Advertisements create');
|
||||
// $sectionData = [
|
||||
// 'topbar' => 'Topbar',
|
||||
// 'sidebar' => 'Sidebar',
|
||||
// 'featuredNews' => 'Featured News',
|
||||
// ''
|
||||
// ]
|
||||
|
||||
$TableData = Advertisements::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.advertisements.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(AdvertisementsController::class, 'store', ' Advertisements store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_advertisements')]);
|
||||
$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);
|
||||
});
|
||||
$requestData['createdby'] = Auth::user()->id;
|
||||
$requestData['updatedby'] = Auth::user()->id;
|
||||
|
||||
$this->advertisementRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Advertisements Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('advertisements.index')->with('success', 'The Advertisements created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Advertisements::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 = Advertisements::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(AdvertisementsController::class, 'show', ' Advertisements show');
|
||||
$data = Advertisements::findOrFail($id);
|
||||
|
||||
return view("crud.generated.advertisements.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AdvertisementsController::class, 'edit', ' Advertisements edit');
|
||||
$TableData = Advertisements::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Advertisements::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.advertisements.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.advertisements.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AdvertisementsController::class, 'update', ' Advertisements update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
|
||||
$filterData = $request->except(['_method', '_token']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
$this->advertisementRepository->update($id, $filterData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Advertisements updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('advertisements.index')->with('success','The Advertisements updated Successfully.');
|
||||
return redirect()->route('advertisements.index')->with('success', 'The Advertisements updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AdvertisementsController::class, 'destroy', ' Advertisements destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(AdvertisementsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Advertisements Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AdvertisementsController::class, 'destroy', ' Advertisements destroy');
|
||||
$data = Advertisements::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(AdvertisementsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Advertisements Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
195
app/Http/Controllers/ArticlesController.php
Normal file
195
app/Http/Controllers/ArticlesController.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\ArticleRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Articles;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class ArticlesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $articleRepository;
|
||||
|
||||
public function __construct(Articles $model, ArticleRepository $articleRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->articleRepository = $articleRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(ArticlesController::class, 'index', ' Articles index');
|
||||
$data = Articles::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.articles.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(ArticlesController::class, 'create', ' Articles create');
|
||||
$TableData = Articles::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.articles.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(ArticlesController::class, 'store', ' Articles store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_articles')]);
|
||||
$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);
|
||||
});
|
||||
$requestData['createdBy'] = Auth::user()->id;
|
||||
$requestData['updatedBy'] = Auth::user()->id;
|
||||
|
||||
$this->articleRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Articles Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('articles.index')->with('success', 'The Articles created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Articles::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 = Articles::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(ArticlesController::class, 'show', ' Articles show');
|
||||
$data = Articles::findOrFail($id);
|
||||
|
||||
return view("crud.generated.articles.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ArticlesController::class, 'edit', ' Articles edit');
|
||||
$TableData = Articles::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Articles::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.articles.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.articles.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ArticlesController::class, 'update', ' Articles update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$filterData = $request->except(['_method', '_token']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
|
||||
$this->articleRepository->update($id, $filterData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Articles updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('articles.index')->with('success','The Articles updated Successfully.');
|
||||
return redirect()->route('articles.index')->with('success', 'The Articles updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ArticlesController::class, 'destroy', ' Articles destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(ArticlesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Articles Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ArticlesController::class, 'destroy', ' Articles destroy');
|
||||
$data = Articles::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(ArticlesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Articles Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
@@ -3,10 +3,13 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Advertisements;
|
||||
use App\Models\Menuitems;
|
||||
use App\Models\User;
|
||||
use App\Models\News;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class AuthenticationController extends Controller
|
||||
{
|
||||
@@ -15,16 +18,26 @@ class AuthenticationController extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
$this->path = config('app.client_path');
|
||||
$ads = Advertisements::where('status', 1)->where('parent_advertisement', 0)->get();
|
||||
$headerMenuItems = Menuitems::where(['parent_menu' => 0, "status" => 1, "menulocations_id" => 1])->with('children')->orderBy('display_order')->get();
|
||||
$footerMenuItems = Menuitems::where(['parent_menu' => 0, "status" => 1, "menulocations_id" => 2])->with('children')->orderBy('display_order')->get();
|
||||
$latestNews = News::where('status', 1)->inRandomOrder()->limit(4)->get();
|
||||
View::share([
|
||||
'ads' => $ads,
|
||||
'headerMenuItems' => $headerMenuItems,
|
||||
'footerMenuItems' => $footerMenuItems,
|
||||
'latestNews' => $latestNews
|
||||
]);
|
||||
}
|
||||
|
||||
public function login()
|
||||
{
|
||||
return view($this->path.'.auth.login');
|
||||
return view($this->path . '.auth.login');
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
return view($this->path.'.auth.registration');
|
||||
return view($this->path . '.auth.registration');
|
||||
}
|
||||
|
||||
public static function store(Request $request)
|
||||
@@ -32,32 +45,27 @@ class AuthenticationController extends Controller
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
'password' => ['required', 'string', 'min:8'],
|
||||
'phone' => ['required', 'integer'],
|
||||
]);
|
||||
|
||||
User::create([
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => bcrypt($request->password),
|
||||
'username' => $request->name
|
||||
]);
|
||||
'username' => $request->name,
|
||||
'phone' => $request->phone,
|
||||
'status' => 1,
|
||||
'email_verified_at' => now()
|
||||
])->assignRole('user');
|
||||
|
||||
$credentials = $request->only('email', 'password');
|
||||
if (Auth::attempt($credentials)) {
|
||||
$request->session()->regenerate();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'You have successfully logged in!',
|
||||
'redirect_url' => route('home')
|
||||
]);
|
||||
}
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'The provided credentials do not match our records.'
|
||||
]);
|
||||
dd($user);
|
||||
return response()->json(['success' => true, 'message' => 'User created successfully!', 'redirect_url' => route('userLogin')]);
|
||||
}
|
||||
|
||||
public static function authenticate(Request $request){
|
||||
|
||||
public static function authenticate(Request $request)
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
'email' => ['required', 'string', 'email', 'max:255'],
|
||||
'password' => ['required', 'string', 'min:8'],
|
||||
@@ -77,12 +85,12 @@ class AuthenticationController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public static function logout(Request $request){
|
||||
public static function logout(Request $request)
|
||||
{
|
||||
Auth::logout();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect()->route('userLogin');
|
||||
|
||||
}
|
||||
}
|
||||
|
193
app/Http/Controllers/AuthorsController.php
Normal file
193
app/Http/Controllers/AuthorsController.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Authors;
|
||||
use App\Repositories\AuthorRepository;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class AuthorsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $authorRepository;
|
||||
|
||||
public function __construct(Authors $model, AuthorRepository $authorRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->authorRepository = $authorRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(AuthorsController::class, 'index', ' Authors index');
|
||||
$data = Authors::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.authors.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(AuthorsController::class, 'create', ' Authors create');
|
||||
$TableData = Authors::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.authors.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(AuthorsController::class, 'store', ' Authors store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_authors')]);
|
||||
$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);
|
||||
});
|
||||
$requestData['createdBy'] = Auth::user()->id;
|
||||
$requestData['updatedBy'] = Auth::user()->id;
|
||||
|
||||
$this->authorRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Authors Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('authors.index')->with('success', 'The Authors created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Authors::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 = Authors::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(AuthorsController::class, 'show', ' Authors show');
|
||||
$data = Authors::findOrFail($id);
|
||||
|
||||
return view("crud.generated.authors.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AuthorsController::class, 'edit', ' Authors edit');
|
||||
$TableData = Authors::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Authors::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.authors.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.authors.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AuthorsController::class, 'update', ' Authors update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$filterData = $request->except('_token', '_method');
|
||||
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
$this->authorRepository->update($id,$filterData);
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Authors updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('authors.index')->with('success','The Authors updated Successfully.');
|
||||
return redirect()->route('authors.index')->with('success', 'The Authors updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AuthorsController::class, 'destroy', ' Authors destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(AuthorsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Authors Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(AuthorsController::class, 'destroy', ' Authors destroy');
|
||||
$data = Authors::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(AuthorsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Authors Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
171
app/Http/Controllers/CommentsController.php
Normal file
171
app/Http/Controllers/CommentsController.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Comments;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use App\Repositories\CommentsRepository;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class CommentsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $commentRepository;
|
||||
public function __construct(Comments $model, CommentsRepository $commentRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->commentRepository = $commentRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(CommentsController::class, 'index', ' Comments index');
|
||||
$data = Comments::where('status','<>',-1)->orderBy('created_at')->get();
|
||||
|
||||
return view("crud.generated.comments.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(CommentsController::class, 'create', ' Comments create');
|
||||
$TableData = Comments::where('status','<>',-1)->orderBy('created_at')->get();
|
||||
return view("crud.generated.comments.create",compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(CommentsController::class, 'store', ' Comments store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
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);
|
||||
});
|
||||
$this->commentRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Comments Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('comments.index')->with('success','The Comments created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Comments::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 = Comments::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(CommentsController::class, 'show', ' Comments show');
|
||||
$data = Comments::findOrFail($id);
|
||||
|
||||
return view("crud.generated.comments.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(CommentsController::class, 'edit', ' Comments edit');
|
||||
$TableData = Comments::where('status','<>',-1)->orderBy('created_at')->get();
|
||||
$data = Comments::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.comments.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.comments.edit", compact('data','TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(CommentsController::class, 'update', ' Comments update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$filterData=$request->except(['_method','_token']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
$this->commentRepository->update($id, $filterData);
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Comments updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('comments.index')->with('success','The Comments updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Comments updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request,$id)
|
||||
{
|
||||
// dd($id);
|
||||
$this->commentRepository->delete($id);
|
||||
return response()->json(['status'=>true,'message'=>'The Comments Deleted Successfully.'],200);
|
||||
}
|
||||
public function toggle(Request $request,$id)
|
||||
{
|
||||
createActivityLog(CommentsController::class, 'destroy', ' Comments destroy');
|
||||
$data = Comments::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(CommentsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status'=>true,'message'=>'The Comments Deleted Successfully.'],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
192
app/Http/Controllers/EconomiesController.php
Normal file
192
app/Http/Controllers/EconomiesController.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\EconomyRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Economies;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class EconomiesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $economyRepository;
|
||||
public function __construct(Economies $model, EconomyRepository $economyRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->economyRepository = $economyRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(EconomiesController::class, 'index', ' Economies index');
|
||||
$data = Economies::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.economies.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(EconomiesController::class, 'create', ' Economies create');
|
||||
$TableData = Economies::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.economies.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
dd($request->all());
|
||||
createActivityLog(EconomiesController::class, 'store', ' Economies store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_economies')]);
|
||||
$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);
|
||||
});
|
||||
$requestData['createdBy'] = Auth::user()->id;
|
||||
$requestData['updatedBy'] = Auth::user()->id;
|
||||
|
||||
$this->economyRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Economies Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('economies.index')->with('success', 'The Economies created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Economies::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 = Economies::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(EconomiesController::class, 'show', ' Economies show');
|
||||
$data = Economies::findOrFail($id);
|
||||
|
||||
return view("crud.generated.economies.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(EconomiesController::class, 'edit', ' Economies edit');
|
||||
$TableData = Economies::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Economies::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.economies.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.economies.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(EconomiesController::class, 'update', ' Economies update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$filterData = $request->except(['_token', '_method']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
$this->economyRepository->update($id, $filterData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Economies updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('economies.index')->with('success','The Economies updated Successfully.');
|
||||
return redirect()->route('economies.index')->with('success', 'The Economies updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(EconomiesController::class, 'destroy', ' Economies destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(EconomiesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Economies Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(EconomiesController::class, 'destroy', ' Economies destroy');
|
||||
$data = Economies::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(EconomiesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Economies Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
189
app/Http/Controllers/HoroscopesController.php
Normal file
189
app/Http/Controllers/HoroscopesController.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\HoroscopeRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Horoscopes;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class HoroscopesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $HoroscopesRepository;
|
||||
|
||||
public function __construct(Horoscopes $model, HoroscopeRepository $HoroscopesRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->HoroscopesRepository = $HoroscopesRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(HoroscopesController::class, 'index', ' Horoscopes index');
|
||||
$data = Horoscopes::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.horoscope.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(HoroscopesController::class, 'create', ' Horoscopes create');
|
||||
$TableData = Horoscopes::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.horoscope.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(HoroscopesController::class, 'store', ' Horoscopes store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_Horoscopes')]);
|
||||
$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);
|
||||
});
|
||||
$requestData['updatedBy'] = auth()->user()->id;
|
||||
$requestData['createdBy'] = auth()->user()->id;
|
||||
|
||||
$this->HoroscopesRepository->create($requestData);
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Horoscopes Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('horoscope.index')->with('success', 'The Horoscopes created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Horoscopes::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 = Horoscopes::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(HoroscopesController::class, 'show', ' Horoscopes show');
|
||||
$data = Horoscopes::findOrFail($id);
|
||||
|
||||
return view("crud.generated.Horoscopes.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(HoroscopesController::class, 'edit', ' Horoscopes edit');
|
||||
$TableData = Horoscopes::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Horoscopes::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.Horoscopes.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.horoscope.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(HoroscopesController::class, 'update', ' Horoscopes update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
$filterData = $request->except(['_method', '_token']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
$this->HoroscopesRepository->update($id, $filterData);
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Horoscopes updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('Horoscopes.index')->with('success','The Horoscopes updated Successfully.');
|
||||
return redirect()->route('horoscope.index')->with('success', 'The Horoscopes updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(HoroscopesController::class, 'destroy', ' Horoscopes destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(HoroscopesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Horoscopes Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(HoroscopesController::class, 'destroy', ' Horoscopes destroy');
|
||||
$data = Horoscopes::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(HoroscopesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Horoscopes Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
@@ -8,6 +8,7 @@ use App\Service\CommonModelService;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Log;
|
||||
|
||||
@@ -23,49 +24,45 @@ class MenuitemsController extends Controller
|
||||
public function initializeController()
|
||||
{
|
||||
$menuTypes = [
|
||||
['display' => "Economies", 'value' => "tbl_economies"],
|
||||
['display' => "News", 'value' => "tbl_news"],
|
||||
['display' => "News Categories", 'value' => "tbl_newscategories"],
|
||||
['display' => "News Type", 'value' => "tbl_news_type"],
|
||||
['display' => "Provinces", 'value' => "tbl_provinces"],
|
||||
['display' => "Articles", 'value' => "tbl_articles"],
|
||||
['display' => "Country", 'value' => "tbl_countries"],
|
||||
['display' => "Country Articles", 'value' => "tbl_countryarticles"],
|
||||
['display' => "Events", 'value' => "tbl_events"],
|
||||
['display' => "Faqs", 'value' => "tbl_faqs"],
|
||||
['display' => "Institutions", 'value' => "tbl_institutions"],
|
||||
['display' => "News/Blogs", 'value' => "tbl_news"],
|
||||
['display' => "Preparation class", 'value' => "tbl_preparationclasses"],
|
||||
['display' => "Testimonial", 'value' => "tbl_testimonials"],
|
||||
['display' => "Teams", 'value' => "tbl_teams"],
|
||||
['display' => "Videos", 'value' => "tbl_videos"],
|
||||
|
||||
|
||||
['display' => "Custom", 'value' => ""],
|
||||
];
|
||||
|
||||
foreach ($menuTypes as &$menuType) {
|
||||
switch ($menuType['value']) {
|
||||
case 'tbl_articles':
|
||||
$menuType['values'] = json_encode(DB::select("select article_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_countries':
|
||||
$menuType['values'] = json_encode(DB::select("select country_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_countryarticles':
|
||||
$menuType['values'] = json_encode(DB::select("select article_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_events':
|
||||
$menuType['values'] = json_encode(DB::select("select event_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_faqs':
|
||||
$menuType['values'] = json_encode(DB::select("select faq_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_institutions':
|
||||
$menuType['values'] = json_encode(DB::select("select institution_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
case 'tbl_economies':
|
||||
$menuType['values'] = json_encode(DB::select("select economy_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_news':
|
||||
$menuType['values'] = json_encode(DB::select("select news_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_preparationclasses':
|
||||
$menuType['values'] = json_encode(DB::select("select preparationclass_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
case 'tbl_newscategories':
|
||||
$menuType['values'] = json_encode(DB::select("select category_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_testimonials':
|
||||
$menuType['values'] = json_encode(DB::select("select testimonial_id as value, `by` as display from " . $menuType['value'] . " where status=1 order by `by`"));
|
||||
case 'tbl_news_type':
|
||||
$menuType['values'] = json_encode(DB::select("select news_type_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_provinces':
|
||||
$menuType['values'] = json_encode(DB::select("select province_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_articles':
|
||||
$menuType['values'] = json_encode(DB::select("select article_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_teams':
|
||||
$menuType['values'] = json_encode(DB::select("select team_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
case 'tbl_videos':
|
||||
$menuType['values'] = json_encode(DB::select("select video_id as value,title as display from " . $menuType['value'] . " where status=1 Order by title"));
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
$menuType['values'] = "";
|
||||
@@ -110,7 +107,10 @@ class MenuitemsController extends Controller
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->request->add(['alias' => slugify($request->title)]);
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_menuitems')]);
|
||||
$requestData = $request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
@@ -192,6 +192,10 @@ class MenuitemsController extends Controller
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$requestData = $request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
|
225
app/Http/Controllers/NewsController.php
Normal file
225
app/Http/Controllers/NewsController.php
Normal file
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\NewsRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\News;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $newsRepository;
|
||||
|
||||
public function __construct(News $model, NewsRepository $newsRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->newsRepository = $newsRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(NewsController::class, 'index', ' News index');
|
||||
$data = News::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.news.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(NewsController::class, 'create', ' News create');
|
||||
$TableData = News::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.news.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
dd($request->all());
|
||||
$status = $request->input('status');
|
||||
$isFeatured = $request->input('featured_news');
|
||||
createActivityLog(NewsController::class, 'store', ' News store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_news')]);
|
||||
$requestData = $request->all();
|
||||
$requestData['createdBy'] = Auth::user()->id;
|
||||
$requestData['updatedBy'] = Auth::user()->id;
|
||||
|
||||
if ($isFeatured) {
|
||||
News::where('featured_news', 'True')->update(['featured_news' => 'False']);
|
||||
$requestData['featured_news'] = 'True';
|
||||
} else {
|
||||
$requestData['featured_news'] = 'False';
|
||||
}
|
||||
if($status){
|
||||
$requestData['status'] = 1;
|
||||
}else{
|
||||
$requestData['status'] = 0;
|
||||
}
|
||||
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);
|
||||
});
|
||||
|
||||
$this->newsRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The News Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('news.index')->with('success', 'The News created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = News::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 = News::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(NewsController::class, 'show', ' News show');
|
||||
$data = News::findOrFail($id);
|
||||
|
||||
return view("crud.generated.news.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(NewsController::class, 'edit', ' News edit');
|
||||
$TableData = News::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = News::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.news.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.news.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$status = $request->input('status');
|
||||
$isFeatured = $request->input('featured_news');
|
||||
|
||||
createActivityLog(NewsController::class, 'update', ' News update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
$filterData = $request->except('_method', '_token');
|
||||
|
||||
if ($isFeatured) {
|
||||
News::where('featured_news', 'True')->update(['featured_news' => 'False']);
|
||||
$filterData['featured_news'] = 'True';
|
||||
} else {
|
||||
$filterData['featured_news'] = 'False';
|
||||
}
|
||||
if($status){
|
||||
$filterData['status'] = 1;
|
||||
}else{
|
||||
$filterData['status'] = 0;
|
||||
}
|
||||
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
|
||||
$this->newsRepository->update($id, $filterData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The News updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('news.index')->with('success','The News updated Successfully.');
|
||||
return redirect()->route('news.index')->with('success', 'The News updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(NewsController::class, 'destroy', ' News destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(NewsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The News Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(NewsController::class, 'destroy', ' News destroy');
|
||||
$data = News::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(NewsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The News Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
193
app/Http/Controllers/News_typeController.php
Normal file
193
app/Http/Controllers/News_typeController.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\NewsTypeRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\News_type;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class News_typeController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $newsTypeRepository;
|
||||
public function __construct(News_type $model, NewsTypeRepository $newsTypeRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->newsTypeRepository = $newsTypeRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(News_typeController::class, 'index', ' News_type index');
|
||||
$data = News_type::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.news_type.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(News_typeController::class, 'create', ' News_type create');
|
||||
$TableData = News_type::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.news_type.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(News_typeController::class, 'store', ' News_type store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title_neplai),
|
||||
]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_news_type')]);
|
||||
$requestData = $request->all();
|
||||
|
||||
$requestData['createdBy'] = Auth::user()->id;
|
||||
$requestData['updatedBy'] = Auth::user()->id;
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
$this->newsTypeRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The News_type Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('news_type.index')->with('success', 'The News_type created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = News_type::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 = News_type::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(News_typeController::class, 'show', ' News_type show');
|
||||
$data = News_type::findOrFail($id);
|
||||
|
||||
return view("crud.generated.news_type.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(News_typeController::class, 'edit', ' News_type edit');
|
||||
$TableData = News_type::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = News_type::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.news_type.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.news_type.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(News_typeController::class, 'update', ' News_type update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title_nepali),
|
||||
]);
|
||||
$filterData = $request->except(['_token', '_method']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
$this->newsTypeRepository->update($id, $filterData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The News_type updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('news_type.index')->with('success','The News_type updated Successfully.');
|
||||
return redirect()->route('news_type.index')->with('success', 'The News_type updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(News_typeController::class, 'destroy', ' News_type destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(News_typeController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The News_type Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(News_typeController::class, 'destroy', ' News_type destroy');
|
||||
$data = News_type::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(News_typeController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The News_type Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
198
app/Http/Controllers/NewscategoriesController.php
Normal file
198
app/Http/Controllers/NewscategoriesController.php
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Newscategories;
|
||||
use App\Repositories\NewsCategoriesRepository;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class NewscategoriesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
|
||||
protected $newsCategoriesRepository;
|
||||
public function __construct(Newscategories $model, NewsCategoriesRepository $newsCategoriesRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->newsCategoriesRepository = $newsCategoriesRepository;
|
||||
|
||||
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(NewscategoriesController::class, 'index', ' Newscategories index');
|
||||
$data = Newscategories::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.newscategories.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(NewscategoriesController::class, 'create', ' Newscategories create');
|
||||
$TableData = Newscategories::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.newscategories.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(NewscategoriesController::class, 'store', ' Newscategories store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_newscategories')]);
|
||||
$requestData = $request->all();
|
||||
|
||||
$requestData['createdBy'] = Auth::user()->id;
|
||||
$requestData['updatedBy'] = Auth::user()->id;
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
$this->newsCategoriesRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Newscategories Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('newscategories.index')->with('success', 'The Newscategories created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Newscategories::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 = Newscategories::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(NewscategoriesController::class, 'show', ' Newscategories show');
|
||||
$data = Newscategories::findOrFail($id);
|
||||
|
||||
return view("crud.generated.newscategories.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(NewscategoriesController::class, 'edit', ' Newscategories edit');
|
||||
$TableData = Newscategories::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Newscategories::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.newscategories.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.newscategories.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(NewscategoriesController::class, 'update', ' Newscategories update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
$filterData = $request->except(['_token', '_method']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
$this->newsCategoriesRepository->update($id, $filterData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Newscategories updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('newscategories.index')->with('success','The Newscategories updated Successfully.');
|
||||
return redirect()->route('newscategories.index')->with('success', 'The Newscategories updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(NewscategoriesController::class, 'destroy', ' Newscategories destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(NewscategoriesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Newscategories Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(NewscategoriesController::class, 'destroy', ' Newscategories destroy');
|
||||
$data = Newscategories::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(NewscategoriesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Newscategories Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
106
app/Http/Controllers/PermissionsController.php
Normal file
106
app/Http/Controllers/PermissionsController.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\RoleRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use App\Repositories\PermissionRepository;
|
||||
|
||||
|
||||
class PermissionsController extends Controller
|
||||
{
|
||||
private $permissionRepository;
|
||||
private $role;
|
||||
|
||||
public function __construct(permissionRepository $permissionRepository,
|
||||
RoleRepository $role)
|
||||
{
|
||||
$this->permissionRepository = $permissionRepository;
|
||||
$this->role = $role;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Permission Lists';
|
||||
$data['permissionLists'] = $this->permissionRepository->getPermissionListsArrangedByPrefix();
|
||||
$data['roles'] = $this->role->pluck();
|
||||
$data['editable'] = false;
|
||||
return view('crud.generated.permissions.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['editable'] = false;
|
||||
$data['permissionLists'] = $this->permissionRepository->getPermissionListsArrangedByPrefix();
|
||||
return view('user::role.create', $data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Permission $permission)
|
||||
{
|
||||
$data['title'] = "Edit Role";
|
||||
$data['editable'] = true;
|
||||
$data['role'] = $this->role->getRoleById($id);
|
||||
$data['permissionIDsArray'] = $data['role']?->permissions?->pluck('id')->toArray();
|
||||
$data['permissionLists'] = $this->permissionRepository->getPermissionListsArrangedByPrefix();
|
||||
return view('user::role.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Permission $permission)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$permissionDelete = $this->permissionRepository->getPermissionById($id);
|
||||
|
||||
$permissionDelete->delete();
|
||||
return response()->json(['status' => true, 'message' => 'Permission has been deleted'] );
|
||||
}
|
||||
|
||||
public function generatePermissionFromRoutes()
|
||||
{
|
||||
try {
|
||||
$this->permissionRepository->generatePermissionFromRoutes();
|
||||
toastr()->success('Permission generated successfully!');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
|
||||
}
|
||||
return to_route('permissions.index');
|
||||
|
||||
}
|
||||
}
|
181
app/Http/Controllers/PopupsController.php
Normal file
181
app/Http/Controllers/PopupsController.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\PopupRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Popups;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class PopupsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $popupRepository;
|
||||
public function __construct(Popups $model, PopupRepository $popupRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->popupRepository = $popupRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(PopupsController::class, 'index', ' Popups index');
|
||||
$data = Popups::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.popups.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(PopupsController::class, 'create', ' Popups create');
|
||||
$TableData = Popups::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.popups.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(PopupsController::class, 'store', ' Popups store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_popups')]);
|
||||
$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);
|
||||
});
|
||||
$requestData['createdBy'] = auth()->user()->id;
|
||||
$requestData['updatedBy'] = auth()->user()->id;
|
||||
|
||||
$this->popupRepository->create($requestData);
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Popups Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('popups.index')->with('success', 'The Popups created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Popups::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 = Popups::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(PopupsController::class, 'show', ' Popups show');
|
||||
$data = Popups::findOrFail($id);
|
||||
|
||||
return view("crud.generated.popups.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(PopupsController::class, 'edit', ' Popups edit');
|
||||
$TableData = Popups::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Popups::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.popups.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.popups.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(PopupsController::class, 'update', ' Popups update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$filterData = $request->except(['_method','_token']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
$this->popupRepository->update($id, $filterData);
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Popups updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('popups.index')->with('success','The Popups updated Successfully.');
|
||||
return redirect()->route('popups.index')->with('success', 'The Popups updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(PopupsController::class, 'destroy', ' Popups destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(PopupsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Popups Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(PopupsController::class, 'destroy', ' Popups destroy');
|
||||
$data = Popups::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(PopupsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Popups Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
186
app/Http/Controllers/ProvincesController.php
Normal file
186
app/Http/Controllers/ProvincesController.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\ProvinceRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Provinces;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Brian2694\Toastr\Facades\Toastr;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class ProvincesController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
|
||||
private $ProvinceRepository;
|
||||
|
||||
public function __construct(Provinces $model, ProvinceRepository $ProvinceRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->ProvinceRepository = $ProvinceRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(ProvincesController::class, 'index', ' Provinces index');
|
||||
$data = $this->ProvinceRepository->getAll();
|
||||
|
||||
return view("crud.generated.provinces.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(ProvincesController::class, 'create', ' Provinces create');
|
||||
$TableData = Provinces::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.provinces.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'province_nepali_name' => 'nullable|string|max:255',
|
||||
]);
|
||||
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_provinces')]);
|
||||
|
||||
$requestData = $request->all();
|
||||
$requestData['createdBy'] = Auth::user()->id;
|
||||
$requestData['updatedBy'] = Auth::user()->id;
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
$this->ProvinceRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Provinces Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('provinces.index')->with('success', 'The Provinces created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Provinces::find($id);
|
||||
$companyArticle->display_order = $index + 1;
|
||||
$companyArticle->save();
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200);
|
||||
}
|
||||
public function updatealias(Request $request)
|
||||
{
|
||||
|
||||
$articleId = $request->input('articleId');
|
||||
$newAlias = $request->input('newAlias');
|
||||
$companyArticle = Provinces::find($articleId);
|
||||
if (!$companyArticle) {
|
||||
return response()->json(['status' => false, 'content' => 'Company article not found.'], 404);
|
||||
}
|
||||
$companyArticle->alias = $newAlias;
|
||||
$companyArticle->save();
|
||||
return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ProvincesController::class, 'show', ' Provinces show');
|
||||
$data = Provinces::findOrFail($id);
|
||||
|
||||
return view("crud.generated.provinces.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ProvincesController::class, 'edit', ' Provinces edit');
|
||||
$TableData = Provinces::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Provinces::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.provinces.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.provinces.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ProvincesController::class, 'update', ' Provinces update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title),
|
||||
]);
|
||||
|
||||
$filterData = $request->except('_method', '_token');
|
||||
// $requestData = $request->all();
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
|
||||
$this->ProvinceRepository->update($id, $filterData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Provinces updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('provinces.index')->with('success','The Provinces updated Successfully.');
|
||||
return redirect()->route('provinces.index')->with('success', 'The Provinces updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ProvincesController::class, 'destroy', ' Provinces destroy');
|
||||
|
||||
$this->ProvinceRepository->delete($id);
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'The Provinces Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(ProvincesController::class, 'destroy', ' Provinces destroy');
|
||||
$data = Provinces::findOrFail($id);
|
||||
$requestData = ['status' => ($data->status == 1) ? 0 : 1];
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->update($OperationNumber, $OperationNumber, null, $requestData, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(ProvincesController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Provinces Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
103
app/Http/Controllers/RolesController.php
Normal file
103
app/Http/Controllers/RolesController.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\PermissionRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Roles;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Brian2694\Toastr\Facades\Toastr;
|
||||
use App\Repositories\RoleRepository;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class RolesController extends Controller
|
||||
{
|
||||
private $roleRepository;
|
||||
private $permissionRepository;
|
||||
public function __construct(
|
||||
RoleRepository $roleRepository,
|
||||
PermissionRepository $permissionRepository
|
||||
) {
|
||||
$this->roleRepository = $roleRepository;
|
||||
$this->permissionRepository = $permissionRepository;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data['title'] = "List Roles";
|
||||
createActivityLog(RolesController::class, 'index', ' Roles index');
|
||||
$roles = $this->roleRepository->findAll();
|
||||
|
||||
return view("crud.generated.roles.index", compact('roles'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = "Create Role";
|
||||
$data['editable'] = false;
|
||||
$data['permissionLists'] = $this->permissionRepository->getPermissionListsArrangedByPrefix();
|
||||
return view('crud.generated.roles.create', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'name' => 'required',
|
||||
'guard_name' => 'string',
|
||||
]);
|
||||
|
||||
$role = $this->roleRepository->create($validatedData);
|
||||
|
||||
$role->permissions()->attach($request->permissions);
|
||||
|
||||
Toastr::success('New Role has been created', 'Title', ["positionClass" => "toast-top-center"]);
|
||||
} catch (\Throwable $th) {
|
||||
Toastr::success('Error while creating', 'Title', ["positionClass" => "toast-top-center"]);
|
||||
}
|
||||
return redirect()->route('roles.index');
|
||||
}
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = "Edit Role";
|
||||
$data['editable'] = false;
|
||||
$data['role'] = $this->roleRepository->getRoleById($id);
|
||||
$data['permissionIDsArray'] = $data['role']?->permissions?->pluck('id')->toArray();
|
||||
$data['permissionLists'] = $this->permissionRepository->getPermissionListsArrangedByPrefix();
|
||||
return view('crud.generated.roles.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$validatedData = $request->validate([
|
||||
'name' => 'required',
|
||||
'guard_name' => 'string',
|
||||
]);
|
||||
|
||||
$role = $this->roleRepository->update($id, $validatedData);
|
||||
$role->permissions()->sync($request->permissions);
|
||||
|
||||
Toastr::success('Role has been updated', 'Title', ["positionClass" => "toast-top-center"]);
|
||||
} catch (\Throwable $th) {
|
||||
Toastr::success('Error while updating', 'Title', ["positionClass" => "toast-top-center"]);
|
||||
}
|
||||
return redirect()->route('roles.index');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->roleRepository->delete($id);
|
||||
Toastr::success('Role has been deleted', 'Title', ["positionClass" => "toast-top-center"]);
|
||||
return response()->json(['status' => true, 'message' => 'Role has been deleted!']);
|
||||
}
|
||||
}
|
@@ -1,20 +1,27 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\SettingRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
public function __construct(Settings $model)
|
||||
protected $settingRepository;
|
||||
|
||||
public function __construct(Settings $model, SettingRepository $settingRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->settingRepository = $settingRepository;
|
||||
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
@@ -43,7 +50,9 @@
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$request->request->add(['alias' => slugify($request->title)]);
|
||||
|
||||
// $request->mergeIfMissing(['alias' => Str::slug($request->title)]);
|
||||
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_settings')]);
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
@@ -52,21 +61,16 @@
|
||||
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();
|
||||
$requestData['createdby'] = Auth::user()->id;
|
||||
$requestData['updatedby'] = Auth::user()->id;
|
||||
|
||||
$this->settingRepository->create($requestData);
|
||||
|
||||
|
||||
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.');
|
||||
return redirect()->back()->with('success','The Settings created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
@@ -132,24 +136,23 @@
|
||||
'error' => $validator->errors(),
|
||||
],500);
|
||||
}
|
||||
$requestData=$request->all();
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
|
||||
// $request->mergeIfMissing([
|
||||
// 'alias' => Str::slug($request->title),
|
||||
// ]);
|
||||
|
||||
$filterData = $request->except('_method','_token');
|
||||
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL').'/', '', $value);
|
||||
});
|
||||
array_walk_recursive($requestData, function (&$value) {
|
||||
array_walk_recursive($filterData, 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();
|
||||
|
||||
|
||||
$this->settingRepository->update($id, $filterData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Settings updated Successfully.'], 200);
|
||||
}
|
||||
|
197
app/Http/Controllers/TeamsController.php
Normal file
197
app/Http/Controllers/TeamsController.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\TeamsRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Teams;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class TeamsController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $teamsRepository;
|
||||
public function __construct(Teams $model, TeamsRepository $teamsRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->teamsRepository = $teamsRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(TeamsController::class, 'index', ' Teams index');
|
||||
$data = Teams::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.teams.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(TeamsController::class, 'create', ' Teams create');
|
||||
$TableData = Teams::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.teams.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(TeamsController::class, 'store', ' Teams store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title)
|
||||
]);
|
||||
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_teams')]);
|
||||
$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);
|
||||
});
|
||||
$requestData['createdBy'] = Auth::user()->id;
|
||||
$requestData['updatedBy'] = Auth::user()->id;
|
||||
|
||||
$this->teamsRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Teams Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('teams.index')->with('success', 'The Teams created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Teams::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 = Teams::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(TeamsController::class, 'show', ' Teams show');
|
||||
$data = Teams::findOrFail($id);
|
||||
|
||||
return view("crud.generated.teams.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(TeamsController::class, 'edit', ' Teams edit');
|
||||
$TableData = Teams::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Teams::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.teams.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.teams.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(TeamsController::class, 'update', ' Teams update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
|
||||
$request->mergeIfMissing([
|
||||
'alias' => Str::slug($request->title)
|
||||
]);
|
||||
|
||||
$filterData = $request->except(['_token', '_method']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
|
||||
|
||||
$this->teamsRepository->update($filterData, $id);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Teams updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('teams.index')->with('success','The Teams updated Successfully.');
|
||||
return redirect()->back()->with('success', 'The Teams updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(TeamsController::class, 'destroy', ' Teams destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(TeamsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Teams Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(TeamsController::class, 'destroy', ' Teams destroy');
|
||||
$data = Teams::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(TeamsController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Teams Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
137
app/Http/Controllers/UsersController.php
Normal file
137
app/Http/Controllers/UsersController.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\RoleInterface;
|
||||
use App\Repositories\RoleRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Brian2694\Toastr\Facades\Toastr;
|
||||
|
||||
class UsersController extends Controller
|
||||
{
|
||||
protected $userRepository;
|
||||
protected $employeeRepository;
|
||||
protected $roleRepository;
|
||||
|
||||
public function __construct(UserRepository $userRepository, RoleRepository $roleRepository)
|
||||
{
|
||||
$this->userRepository = $userRepository;
|
||||
$this->roleRepository = $roleRepository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data['users'] = $this->userRepository->findAll();
|
||||
$data['editable'] = false;
|
||||
$data['roleLists'] = $this->roleRepository->pluck();
|
||||
return view('crud.generated.users.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = "Create User";
|
||||
$data['editable'] = false;
|
||||
$data['roleLists'] = $this->roleRepository->pluck();
|
||||
return view('crud.generated.users.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
// try {
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|min:5',
|
||||
'email' => 'required',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
$validated['password'] = bcrypt($validated['password']);
|
||||
|
||||
$this->userRepository->create($validated, $request->role);
|
||||
|
||||
Toastr::success('User has been created successfully.', 'Title', ["positionClass" => "toast-top-center"]);
|
||||
|
||||
// } catch (\Throwable $th) {
|
||||
|
||||
// echo $th->getMessage();
|
||||
|
||||
// toastr()->error($th->getMessage());
|
||||
|
||||
// }
|
||||
|
||||
return redirect()->route('user.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data['user'] = $this->userRepository->getUserById($id);
|
||||
return view('user::user.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = "Edit User";
|
||||
$data['editable'] = true;
|
||||
$data['roleLists'] = $this->roleRepository->pluck();
|
||||
$data['user'] = $this->userRepository->getUserById($id);
|
||||
return view('crud.generated.users.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|min:5',
|
||||
'email' => 'required',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
$validated['password'] = bcrypt($validated['password']);
|
||||
|
||||
$this->userRepository->update($id, $validated, $request->role);
|
||||
|
||||
Toastr::success('User has been updated', 'Title', ["positionClass" => "toast-top-center"]);
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('user.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
|
||||
$this->userRepository->delete($id);
|
||||
|
||||
Toastr::success('User has been deleted', 'Title', ["positionClass" => "toast-top-center"]);
|
||||
} catch (\Throwable $th) {
|
||||
|
||||
Toastr::success('Error deleting user', 'Title', ["positionClass" => "toast-top-center"]);
|
||||
}
|
||||
}
|
||||
}
|
188
app/Http/Controllers/VideosController.php
Normal file
188
app/Http/Controllers/VideosController.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\VideoRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Videos;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Service\CommonModelService;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class VideosController extends Controller
|
||||
{
|
||||
protected $modelService;
|
||||
protected $videoRepository;
|
||||
|
||||
public function __construct(Videos $model, VideoRepository $videoRepository)
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->videoRepository = $videoRepository;
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
createActivityLog(VideosController::class, 'index', ' Videos index');
|
||||
$data = Videos::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
|
||||
return view("crud.generated.videos.index", compact('data'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
createActivityLog(VideosController::class, 'create', ' Videos create');
|
||||
$TableData = Videos::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
return view("crud.generated.videos.create", compact('TableData'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
createActivityLog(VideosController::class, 'store', ' Videos store');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD REQUIRED FIELDS FOR VALIDATION
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing(['alias' => Str::slug($request->title)]);
|
||||
|
||||
$request->request->add(['display_order' => getDisplayOrder('tbl_videos')]);
|
||||
$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);
|
||||
});
|
||||
$requestData['createdBy'] = Auth::user()->id;
|
||||
$requestData['updatedBy'] = Auth::user()->id;
|
||||
|
||||
$this->videoRepository->create($requestData);
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Videos Created Successfully.'], 200);
|
||||
}
|
||||
return redirect()->route('videos.index')->with('success', 'The Videos created Successfully.');
|
||||
}
|
||||
|
||||
public function sort(Request $request)
|
||||
{
|
||||
$idOrder = $request->input('id_order');
|
||||
|
||||
foreach ($idOrder as $index => $id) {
|
||||
$companyArticle = Videos::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 = Videos::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(VideosController::class, 'show', ' Videos show');
|
||||
$data = Videos::findOrFail($id);
|
||||
|
||||
return view("crud.generated.videos.show", compact('data'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
createActivityLog(VideosController::class, 'edit', ' Videos edit');
|
||||
$TableData = Videos::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
$data = Videos::findOrFail($id);
|
||||
if ($request->ajax()) {
|
||||
$html = view("crud.generated.videos.ajax.edit", compact('data'))->render();
|
||||
return response()->json(['status' => true, 'content' => $html], 200);
|
||||
}
|
||||
return view("crud.generated.videos.edit", compact('data', 'TableData'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
createActivityLog(VideosController::class, 'update', ' Videos update');
|
||||
$validator = Validator::make($request->all(), [
|
||||
//ADD VALIDATION FOR REQIRED FIELDS
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors(),
|
||||
], 500);
|
||||
}
|
||||
$request->mergeIfMissing(['alias' => Str::slug($request->title)]);
|
||||
$filterData = $request->except(['_token', '_method']);
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL') . '/', '', $value);
|
||||
});
|
||||
array_walk_recursive($filterData, function (&$value) {
|
||||
$value = str_replace(env('APP_URL'), '', $value);
|
||||
});
|
||||
$this->videoRepository->update($id, $filterData);
|
||||
if ($request->ajax()) {
|
||||
return response()->json(['status' => true, 'message' => 'The Videos updated Successfully.'], 200);
|
||||
}
|
||||
// return redirect()->route('videos.index')->with('success','The Videos updated Successfully.');
|
||||
return redirect()->route('videos.index')->with('success', 'The Videos updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
createActivityLog(VideosController::class, 'destroy', ' Videos destroy');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$OperationNumber = getOperationNumber();
|
||||
$this->modelService->destroy($OperationNumber, $OperationNumber, $id);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::info($e->getMessage());
|
||||
createErrorLog(VideosController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Videos Deleted Successfully.'], 200);
|
||||
}
|
||||
public function toggle(Request $request, $id)
|
||||
{
|
||||
createActivityLog(VideosController::class, 'destroy', ' Videos destroy');
|
||||
$data = Videos::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(VideosController::class, 'destroy', $e->getMessage());
|
||||
return response()->json(['status' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'The Videos Deleted Successfully.'], 200);
|
||||
}
|
||||
}
|
@@ -2,20 +2,213 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\sendEmail;
|
||||
use App\Models\Advertisements;
|
||||
use App\Models\Articles;
|
||||
use App\Models\Comments;
|
||||
use App\Models\Economies;
|
||||
use App\Models\Horoscopes;
|
||||
use App\Models\Menuitems;
|
||||
use App\Models\News;
|
||||
use App\Models\News_type;
|
||||
use App\Models\Newscategories;
|
||||
use App\Models\Popups;
|
||||
use App\Models\Provinces;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Teams;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Models\Videos;
|
||||
use Share;
|
||||
|
||||
class WebsiteController extends Controller
|
||||
{
|
||||
private $path;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$routes = Route::getRoutes();
|
||||
// dd($routes);
|
||||
// foreach ($routes as $route) {
|
||||
// $name= $route->getName();
|
||||
// dump($name);
|
||||
// }
|
||||
// dd('end');
|
||||
$this->path = config('app.client_path');
|
||||
|
||||
$headerMenuItems = Menuitems::where(['parent_menu' => 0, "status" => 1, "menulocations_id" => 1])->with('children')->orderBy('display_order')->get();
|
||||
$footerMenuItems = Menuitems::where(['parent_menu' => 0, "status" => 1, "menulocations_id" => 2])->with('children')->orderBy('display_order')->get();
|
||||
$latestNews = News::where('status', 1)->inRandomOrder()->limit(4)->get();
|
||||
|
||||
$ads = Advertisements::where('status', 1)->where('parent_advertisement', 0)->get();
|
||||
$adsWithChildren = Advertisements::where('status', 1)->where('parent_advertisement', 0)->orderBy('display_order')->with('children')->get();
|
||||
$popup = Popups::where('status',1)->latest()->first();
|
||||
$route = Route::getRoutes();
|
||||
|
||||
View::share(
|
||||
[
|
||||
'headerMenuItems' => $headerMenuItems,
|
||||
'footerMenuItems' => $footerMenuItems,
|
||||
'latestNews' => $latestNews,
|
||||
'ads' => $ads,
|
||||
'adsWithChildren' => $adsWithChildren,
|
||||
'popup' => $popup
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function home(){
|
||||
return view($this->path.'.home');
|
||||
public function home()
|
||||
{
|
||||
$data['featuredNews'] = News::where('featured_news', "True")->where('status', 1)->first();
|
||||
|
||||
$data['provinces'] = Provinces::with('provinceNews')->limit(5)->get();
|
||||
|
||||
$data['categories'] = Newscategories::with('news')->get();
|
||||
$data['interviews'] = Newscategories::with('interviewNews')->get();
|
||||
$data['politics'] = Newscategories::with('politicNews')->get();
|
||||
// $data['economics'] = Newscategories::with('news')->inRandomOrder()->get();
|
||||
$data['economics'] = Economies::with('news')
|
||||
->orderBy('display_order')
|
||||
->where('status', 1)
|
||||
->get();
|
||||
|
||||
|
||||
$data['sports'] = Newscategories::with('sportNews')->get();
|
||||
$data['cultural'] = Newscategories::with('culturalNews')->get();
|
||||
$data['technology'] = Newscategories::with('technologyNews')->get();
|
||||
$data['entertainment'] = Newscategories::with('entertainmentNews')->get();
|
||||
$data['branches'] = Newscategories::with('branchesNews')->get();
|
||||
$data['videos'] = Videos::where('status', 1)->orderBy('display_order')->get();
|
||||
|
||||
$data['horoscope'] = Horoscopes::where('status', 1)->orderBy('display_order')->get();
|
||||
// dd($data['videos']);
|
||||
|
||||
$data['internationalNews'] = News_type::with('news')->get();
|
||||
// dd($data['internationalNews']->toArray());
|
||||
|
||||
|
||||
|
||||
// dd($data['internationalNews']);
|
||||
|
||||
return view($this->path . '.home', $data);
|
||||
}
|
||||
|
||||
public function single(){
|
||||
return view($this->path.'.single');
|
||||
public function single($alias)
|
||||
{
|
||||
$categoryId = Newscategories::where('alias', $alias)->pluck('category_id')->first();
|
||||
$categoryTitle = Newscategories::where('alias', $alias)->pluck('nepali_title')->first();
|
||||
|
||||
$data = News::where('newscategories_id', $categoryId)->where('status', 1)->orderBy('display_order')->paginate(9);
|
||||
|
||||
return view($this->path . '.single', compact('data', 'categoryTitle'));
|
||||
}
|
||||
|
||||
public function newsDetail($alias)
|
||||
{
|
||||
$shareComponent = Share::currentPage()->facebook()->twitter()->whatsapp()->linkedin();
|
||||
$news = News::where('alias', $alias)->where('status', 1)->first();
|
||||
if (!$news) {
|
||||
abort(404, 'News not found');
|
||||
}
|
||||
|
||||
$news->views_count = $news->views_count + 1;
|
||||
$news->save();
|
||||
$newsWithComment = News::with('comments')->where('news_id', $news->news_id)->get();
|
||||
// dd($newsWithComment->toArray());
|
||||
$recentNews = News::where('status', 1)
|
||||
->where('news_id', '!=', $news->news_id)
|
||||
->inRandomOrder()
|
||||
->limit(12)
|
||||
->latest()
|
||||
->get();
|
||||
|
||||
return view($this->path . '.news-detail', compact('news', 'recentNews','shareComponent','newsWithComment'));
|
||||
}
|
||||
|
||||
|
||||
public function showHororscope()
|
||||
{
|
||||
$rashifal = Horoscopes::where('status', 1)->orderBy('display_order')->limit(12)->get();
|
||||
return view($this->path . '.rashifal', compact('rashifal'));
|
||||
}
|
||||
|
||||
public function showInternational($alias)
|
||||
{
|
||||
$categoryTitle = News_type::where('alias', $alias)->value('title_nepali');
|
||||
$data = News::where('news_type_id', 1)
|
||||
->where('status', 1)->orderBy('display_order')->paginate(9);
|
||||
|
||||
return view($this->path . '.single', compact('data', 'categoryTitle'));
|
||||
}
|
||||
|
||||
public function showVideos()
|
||||
{
|
||||
$videos = Videos::where('status', 1)->orderBy('display_order')->paginate(7);
|
||||
// dd($videos->toArray());
|
||||
return view($this->path . '.video', compact('videos'));
|
||||
}
|
||||
|
||||
public function showAboutus($alias)
|
||||
{
|
||||
|
||||
$data['aboutus'] = Articles::where('alias', $alias)->where('status', 1)->first();
|
||||
$data['teams'] = Teams::where('status', 1)->orderBy('display_order')->get();
|
||||
|
||||
return view($this->path . '.about-us', $data);
|
||||
}
|
||||
|
||||
public function showArtilce($alias)
|
||||
{
|
||||
$data['article'] = Articles::with('childrens')->where('alias', $alias)->where('status', 1)->first();
|
||||
return view($this->path . '.article', $data);
|
||||
}
|
||||
|
||||
public function showContact()
|
||||
{
|
||||
return view($this->path . '.contact');
|
||||
}
|
||||
public function sendEmail(Request $request)
|
||||
{
|
||||
if ($request->input('accepted') == 'on') {
|
||||
$requestData = $request->except(['_token', 'accepted']);
|
||||
$validator = Validator::make($requestData, [
|
||||
'title' => 'required|string|max:255',
|
||||
'email' => 'required|email',
|
||||
'phone_number' => 'required|regex:/\d{10}/',
|
||||
'secondary_number' => 'nullable|regex:/\d{10}/',
|
||||
'message' => 'required|string',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->back()->withErrors($validator)->withInput();
|
||||
}
|
||||
|
||||
$validated = $validator->validated();
|
||||
|
||||
try {
|
||||
Mail::to(SITEVARS->email)->send(new SendEmail($validated));
|
||||
return response()->json(['success' => 'Email sent successfully']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['error' => 'Failed to send email'], 500);
|
||||
}
|
||||
} else {
|
||||
return response()->json(['error' => 'Acceptance checkbox is required'], 400);
|
||||
}
|
||||
}
|
||||
|
||||
public function showProvinces($id)
|
||||
{
|
||||
$categoryTitle = Provinces::where('province_id', $id)->pluck('province_nepali_name')->first();
|
||||
$data = News::where('provinces_id', $id)->where('status', 1)->orderBy('display_order')->paginate(9);
|
||||
return view($this->path . '.single', compact('data', 'categoryTitle'));
|
||||
}
|
||||
|
||||
public function videoDetail($alias)
|
||||
{
|
||||
$data = Videos::where('alias', $alias)->where('status', 1)->first();
|
||||
$recentNews = News::where('status', 1)->inRandomOrder()->limit(12)->latest()->get();
|
||||
return view($this->path . '.video-detail', compact('data', 'recentNews'));
|
||||
}
|
||||
}
|
||||
|
@@ -36,11 +36,12 @@ class Kernel extends HttpKernel
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\PermissionMiddleware::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
@@ -64,5 +65,8 @@ class Kernel extends HttpKernel
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
// 'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
|
||||
'permission' => \App\Http\Middleware\PermissionMiddleware::class,
|
||||
// 'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
|
||||
];
|
||||
}
|
||||
|
62
app/Http/Middleware/PermissionMiddleware.php
Normal file
62
app/Http/Middleware/PermissionMiddleware.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Spatie\Permission\Exceptions\UnauthorizedException;
|
||||
use Spatie\Permission\Guard;
|
||||
|
||||
class PermissionMiddleware
|
||||
{
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
$authGuard = Auth::guard($guard);
|
||||
|
||||
$user = $authGuard->user();
|
||||
|
||||
// For machine-to-machine Passport clients
|
||||
if (!$user && $request->bearerToken() && config('permission.use_passport_client_credentials')) {
|
||||
|
||||
$user = Guard::getPassportClient($guard);
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
|
||||
throw UnauthorizedException::notLoggedIn();
|
||||
}
|
||||
|
||||
if (!method_exists($user, 'hasAnyPermission')) {
|
||||
|
||||
throw UnauthorizedException::missingTraitHasRoles($user);
|
||||
}
|
||||
|
||||
// if ($user->hasRole('admin')) {
|
||||
// return $next($request);
|
||||
// }
|
||||
|
||||
foreach ($user->roles as $role) {
|
||||
if ($role->hasPermissionTo($request->route()->getName())) {
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
throw UnauthorizedException::forPermissions($user->getAllPermissions()->toArray());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the permission and guard for the middleware.
|
||||
*
|
||||
* @param array|string $permission
|
||||
* @param string|null $guard
|
||||
* @return string
|
||||
*/
|
||||
public static function using($permission, $guard = null)
|
||||
{
|
||||
$permissionString = is_string($permission) ? $permission : implode('|', $permission);
|
||||
$args = is_null($guard) ? $permissionString : "$permissionString,$guard";
|
||||
|
||||
return static::class . ':' . $args;
|
||||
}
|
||||
}
|
54
app/Mail/sendEmail.php
Normal file
54
app/Mail/sendEmail.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class sendEmail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $data;
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Send Email',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'hulaki_khabar.email.contact',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
49
app/Models/Adcategories.php
Normal file
49
app/Models/Adcategories.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Adcategories extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'category_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'alias',
|
||||
'status',
|
||||
'display_order',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
65
app/Models/Advertisements.php
Normal file
65
app/Models/Advertisements.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Advertisements extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'advertisement_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'ad_categories_id',
|
||||
'alias',
|
||||
'valid_till',
|
||||
'parent_advertisement',
|
||||
'thumb',
|
||||
'link',
|
||||
'display_order',
|
||||
'status',
|
||||
'remarks',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(Advertisements::class, 'parent_advertisement');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Advertisements::class, 'parent_advertisement');
|
||||
}
|
||||
}
|
67
app/Models/Articles.php
Normal file
67
app/Models/Articles.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Articles extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'article_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'parent_article',
|
||||
'title',
|
||||
'subtitle',
|
||||
'alias',
|
||||
'text',
|
||||
'cover_photo',
|
||||
'display_order',
|
||||
'status',
|
||||
'seo_keywords',
|
||||
'seo_title',
|
||||
'seo_descriptions',
|
||||
'og_tags',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function childrens()
|
||||
{
|
||||
return $this->hasMany(Articles::class, 'parent_article');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Articles::class, 'parent_article');
|
||||
}
|
||||
}
|
56
app/Models/Authors.php
Normal file
56
app/Models/Authors.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Authors extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'author_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'alias',
|
||||
'author_email',
|
||||
'author_description',
|
||||
'author_image',
|
||||
'status',
|
||||
'display_order',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function publishedNews(){
|
||||
return $this->hasMany(News::class, 'authors_id', 'author_id')->where('status', 1);
|
||||
}
|
||||
}
|
53
app/Models/Comments.php
Normal file
53
app/Models/Comments.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Comments extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'parent_id',
|
||||
'users_id',
|
||||
'news_id',
|
||||
'content',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
|
||||
public function news():BelongsTo{
|
||||
|
||||
return $this->belongsTo(News::class,'news_id','news_id');
|
||||
}
|
||||
|
||||
public function parent(){
|
||||
return $this->belongsTo(Comments::class,'parent_id');
|
||||
}
|
||||
|
||||
public function subComments(){
|
||||
return $this->hasMany(Comments::class,'parent_id');
|
||||
}
|
||||
|
||||
public function user(){
|
||||
return $this->belongsTo(User::class, 'users_id', 'id');
|
||||
}
|
||||
|
||||
}
|
54
app/Models/Economies.php
Normal file
54
app/Models/Economies.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Economies extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'economy_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'ecomomy_nepali_name',
|
||||
'alias',
|
||||
'status',
|
||||
'display_order',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function news(){
|
||||
return $this->hasMany(News::class, 'economics_id', 'economy_id');
|
||||
}
|
||||
}
|
53
app/Models/Horoscopes.php
Normal file
53
app/Models/Horoscopes.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Horoscopes extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
protected $table = 'horoscopes';
|
||||
protected $primaryKey = 'horoscope_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'title_nepali',
|
||||
'alias',
|
||||
'image',
|
||||
'thumb',
|
||||
'description',
|
||||
'status',
|
||||
'display_order',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
@@ -30,11 +30,11 @@ class OperationLog extends Model
|
||||
];
|
||||
|
||||
|
||||
// protected $appends = ['operation_by'];
|
||||
protected $appends = ['operation_by'];
|
||||
|
||||
// public function getOperationByAttribute()
|
||||
// {
|
||||
// $user = User::find($this->user_id);
|
||||
// return $user ? $user->name : '';
|
||||
// }
|
||||
public function getOperationByAttribute()
|
||||
{
|
||||
$user = User::find($this->user_id);
|
||||
return $user ? $user->name : '';
|
||||
}
|
||||
}
|
@@ -68,4 +68,5 @@ class Menuitems extends Model
|
||||
->orderBy('display_order')
|
||||
->with('children');
|
||||
}
|
||||
|
||||
}
|
||||
|
100
app/Models/News.php
Normal file
100
app/Models/News.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class News extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'news_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'newscategories_id',
|
||||
'provinces_id',
|
||||
'news_type_id',
|
||||
'economics_id',
|
||||
'authors_id',
|
||||
'parent_news',
|
||||
'title',
|
||||
'short_description',
|
||||
'nepali_title',
|
||||
'alias',
|
||||
'content',
|
||||
'featured_news',
|
||||
'image',
|
||||
'thumb',
|
||||
'image_source',
|
||||
'views_count',
|
||||
'display_order',
|
||||
'status',
|
||||
'remarks',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(News::class, 'parent_news');
|
||||
}
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(News::class, 'parent_news');
|
||||
}
|
||||
|
||||
public function newsType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(News_Type::class, 'news_type_id', 'news_type_id');
|
||||
}
|
||||
public function newsCategories(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Newscategories::class, 'newscategories_id', 'category_id');
|
||||
}
|
||||
|
||||
public function author(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'authors_id', 'author_id');
|
||||
}
|
||||
|
||||
public function provinces(): BelongsTo{
|
||||
return $this->belongsTo(Provinces::class, 'provinces_id', 'province_id');
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(Comments::class, 'news_id', 'news_id')->with('subcomments')
|
||||
->where('parent_id', 0)
|
||||
->orWhere('parent_id', null)
|
||||
->where('status', 1);
|
||||
}
|
||||
}
|
56
app/Models/News_type.php
Normal file
56
app/Models/News_type.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class News_type extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'news_type_id';
|
||||
protected $table = 'news_type';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'title_nepali',
|
||||
'alias',
|
||||
'status',
|
||||
'display_order',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function news(): HasMany
|
||||
{
|
||||
return $this->hasMany(News::class, 'news_type_id', 'news_type_id');
|
||||
}
|
||||
|
||||
}
|
96
app/Models/Newscategories.php
Normal file
96
app/Models/Newscategories.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Newscategories extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'category_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'nepali_title',
|
||||
'alias',
|
||||
'parent_category',
|
||||
'display_order',
|
||||
'status',
|
||||
'remarks',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Newscategories::class, 'parent_category')->where('status', 1);
|
||||
}
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(Newscategories::class, 'parent_category')->where('status', 1);
|
||||
}
|
||||
|
||||
public function news()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->orderBy('display_order');
|
||||
}
|
||||
public function entertainmentNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function technologyNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function culturalNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function sportNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(9)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function interviewNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
|
||||
public function politicNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(5)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function branchesNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
|
||||
}
|
45
app/Models/Permissions.php
Normal file
45
app/Models/Permissions.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Permissions extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'guard_name',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
51
app/Models/Popups.php
Normal file
51
app/Models/Popups.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Popups extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
public $timestamps = true;
|
||||
protected $fillable =[
|
||||
'title',
|
||||
'description',
|
||||
'image',
|
||||
'valid_till',
|
||||
'link',
|
||||
'status',
|
||||
'display_order',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
61
app/Models/Provinces.php
Normal file
61
app/Models/Provinces.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Provinces extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'province_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'province_no',
|
||||
'province_nepali_name',
|
||||
'alias',
|
||||
'status',
|
||||
'display_order',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
// protected function createdBy(): Attribute
|
||||
// {
|
||||
// return Attribute::make(
|
||||
// get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
// );
|
||||
// }
|
||||
|
||||
// protected function updatedBy(): Attribute
|
||||
// {
|
||||
// return Attribute::make(
|
||||
// get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
// );
|
||||
// }
|
||||
|
||||
public function provinceNews():HasMany{
|
||||
return $this->hasMany(News::class,'provinces_id','province_id')
|
||||
->where('status','<>',-1)
|
||||
->where('news_type_id',2)
|
||||
->where('newscategories_id',1)
|
||||
->orderBy('display_order');
|
||||
}
|
||||
|
||||
}
|
44
app/Models/Roles.php
Normal file
44
app/Models/Roles.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Roles extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
public $timestamps = true;
|
||||
protected $fillable =[
|
||||
'name',
|
||||
'guard_name',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,32 +1,33 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
namespace App\Models;
|
||||
|
||||
class Sitemenus extends Model
|
||||
{
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Sitemenus extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'menu_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable =[
|
||||
protected $fillable = [
|
||||
'parent_menu',
|
||||
'menulocations_id',
|
||||
'title',
|
||||
'alias',
|
||||
'type',
|
||||
'ref',
|
||||
'target',
|
||||
'display_order',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
'menulocations_id',
|
||||
'title',
|
||||
'alias',
|
||||
'type',
|
||||
'ref',
|
||||
'target',
|
||||
'display_order',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
|
||||
];
|
||||
|
||||
@@ -50,4 +51,4 @@
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
51
app/Models/Teams.php
Normal file
51
app/Models/Teams.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Teams extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'team_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable =[
|
||||
'title',
|
||||
'alias',
|
||||
'photo',
|
||||
'designation',
|
||||
'description',
|
||||
'display_order',
|
||||
'status',
|
||||
'createdby',
|
||||
'updatedby',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
@@ -7,10 +7,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
use HasApiTokens, HasFactory, Notifiable, HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -20,6 +21,7 @@ class User extends Authenticatable
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'phone',
|
||||
'username',
|
||||
'password',
|
||||
];
|
||||
@@ -43,4 +45,8 @@ class User extends Authenticatable
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
|
||||
public function comments(){
|
||||
return $this->hasMany(Comments::class,'users_id','id');
|
||||
}
|
||||
}
|
||||
|
52
app/Models/Videos.php
Normal file
52
app/Models/Videos.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\CreatedUpdatedBy;
|
||||
|
||||
class Videos extends Model
|
||||
{
|
||||
use HasFactory, CreatedUpdatedBy;
|
||||
|
||||
protected $primaryKey = 'video_id';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'video_url',
|
||||
'image',
|
||||
'alias',
|
||||
'description',
|
||||
'status',
|
||||
'display_order',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
|
||||
protected function getStatusNameAttribute()
|
||||
{
|
||||
return $this->status == 1 ? '<span class="badge text-bg-success-soft"> Active </span>' : '<span class="badge text-bg-danger-soft">Inactive</span>';
|
||||
}
|
||||
|
||||
protected function createdBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
|
||||
protected function updatedBy(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => User::find($value) ? User::find($value)->name : '',
|
||||
);
|
||||
}
|
||||
}
|
9
app/Repositories/AdCategoriesInterface.php
Normal file
9
app/Repositories/AdCategoriesInterface.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface AdCategoriesInterface
|
||||
{
|
||||
public function create(array $adCategoriesDetail);
|
||||
public function update($adCategoryId, array $newDetails);
|
||||
}
|
19
app/Repositories/AdCategoryRepository.php
Normal file
19
app/Repositories/AdCategoryRepository.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Adcategories;
|
||||
use App\Repositories\AdCategoriesInterface;
|
||||
|
||||
|
||||
class AdCategoryRepository implements AdCategoriesInterface
|
||||
{
|
||||
public function create(array $adCategoriesDetail)
|
||||
{
|
||||
return Adcategories::create($adCategoriesDetail);
|
||||
}
|
||||
public function update($adCategoryId, array $newDetails)
|
||||
{
|
||||
return Adcategories::where('category_id', $adCategoryId)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/AdvertisementInterface.php
Normal file
12
app/Repositories/AdvertisementInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface AdvertisementInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getAdvertisementById($id);
|
||||
public function delete($advertisementId);
|
||||
public function create(array $advertisementDetail);
|
||||
public function update($advertisementId, array $newDetails);
|
||||
}
|
35
app/Repositories/AdvertisementRepository.php
Normal file
35
app/Repositories/AdvertisementRepository.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Advertisements;
|
||||
use App\Repositories\AdvertisementInterface;
|
||||
|
||||
|
||||
class AdvertisementRepository implements AdvertisementInterface
|
||||
{
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
return Advertisements::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
|
||||
public function getAdvertisementById($advertisementId)
|
||||
{
|
||||
return Advertisements::where('advertisement_id', $advertisementId)->first();
|
||||
}
|
||||
|
||||
public function delete($advertisementId)
|
||||
{
|
||||
return Advertisements::where('advertisement_id', $advertisementId)->delete();
|
||||
}
|
||||
|
||||
public function create(array $newData)
|
||||
{
|
||||
return Advertisements::create($newData);
|
||||
}
|
||||
public function update($advertisementId, array $newDetails)
|
||||
{
|
||||
return Advertisements::where('advertisement_id', $advertisementId)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/ArticleInterface.php
Normal file
12
app/Repositories/ArticleInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface ArticleInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getArticleById($artilceId);
|
||||
public function delete($artilceId);
|
||||
public function create(array $artilceDetails);
|
||||
public function update($artilceId, array $newDetails);
|
||||
}
|
35
app/Repositories/ArticleRepository.php
Normal file
35
app/Repositories/ArticleRepository.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Articles;
|
||||
use App\Repositories\ArticleInterface;
|
||||
|
||||
|
||||
class ArticleRepository implements ArticleInterface
|
||||
{
|
||||
public function getAll()
|
||||
{
|
||||
return Articles::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
|
||||
public function getArticleById($artilceId)
|
||||
{
|
||||
return Articles::findOrFail($artilceId);
|
||||
}
|
||||
|
||||
public function delete($artilceId)
|
||||
{
|
||||
return Articles::destroy($artilceId);
|
||||
}
|
||||
|
||||
public function create(array $provinceDetails)
|
||||
{
|
||||
return Articles::create($provinceDetails);
|
||||
}
|
||||
|
||||
public function update($artilceId, array $newDetails)
|
||||
{
|
||||
return Articles::where('article_id', $artilceId)->update($newDetails);
|
||||
}
|
||||
}
|
34
app/Repositories/AuthorRepository.php
Normal file
34
app/Repositories/AuthorRepository.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Repositories\AuthorsInterface;
|
||||
use App\Models\Authors;
|
||||
|
||||
class AuthorRepository implements AuthorsInterface
|
||||
{
|
||||
public function getAll()
|
||||
{
|
||||
return Authors::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
|
||||
public function getAuthorsById($authorId)
|
||||
{
|
||||
return Authors::findOrFail($authorId);
|
||||
}
|
||||
|
||||
public function delete($authorId)
|
||||
{
|
||||
return Authors::destroy($authorId);
|
||||
}
|
||||
|
||||
public function create(array $authorDetail)
|
||||
{
|
||||
return Authors::create($authorDetail);
|
||||
}
|
||||
|
||||
public function update($authorId, array $newDetails)
|
||||
{
|
||||
return Authors::where('author_id', $authorId)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/AuthorsInterface.php
Normal file
12
app/Repositories/AuthorsInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface AuthorsInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getAuthorsById($authorId);
|
||||
public function delete($authorId);
|
||||
public function create(array $authorDetail);
|
||||
public function update($authorId, array $newDetails);
|
||||
}
|
9
app/Repositories/CommentsInterface.php
Normal file
9
app/Repositories/CommentsInterface.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface CommentsInterface{
|
||||
public function create(array $Details);
|
||||
public function update($commentId, array $newDetails);
|
||||
public function delete($commentId);
|
||||
}
|
25
app/Repositories/CommentsRepository.php
Normal file
25
app/Repositories/CommentsRepository.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Comments;
|
||||
use App\Repositories\CommentsInterface;
|
||||
|
||||
class CommentsRepository implements CommentsInterface
|
||||
{
|
||||
public function create(array $Details)
|
||||
{
|
||||
// dd($Details);
|
||||
return Comments::create($Details);
|
||||
}
|
||||
|
||||
public function update($commentId, array $Details)
|
||||
{
|
||||
return Comments::where('id', $commentId)->update($Details);
|
||||
}
|
||||
|
||||
public function delete($commentId)
|
||||
{
|
||||
return Comments::where('id', $commentId)->delete();
|
||||
}
|
||||
}
|
12
app/Repositories/EconomyInterface.php
Normal file
12
app/Repositories/EconomyInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface EconomyInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getId($id);
|
||||
public function delete($id);
|
||||
public function create(array $Details);
|
||||
public function update($id, array $newDetails);
|
||||
}
|
34
app/Repositories/EconomyRepository.php
Normal file
34
app/Repositories/EconomyRepository.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Economies;
|
||||
use App\Repositories\EconomyInterface;
|
||||
|
||||
|
||||
class EconomyRepository implements EconomyInterface
|
||||
{
|
||||
public function getAll()
|
||||
{
|
||||
return Economies::where('status','<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
|
||||
public function getId($id)
|
||||
{
|
||||
return Economies::findOrFail($id);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
return Economies::destroy($id);
|
||||
}
|
||||
|
||||
public function create(array $Details)
|
||||
{
|
||||
return Economies::create($Details);
|
||||
}
|
||||
|
||||
public function update($id, array $newDetails){
|
||||
return Economies::where('economy_id', $id)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/HoroscopeInterface.php
Normal file
12
app/Repositories/HoroscopeInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface HoroscopeInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getHoroscopeById($horoscopeId);
|
||||
public function delete($horoscopeId);
|
||||
public function create(array $horoscopeDetails);
|
||||
public function update($horoscopeId, array $newDetails);
|
||||
}
|
35
app/Repositories/HoroscopeRepository.php
Normal file
35
app/Repositories/HoroscopeRepository.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Horoscopes;
|
||||
use App\Repositories\HoroscopeInterface;
|
||||
|
||||
|
||||
class HoroscopeRepository implements HoroscopeInterface
|
||||
{
|
||||
public function getAll()
|
||||
{
|
||||
return Horoscopes::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
|
||||
public function getHoroscopeById($horoscopeId)
|
||||
{
|
||||
return Horoscopes::findOrFail($horoscopeId);
|
||||
}
|
||||
|
||||
public function delete($horoscopeId)
|
||||
{
|
||||
return Horoscopes::destroy($horoscopeId);
|
||||
}
|
||||
|
||||
public function create(array $provinceDetails)
|
||||
{
|
||||
return Horoscopes::create($provinceDetails);
|
||||
}
|
||||
|
||||
public function update($horoscopeId, array $newDetails)
|
||||
{
|
||||
return Horoscopes::where('horoscope_id', $horoscopeId)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/NewsCategoriesInterface.php
Normal file
12
app/Repositories/NewsCategoriesInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface NewsCategoriesInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getNewsCategoriesById($newsCategoriesId);
|
||||
public function delete($newsCategoriesId);
|
||||
public function create(array $newsCategoriesDetail);
|
||||
public function update($newsCategoriesId, array $newDetails);
|
||||
}
|
30
app/Repositories/NewsCategoriesRepository.php
Normal file
30
app/Repositories/NewsCategoriesRepository.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Newscategories;
|
||||
use App\Repositories\NewsCategoriesInterface;
|
||||
|
||||
class NewsCategoriesRepository implements NewsCategoriesInterface
|
||||
{
|
||||
public function getAll()
|
||||
{
|
||||
return Newscategories::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
public function getNewsCategoriesById($newsCategoriesId)
|
||||
{
|
||||
return Newscategories::findOrFail($newsCategoriesId);
|
||||
}
|
||||
public function delete($newsCategoriesId)
|
||||
{
|
||||
return Newscategories::destroy($newsCategoriesId);
|
||||
}
|
||||
public function create(array $provinceDetails)
|
||||
{
|
||||
return Newscategories::create($provinceDetails);
|
||||
}
|
||||
public function update($newsCategoriesId, array $newDetails)
|
||||
{
|
||||
return Newscategories::where('category_id', $newsCategoriesId)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/NewsInterface.php
Normal file
12
app/Repositories/NewsInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface NewsInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getNewsById($newsId);
|
||||
public function delete($newsId);
|
||||
public function create(array $newsDetail);
|
||||
public function update($newsId, array $newDetails);
|
||||
}
|
30
app/Repositories/NewsRepository.php
Normal file
30
app/Repositories/NewsRepository.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\News;
|
||||
use App\Repositories\NewsInterface;
|
||||
|
||||
class NewsRepository implements NewsInterface
|
||||
{
|
||||
public function getAll()
|
||||
{
|
||||
return News::where('status', '<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
public function getNewsById($newsId)
|
||||
{
|
||||
return News::findOrFail($newsId);
|
||||
}
|
||||
public function delete($newsId)
|
||||
{
|
||||
return News::destroy($newsId);
|
||||
}
|
||||
public function create(array $newsDetail)
|
||||
{
|
||||
return News::create($newsDetail);
|
||||
}
|
||||
public function update($newsId, array $newDetails)
|
||||
{
|
||||
return News::where('news_id', $newsId)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/NewsTypeInterface.php
Normal file
12
app/Repositories/NewsTypeInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface NewsTypeInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getNewsTypeById($newsTypeId);
|
||||
public function delete($newsTypeId);
|
||||
public function create(array $newsTypeDetail);
|
||||
public function update($newsTypeId, array $newDetails);
|
||||
}
|
34
app/Repositories/NewsTypeRepository.php
Normal file
34
app/Repositories/NewsTypeRepository.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\News_type;
|
||||
use App\Repositories\NewsTypeInterface;
|
||||
|
||||
|
||||
class NewsTypeRepository implements NewsTypeInterface
|
||||
{
|
||||
public function getAll()
|
||||
{
|
||||
return News_type::where('status','<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
|
||||
public function getNewsTypeById($newsTypeId)
|
||||
{
|
||||
return News_type::findOrFail($newsTypeId);
|
||||
}
|
||||
|
||||
public function delete($newsTypeId)
|
||||
{
|
||||
return News_type::destroy($newsTypeId);
|
||||
}
|
||||
|
||||
public function create(array $newsTypeDetail)
|
||||
{
|
||||
return News_type::create($newsTypeDetail);
|
||||
}
|
||||
|
||||
public function update($newsTypeId, array $newDetails){
|
||||
return News_type::where('news_type_id', $newsTypeId)->update($newDetails);
|
||||
}
|
||||
}
|
15
app/Repositories/PermissionInterface.php
Normal file
15
app/Repositories/PermissionInterface.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface PermissionInterface
|
||||
{
|
||||
public function findAll();
|
||||
public function getPermissionById($permissionId);
|
||||
public function delete($permissionId);
|
||||
public function create(array $permissionDetails);
|
||||
public function update($permissionId, array $newDetails);
|
||||
public function getRoleById($roleId);
|
||||
public function getPermissionListsArrangedByPrefix();
|
||||
public static function generatePermissionFromRoutes();
|
||||
}
|
121
app/Repositories/PermissionRepository.php
Normal file
121
app/Repositories/PermissionRepository.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Repositories\PermissionInterface;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class PermissionRepository implements PermissionInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Permission::get();
|
||||
}
|
||||
|
||||
public function getPermissionById($permissionId)
|
||||
{
|
||||
return Permission::findOrFail($permissionId);
|
||||
}
|
||||
|
||||
public function delete($permissionId)
|
||||
{
|
||||
Permission::destroy($permissionId);
|
||||
}
|
||||
|
||||
public function create(array $permissionDetails)
|
||||
{
|
||||
return Permission::create($permissionDetails);
|
||||
}
|
||||
|
||||
public function getRoleById($roleId)
|
||||
{
|
||||
return Role::with('permissions')->findOrFail($roleId);
|
||||
}
|
||||
|
||||
public function update($permissionId, array $newDetails)
|
||||
{
|
||||
return Permission::where('id', $permissionId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function getPermissionListsArrangedByPrefix()
|
||||
{
|
||||
$permissions = self::findAll();
|
||||
|
||||
$routeNameArr = [];
|
||||
foreach ($permissions as $permission) {
|
||||
if (!is_null($permission->name)) {
|
||||
$routeName = explode('.', $permission->name);
|
||||
if (is_array($routeName) && !empty($routeName[0])) {
|
||||
$routeNameArr[$routeName[0]][$permission->id] = array_key_exists(1, $routeName) ? $routeName[1] : $routeName[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $routeNameArr;
|
||||
}
|
||||
|
||||
public static function generatePermissionFromRoutes()
|
||||
{
|
||||
$routes = Route::getRoutes();
|
||||
// dd($routes);
|
||||
|
||||
foreach ($routes as $route) {
|
||||
|
||||
$routeName = $route->getName();
|
||||
|
||||
$ignoreRoutes = [
|
||||
'installer',
|
||||
'LaravelUpdater',
|
||||
'debugbar',
|
||||
'login',
|
||||
'register',
|
||||
'logout',
|
||||
'post',
|
||||
'ignition',
|
||||
'unisharp',
|
||||
'userLogin',
|
||||
'postLogin',
|
||||
'postLogin',
|
||||
'postresgistration',
|
||||
'home',
|
||||
'single',
|
||||
'newsDetail',
|
||||
'password',
|
||||
'showHororscope',
|
||||
'showInternational',
|
||||
'showVideos',
|
||||
'videoDetail',
|
||||
'showAboutus',
|
||||
'showArtilce',
|
||||
'showProvinces',
|
||||
'contact',
|
||||
'sendEmail',
|
||||
'verification',
|
||||
'auth',
|
||||
'upload',
|
||||
'sanctum',
|
||||
'ignition',
|
||||
'welcome',
|
||||
'home',
|
||||
'api'
|
||||
];
|
||||
|
||||
$routePrefix = explode('.', $routeName);
|
||||
|
||||
if (is_array($routePrefix) && !empty($routePrefix[0])) {
|
||||
if (!in_array($routePrefix[0], $ignoreRoutes) && !Permission::where('name', $routeName)->exists()) {
|
||||
Permission::create(['name' => $routeName, 'guard_name' => 'web']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$roles = Role::all();
|
||||
foreach ($roles as $role) {
|
||||
|
||||
if ($role->name == 'admin' || $role->name == 'editor') {
|
||||
$role->givePermissionTo(Permission::all());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
app/Repositories/PopupInterface.php
Normal file
9
app/Repositories/PopupInterface.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface PopupInterface
|
||||
{
|
||||
public function create(array $popupDetail);
|
||||
public function update($popupId, array $newDetails);
|
||||
}
|
19
app/Repositories/PopupRepository.php
Normal file
19
app/Repositories/PopupRepository.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Popups;
|
||||
use App\Repositories\PopupInterface;
|
||||
|
||||
class PopupRepository implements PopupInterface
|
||||
{
|
||||
public function create(array $popupDetail)
|
||||
{
|
||||
Popups::create($popupDetail);
|
||||
}
|
||||
|
||||
public function update($popupId, array $newDetails)
|
||||
{
|
||||
return Popups::where('id', $popupId)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/ProvinceInterface.php
Normal file
12
app/Repositories/ProvinceInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface ProvinceInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getProvinceById($provinceId);
|
||||
public function delete($provinceId);
|
||||
public function create(array $provinceDetails);
|
||||
public function update($provinceId, array $newDetails);
|
||||
}
|
34
app/Repositories/ProvinceRepository.php
Normal file
34
app/Repositories/ProvinceRepository.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Provinces;
|
||||
use App\Repositories\ProvinceInterface;
|
||||
|
||||
|
||||
class ProvinceRepository implements ProvinceInterface
|
||||
{
|
||||
public function getAll()
|
||||
{
|
||||
return Provinces::where('status','<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
|
||||
public function getProvinceById($provinceId)
|
||||
{
|
||||
return Provinces::findOrFail($provinceId);
|
||||
}
|
||||
|
||||
public function delete($provinceId)
|
||||
{
|
||||
return Provinces::destroy($provinceId);
|
||||
}
|
||||
|
||||
public function create(array $provinceDetails)
|
||||
{
|
||||
return Provinces::create($provinceDetails);
|
||||
}
|
||||
|
||||
public function update($provinceId, array $newDetails){
|
||||
return Provinces::where('province_id', $provinceId)->update($newDetails);
|
||||
}
|
||||
}
|
13
app/Repositories/RoleInterface.php
Normal file
13
app/Repositories/RoleInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface RoleInterface
|
||||
{
|
||||
public function pluck();
|
||||
public function findAll();
|
||||
public function getRoleById($roleId);
|
||||
public function delete($roleId);
|
||||
public function create(array $RoleDetails);
|
||||
public function update($roleId, array $newDetails);
|
||||
}
|
57
app/Repositories/RoleRepository.php
Normal file
57
app/Repositories/RoleRepository.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class RoleRepository implements RoleInterface
|
||||
{
|
||||
public function pluck()
|
||||
{
|
||||
return Role::pluck('name', 'id');
|
||||
}
|
||||
|
||||
public function findAll()
|
||||
{
|
||||
return Role::with('permissions')->get();
|
||||
}
|
||||
|
||||
public function getRoleById($roleId)
|
||||
{
|
||||
return Role::with('permissions')->findOrFail($roleId);
|
||||
}
|
||||
|
||||
public function delete($roleId)
|
||||
{
|
||||
$role = self::getRoleById($roleId);
|
||||
$role->permissions()->detach();
|
||||
return $role->delete();
|
||||
}
|
||||
|
||||
public function create(array $roleDetails)
|
||||
{
|
||||
return Role::create($roleDetails);
|
||||
}
|
||||
|
||||
public function update($roleId, array $newDetails)
|
||||
{
|
||||
$role = Role::find($roleId);
|
||||
$role->update($newDetails);
|
||||
return $role;
|
||||
}
|
||||
public function getPermissionListsArrangedByPrefix()
|
||||
{
|
||||
$permissions = self::findAll();
|
||||
|
||||
$routeNameArr = [];
|
||||
foreach ($permissions as $permission) {
|
||||
if (!is_null($permission->name)) {
|
||||
$routeName = explode('.', $permission->name);
|
||||
if (is_array($routeName) && !empty($routeName[0])) {
|
||||
$routeNameArr[$routeName[0]][$permission->id] = array_key_exists(1, $routeName) ? $routeName[1] : $routeName[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $routeNameArr;
|
||||
}
|
||||
}
|
9
app/Repositories/SettingInterface.php
Normal file
9
app/Repositories/SettingInterface.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface SettingInterface
|
||||
{
|
||||
public function create(array $settingDetails);
|
||||
public function update($settingId, array $newDetails);
|
||||
}
|
19
app/Repositories/SettingRepository.php
Normal file
19
app/Repositories/SettingRepository.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Settings;
|
||||
use App\Repositories\SettingInterface;
|
||||
|
||||
class SettingRepository implements SettingInterface
|
||||
{
|
||||
public function create(array $settingDetails)
|
||||
{
|
||||
Settings::create($settingDetails);
|
||||
}
|
||||
|
||||
public function update($settingId, array $newDetails)
|
||||
{
|
||||
return Settings::where('setting_id', $settingId)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/TeamsInterface.php
Normal file
12
app/Repositories/TeamsInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface TeamsInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getTeamById($teamId);
|
||||
public function delete($teamId);
|
||||
public function create(array $teamsDetail);
|
||||
public function update($teamId, array $newDetails);
|
||||
}
|
33
app/Repositories/TeamsRepository.php
Normal file
33
app/Repositories/TeamsRepository.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Teams;
|
||||
use App\Repositories\TeamsInterface;
|
||||
|
||||
class TeamsRepository implements TeamsInterface
|
||||
{
|
||||
public function getAll()
|
||||
{
|
||||
return Teams::where('status','<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
|
||||
public function getTeamById($teamId)
|
||||
{
|
||||
return Teams::findOrFail($teamId);
|
||||
}
|
||||
|
||||
public function delete($teamId)
|
||||
{
|
||||
return Teams::destroy($teamId);
|
||||
}
|
||||
|
||||
public function create(array $provinceDetails)
|
||||
{
|
||||
return Teams::create($provinceDetails);
|
||||
}
|
||||
|
||||
public function update($teamId, array $newDetails){
|
||||
return Teams::where('team_id', $teamId)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/UserInterface.php
Normal file
12
app/Repositories/UserInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\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, array $role);
|
||||
}
|
39
app/Repositories/UserRepository.php
Normal file
39
app/Repositories/UserRepository.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\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 create(array $userDetails, array $role)
|
||||
{
|
||||
$user = User::create($userDetails);
|
||||
$user->roles()->attach($role);
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function update($userId, array $newDetails, array $role)
|
||||
{
|
||||
$user = User::whereId($userId)->update($newDetails);
|
||||
$user->roles()->sync($role);
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function delete($userId)
|
||||
{
|
||||
$user = User::whereId($userId)->first();
|
||||
$user->roles()->detach();
|
||||
return $user->delete();
|
||||
}
|
||||
}
|
34
app/Repositories/VideoRepository.php
Normal file
34
app/Repositories/VideoRepository.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Videos;
|
||||
use App\Repositories\VideosInterface;
|
||||
|
||||
|
||||
class VideoRepository implements VideosInterface
|
||||
{
|
||||
public function getAll()
|
||||
{
|
||||
return Videos::where('status','<>', -1)->orderBy('display_order')->get();
|
||||
}
|
||||
|
||||
public function getVideoById($videoId)
|
||||
{
|
||||
return Videos::findOrFail($videoId);
|
||||
}
|
||||
|
||||
public function delete($videoId)
|
||||
{
|
||||
return Videos::destroy($videoId);
|
||||
}
|
||||
|
||||
public function create(array $provinceDetails)
|
||||
{
|
||||
return Videos::create($provinceDetails);
|
||||
}
|
||||
|
||||
public function update($videoId, array $newDetails){
|
||||
return Videos::where('video_id', $videoId)->update($newDetails);
|
||||
}
|
||||
}
|
12
app/Repositories/VideosInterface.php
Normal file
12
app/Repositories/VideosInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
interface VideosInterface
|
||||
{
|
||||
public function getAll();
|
||||
public function getVideoById($videoId);
|
||||
public function delete($videoId);
|
||||
public function create(array $videoDetails);
|
||||
public function update($videoId, array $newDetails);
|
||||
}
|
@@ -6,11 +6,15 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.1.17",
|
||||
"brian2694/laravel-toastr": "^5.59",
|
||||
"google/recaptcha": "^1.3",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"jorenvanhocht/laravel-share": "^4.2",
|
||||
"laravel/framework": "^10.10",
|
||||
"laravel/sanctum": "^3.2",
|
||||
"laravel/tinker": "^2.8",
|
||||
"spatie/laravel-html": "^3.9",
|
||||
"spatie/laravel-permission": "^6.7",
|
||||
"symfony/process": "^6.3",
|
||||
"unisharp/laravel-filemanager": "^2.6"
|
||||
},
|
||||
|
287
composer.lock
generated
287
composer.lock
generated
@@ -4,8 +4,70 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "2124567ecbcd27da68d10934a73d827a",
|
||||
"content-hash": "a05854bcfd7b9832b94b17acc7cb097d",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brian2694/laravel-toastr",
|
||||
"version": "5.59",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/brian2694/laravel-toastr.git",
|
||||
"reference": "60f90a7b25973549c3992b3dc5965d4f0e27838c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/brian2694/laravel-toastr/zipball/60f90a7b25973549c3992b3dc5965d4f0e27838c",
|
||||
"reference": "60f90a7b25973549c3992b3dc5965d4f0e27838c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/session": ">=5.2.7",
|
||||
"illuminate/support": ">=5.2.7",
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Brian2694\\Toastr\\ToastrServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Toastr": "Brian2694\\Toastr\\Facades\\Toastr"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/helper.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Brian2694\\Toastr\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "brian2694",
|
||||
"email": "briansanchez2694@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "toastr.js for Laravel",
|
||||
"homepage": "https://github.com/brian2694/laravel-toastr",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"notification",
|
||||
"php",
|
||||
"toastr"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/brian2694/laravel-toastr/issues",
|
||||
"source": "https://github.com/brian2694/laravel-toastr/tree/5.59"
|
||||
},
|
||||
"time": "2024-01-02T16:03:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "brick/math",
|
||||
"version": "0.11.0",
|
||||
@@ -1232,6 +1294,69 @@
|
||||
],
|
||||
"time": "2024-02-14T15:11:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jorenvanhocht/laravel-share",
|
||||
"version": "4.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jorenvh/laravel-share.git",
|
||||
"reference": "86af334068038a840567ed62f2082fe3ac981476"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/jorenvh/laravel-share/zipball/86af334068038a840567ed62f2082fe3ac981476",
|
||||
"reference": "86af334068038a840567ed62f2082fe3ac981476",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4|^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^6.13|^7.0",
|
||||
"phpunit/phpunit": "^9.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Jorenvh\\Share\\Providers\\ShareServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Share": "Jorenvh\\Share\\ShareFacade"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Jorenvh\\Share\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Joren Van Hocht",
|
||||
"email": "joren@codeswitch.be",
|
||||
"homepage": "https://codeswitch.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Optional package for Laravel to generate social share links.",
|
||||
"homepage": "https://github.com/jorenvh/laravel-share",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"share",
|
||||
"social links",
|
||||
"social share links"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/jorenvh/laravel-share/issues",
|
||||
"source": "https://github.com/jorenvh/laravel-share/tree/4.2.0"
|
||||
},
|
||||
"time": "2022-02-11T17:20:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v10.44.0",
|
||||
@@ -3372,6 +3497,166 @@
|
||||
],
|
||||
"time": "2023-11-08T05:53:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-html",
|
||||
"version": "3.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/laravel-html.git",
|
||||
"reference": "35802bd9b276ce08e1d9d15584b17fdef965063b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-html/zipball/35802bd9b276ce08e1d9d15584b17fdef965063b",
|
||||
"reference": "35802bd9b276ce08e1d9d15584b17fdef965063b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/http": "^10.0|^11.0",
|
||||
"illuminate/support": "^10.0|^11.0",
|
||||
"php": "^8.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.3",
|
||||
"orchestra/testbench": "^8.0|^9.0",
|
||||
"pestphp/pest": "^2.34"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Spatie\\Html\\HtmlServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Html": "Spatie\\Html\\Facades\\Html"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Spatie\\Html\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian De Deyne",
|
||||
"email": "sebastian@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "A fluent html builder",
|
||||
"homepage": "https://github.com/spatie/laravel-html",
|
||||
"keywords": [
|
||||
"html",
|
||||
"spatie"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/spatie/laravel-html/tree/3.9.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://spatie.be/open-source/support-us",
|
||||
"type": "custom"
|
||||
}
|
||||
],
|
||||
"time": "2024-04-25T08:07:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-permission",
|
||||
"version": "6.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/laravel-permission.git",
|
||||
"reference": "17607924aa0aa89bc0153c2ce45ed7c55083367b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-permission/zipball/17607924aa0aa89bc0153c2ce45ed7c55083367b",
|
||||
"reference": "17607924aa0aa89bc0153c2ce45ed7c55083367b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/auth": "^8.12|^9.0|^10.0|^11.0",
|
||||
"illuminate/container": "^8.12|^9.0|^10.0|^11.0",
|
||||
"illuminate/contracts": "^8.12|^9.0|^10.0|^11.0",
|
||||
"illuminate/database": "^8.12|^9.0|^10.0|^11.0",
|
||||
"php": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/passport": "^11.0|^12.0",
|
||||
"orchestra/testbench": "^6.23|^7.0|^8.0|^9.0",
|
||||
"phpunit/phpunit": "^9.4|^10.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "6.x-dev",
|
||||
"dev-master": "6.x-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Spatie\\Permission\\PermissionServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Spatie\\Permission\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Permission handling for Laravel 8.0 and up",
|
||||
"homepage": "https://github.com/spatie/laravel-permission",
|
||||
"keywords": [
|
||||
"acl",
|
||||
"laravel",
|
||||
"permission",
|
||||
"permissions",
|
||||
"rbac",
|
||||
"roles",
|
||||
"security",
|
||||
"spatie"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/spatie/laravel-permission/issues",
|
||||
"source": "https://github.com/spatie/laravel-permission/tree/6.7.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/spatie",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-04-19T12:35:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v6.4.3",
|
||||
|
@@ -172,6 +172,9 @@ return [
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
// App\Providers\LaravelInstallerServiceProvider::class,
|
||||
Bibhuti\Installer\Providers\LaravelInstallerServiceProvider::class,
|
||||
Brian2694\Toastr\ToastrServiceProvider::class,
|
||||
Spatie\Permission\PermissionServiceProvider::class,
|
||||
Jorenvh\Share\Providers\ShareServiceProvider::class,
|
||||
|
||||
|
||||
])->toArray(),
|
||||
@@ -188,7 +191,9 @@ return [
|
||||
*/
|
||||
|
||||
'aliases' => Facade::defaultAliases()->merge([
|
||||
// 'Example' => App\Facades\Example::class,
|
||||
'Toastr' => Brian2694\Toastr\Facades\Toastr::class,
|
||||
'Share' => Jorenvh\Share\ShareFacade::class,
|
||||
'Html' => Spatie\Html\Facades\Html::class,
|
||||
])->toArray(),
|
||||
|
||||
];
|
||||
|
57
config/laravel-share.php
Normal file
57
config/laravel-share.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the base uri for each service.
|
||||
|
|
||||
|
|
||||
|
|
||||
*/
|
||||
|
||||
'services' => [
|
||||
'facebook' => [
|
||||
'uri' => 'https://www.facebook.com/sharer/sharer.php?u=',
|
||||
],
|
||||
'twitter' => [
|
||||
'uri' => 'https://twitter.com/intent/tweet',
|
||||
'text' => 'Default share text',
|
||||
],
|
||||
'linkedin' => [
|
||||
'uri' => 'https://www.linkedin.com/sharing/share-offsite', // oud: http://www.linkedin.com/shareArticle
|
||||
'extra' => ['mini' => 'true'],
|
||||
],
|
||||
'whatsapp' => [
|
||||
'uri' => 'https://wa.me/?text=',
|
||||
'extra' => ['mini' => 'true'],
|
||||
],
|
||||
'pinterest' => [
|
||||
'uri' => 'https://pinterest.com/pin/create/button/?url=',
|
||||
],
|
||||
'reddit' => [
|
||||
'uri' => 'https://www.reddit.com/submit',
|
||||
'text' => 'Default share text',
|
||||
],
|
||||
'telegram' => [
|
||||
'uri' => 'https://telegram.me/share/url',
|
||||
'text' => 'Default share text',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Font Awesome
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the version of Font Awesome that you want to use.
|
||||
| We support version 4 and 5.
|
||||
|
|
||||
|
|
||||
*/
|
||||
|
||||
'fontAwesomeVersion' => 5,
|
||||
];
|
@@ -50,7 +50,7 @@ return [
|
||||
'file' => [
|
||||
'folder_name' => 'files',
|
||||
'startup_view' => 'list',
|
||||
'max_size' => 50000, // size in KB
|
||||
'max_size' => 500000, // size in KB
|
||||
'thumb' => true,
|
||||
'thumb_width' => 80,
|
||||
'thumb_height' => 80,
|
||||
@@ -66,7 +66,7 @@ return [
|
||||
'image' => [
|
||||
'folder_name' => 'photos',
|
||||
'startup_view' => 'grid',
|
||||
'max_size' => 50000, // size in KB
|
||||
'max_size' => 500000, // size in KB
|
||||
'thumb' => true,
|
||||
'thumb_width' => 80,
|
||||
'thumb_height' => 80,
|
||||
@@ -176,5 +176,6 @@ return [
|
||||
*/
|
||||
'php_ini_overrides' => [
|
||||
'memory_limit' => '256M',
|
||||
|
||||
],
|
||||
];
|
||||
|
186
config/permission.php
Normal file
186
config/permission.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'models' => [
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your permissions. Of course, it
|
||||
* is often just the "Permission" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Permission model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Permission` contract.
|
||||
*/
|
||||
|
||||
'permission' => Spatie\Permission\Models\Permission::class,
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your roles. Of course, it
|
||||
* is often just the "Role" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Role model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Role` contract.
|
||||
*/
|
||||
|
||||
'role' => Spatie\Permission\Models\Role::class,
|
||||
|
||||
],
|
||||
|
||||
'table_names' => [
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'roles' => 'roles',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your permissions. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'permissions' => 'permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_permissions' => 'model_has_permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models roles. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_roles' => 'model_has_roles',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'role_has_permissions' => 'role_has_permissions',
|
||||
],
|
||||
|
||||
'column_names' => [
|
||||
/*
|
||||
* Change this if you want to name the related pivots other than defaults
|
||||
*/
|
||||
'role_pivot_key' => null, //default 'role_id',
|
||||
'permission_pivot_key' => null, //default 'permission_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to name the related model primary key other than
|
||||
* `model_id`.
|
||||
*
|
||||
* For example, this would be nice if your primary keys are all UUIDs. In
|
||||
* that case, name this `model_uuid`.
|
||||
*/
|
||||
|
||||
'model_morph_key' => 'model_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to use the teams feature and your related model's
|
||||
* foreign key is other than `team_id`.
|
||||
*/
|
||||
|
||||
'team_foreign_key' => 'team_id',
|
||||
],
|
||||
|
||||
/*
|
||||
* When set to true, the method for checking permissions will be registered on the gate.
|
||||
* Set this to false if you want to implement custom logic for checking permissions.
|
||||
*/
|
||||
|
||||
'register_permission_check_method' => true,
|
||||
|
||||
/*
|
||||
* When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered
|
||||
* this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated
|
||||
* NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it.
|
||||
*/
|
||||
'register_octane_reset_listener' => false,
|
||||
|
||||
/*
|
||||
* Teams Feature.
|
||||
* When set to true the package implements teams using the 'team_foreign_key'.
|
||||
* If you want the migrations to register the 'team_foreign_key', you must
|
||||
* set this to true before doing the migration.
|
||||
* If you already did the migration then you must make a new migration to also
|
||||
* add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions'
|
||||
* (view the latest version of this package's migration file)
|
||||
*/
|
||||
|
||||
'teams' => false,
|
||||
|
||||
/*
|
||||
* Passport Client Credentials Grant
|
||||
* When set to true the package will use Passports Client to check permissions
|
||||
*/
|
||||
|
||||
'use_passport_client_credentials' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required permission names are added to exception messages.
|
||||
* This could be considered an information leak in some contexts, so the default
|
||||
* setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_permission_in_exception' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required role names are added to exception messages.
|
||||
* This could be considered an information leak in some contexts, so the default
|
||||
* setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_role_in_exception' => false,
|
||||
|
||||
/*
|
||||
* By default wildcard permission lookups are disabled.
|
||||
* See documentation to understand supported syntax.
|
||||
*/
|
||||
|
||||
'enable_wildcard_permission' => false,
|
||||
|
||||
/*
|
||||
* The class to use for interpreting wildcard permissions.
|
||||
* If you need to modify delimiters, override the class and specify its name here.
|
||||
*/
|
||||
// 'permission.wildcard_permission' => Spatie\Permission\WildcardPermission::class,
|
||||
|
||||
/* Cache-specific settings */
|
||||
|
||||
'cache' => [
|
||||
|
||||
/*
|
||||
* By default all permissions are cached for 24 hours to speed up performance.
|
||||
* When permissions or roles are updated the cache is flushed automatically.
|
||||
*/
|
||||
|
||||
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
|
||||
|
||||
/*
|
||||
* The cache key used to store all permissions.
|
||||
*/
|
||||
|
||||
'key' => 'spatie.permission.cache',
|
||||
|
||||
/*
|
||||
* You may optionally indicate a specific cache driver to use for permission and
|
||||
* role caching using any of the `store` drivers listed in the cache.php config
|
||||
* file. Using 'default' here means to use the `default` set in cache.php.
|
||||
*/
|
||||
|
||||
'store' => 'default',
|
||||
],
|
||||
];
|
21
config/toastr.php
Normal file
21
config/toastr.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'options' => [
|
||||
"closeButton" => false,
|
||||
"debug" => false,
|
||||
"newestOnTop" => false,
|
||||
"progressBar" => false,
|
||||
"positionClass" => "toast-top-right",
|
||||
"preventDuplicates" => false,
|
||||
"onclick" => null,
|
||||
"showDuration" => "300",
|
||||
"hideDuration" => "1000",
|
||||
"timeOut" => "5000",
|
||||
"extendedTimeOut" => "1000",
|
||||
"showEasing" => "swing",
|
||||
"hideEasing" => "linear",
|
||||
"showMethod" => "fadeIn",
|
||||
"hideMethod" => "fadeOut"
|
||||
],
|
||||
];
|
@@ -15,11 +15,13 @@ return new class extends Migration
|
||||
$table->id('news_id');
|
||||
$table->integer('newscategories_id')->unsigned();
|
||||
$table->integer('provinces_id')->unsigned();
|
||||
$table->integer('newstypes_id')->unsigned();
|
||||
$table->integer('news_type_id')->unsigned();
|
||||
$table->integer('authors_id')->unsigned();
|
||||
$table->integer('parent_news')->nullable();
|
||||
$table->string('title',255)->nullable();
|
||||
$table->string('nepali_title',255)->nullable();
|
||||
$table->string('alias',255)->nullable();
|
||||
$table->text('short_description')->nullable();
|
||||
$table->longText('content')->nullable();
|
||||
$table->longText('featured_news')->nullable();
|
||||
$table->string('image',255)->nullable();
|
||||
@@ -28,8 +30,8 @@ return new class extends Migration
|
||||
$table->integer('display_order')->default(1);
|
||||
$table->integer('status')->default(1);
|
||||
$table->text('remarks')->nullable();
|
||||
$table->integer('created_by')->nullable();
|
||||
$table->integer('updated_by')->nullable();
|
||||
$table->integer('createdBy')->nullable();
|
||||
$table->integer('updatedBy')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@@ -12,12 +12,17 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('provinces', function (Blueprint $table) {
|
||||
$table->id('priovince_id');
|
||||
$table->string('province_name',255)->nullable();
|
||||
$table->string('province_nepali_name',255)->nullable();
|
||||
$table->string('alias',255)->nullable();
|
||||
$table->id('province_id');
|
||||
$table->string('title', 255)->nullable();
|
||||
$table->string('province_nepali_name', 255)->charset('utf8mb4')->collate('utf8mb4_unicode_ci')->nullable();
|
||||
$table->string('alias', 255)->nullable();
|
||||
$table->integer('status')->default(1);
|
||||
$table->integer('display_order')->default(1);
|
||||
$table->integer('createdBy')->nullable();
|
||||
$table->integer('updatedBy')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -13,9 +13,15 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('authors', function (Blueprint $table) {
|
||||
$table->id('author_id');
|
||||
$table->string('author_name',255)->nullable();
|
||||
$table->string('author_description',255)->nullable();
|
||||
$table->string('author_image',255)->nullable();
|
||||
$table->string('title', 255)->nullable();
|
||||
$table->string('alias', 255)->nullable();
|
||||
$table->string('author_email', 255)->nullable();
|
||||
$table->string('author_description', 255)->nullable();
|
||||
$table->string('author_image', 255)->nullable();
|
||||
$table->integer('status')->default(1);
|
||||
$table->integer('display_order')->default(1);
|
||||
$table->integer('createdBy')->nullable();
|
||||
$table->integer('updatedBy')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@@ -13,7 +13,13 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('news_type', function (Blueprint $table) {
|
||||
$table->id('news_type_id');
|
||||
$table->string('title',255)->nullable();
|
||||
$table->string('title', 255)->nullable();
|
||||
$table->string('title_nepali',255)->nullable();
|
||||
$table->string('alias', 255)->nullable();
|
||||
$table->integer('status')->default(1);
|
||||
$table->integer('display_order')->default(1);
|
||||
$table->integer('createdBy')->nullable();
|
||||
$table->integer('updatedBy')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@@ -11,19 +11,19 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('advertisement', function (Blueprint $table) {
|
||||
Schema::create('advertisements', function (Blueprint $table) {
|
||||
$table->id('advertisement_id');
|
||||
$table->string('title',255)->nullable();
|
||||
$table->integer('ad_categories_id')->nullable();
|
||||
$table->string('alias',255)->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('image',255)->nullable();
|
||||
$table->string('video',255)->nullable();
|
||||
$table->integer('parent_advertisement');
|
||||
$table->string('thumb',255)->nullable();
|
||||
$table->string('link',255)->nullable();
|
||||
$table->integer('display_order')->default(1);
|
||||
$table->integer('status')->default(1);
|
||||
$table->text('remarks')->nullable();
|
||||
$table->integer('created_by')->nullable();
|
||||
$table->integer('updated_by')->nullable();
|
||||
$table->integer('createdBy')->nullable();
|
||||
$table->integer('updatedBy')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@@ -0,0 +1,34 @@
|
||||
<?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('menulocations', function (Blueprint $table) {
|
||||
$table->id('menulocation_id');
|
||||
$table->string('title', 255)->nullable()->default(null);
|
||||
$table->string('alias', 255)->nullable()->default(null);
|
||||
$table->integer('display_order')->default(1);
|
||||
$table->integer('status')->default(1);
|
||||
$table->timestamps();
|
||||
$table->integer('createdby')->nullable()->default(null);
|
||||
$table->integer('updatedby')->nullable()->default(null);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('menulocations');
|
||||
}
|
||||
};
|
@@ -0,0 +1,38 @@
|
||||
<?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('menuitems', function (Blueprint $table) {
|
||||
$table->id('menu_id');
|
||||
$table->integer('parent_menu')->notNullable();
|
||||
$table->integer('menulocations_id')->nullable();
|
||||
$table->string('title', 255)->nullable()->default(null);
|
||||
$table->string('alias', 255)->nullable()->default(null);
|
||||
$table->string('type', 255)->nullable()->default(null);
|
||||
$table->string('ref', 255)->nullable()->default(null);
|
||||
$table->string('target', 255)->nullable()->default(null);
|
||||
$table->integer('display_order')->default(1);
|
||||
$table->integer('status')->default(1);
|
||||
$table->timestamps();
|
||||
$table->integer('createdby')->nullable()->default(null);
|
||||
$table->integer('updatedby')->nullable()->default(null);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('menuitems');
|
||||
}
|
||||
};
|
@@ -0,0 +1,32 @@
|
||||
<?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('activity_logs', function (Blueprint $table) {
|
||||
$table->id('activity_id');
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('controllerName')->nullable();
|
||||
$table->string('methodName')->nullable();
|
||||
$table->string('actionUrl')->nullable();
|
||||
$table->string('activity')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('activity_logs');
|
||||
}
|
||||
};
|
31
database/migrations/2024_06_13_162112_create_error_logs.php
Normal file
31
database/migrations/2024_06_13_162112_create_error_logs.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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('error_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('user_id')->unsigned()->default(NULL);
|
||||
$table->string('controller_name')->default(NULL);
|
||||
$table->string('method_name')->default(NULL);
|
||||
$table->string('errors')->default(NULL);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('error_logs');
|
||||
}
|
||||
};
|
@@ -0,0 +1,37 @@
|
||||
<?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('operation_logs', function (Blueprint $table) {
|
||||
$table->id('operation_id');
|
||||
$table->string('refNo', 255)->nullable()->default(null);
|
||||
$table->integer('user_id')->nullable()->default(null);
|
||||
$table->bigInteger('operation_start_no')->nullable()->default(null);
|
||||
$table->bigInteger('operation_end_no')->nullable()->default(null);
|
||||
$table->string('model_name', 100)->nullable()->default(null);
|
||||
$table->integer('model_id')->nullable()->default(null);
|
||||
$table->string('operation_name', 100)->nullable()->default(null);
|
||||
$table->text('previous_values')->nullable()->default(null);
|
||||
$table->longText('new_values')->nullable()->default(null);
|
||||
$table->timestamp('created_at')->nullable()->default(null);
|
||||
$table->timestamp('updated_at')->nullable()->default(null);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('operation_logs');
|
||||
}
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user