diff --git a/app/Http/Controllers/Admin/ManageSubAdminController.php b/app/Http/Controllers/Admin/ManageSubAdminController.php index 1cdf337..28c804a 100644 --- a/app/Http/Controllers/Admin/ManageSubAdminController.php +++ b/app/Http/Controllers/Admin/ManageSubAdminController.php @@ -4,10 +4,162 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use Illuminate\Http\Request; - +use App\Models\ManageModule; +use App\Models\IamPrincipal; +use App\Models\ManageModuleLink; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; +use Exception; +use Illuminate\Support\Facades\Mail; +use App\Mail\Add_Subadmin; class ManageSubAdminController extends Controller { public function index(){ - return view('Admin.pages.manage_users.manage_sub_admin.manage_subadmin'); + $sub_admins_module = ManageModule::latest()->get(); + $sub_admins_data = IamPrincipal::where('principal_type_xid', 2)->latest()->get(); + + return view('Admin.pages.manage_users.manage_sub_admin.manage_subadmin',compact('sub_admins_data','sub_admins_module')); } + + public function create() + { + $sub_admins_module = ManageModule::latest()->get(); + + return view('admin.pages.manage_users.manage_sub_admin.create', compact('sub_admins_module')); + } + + public function store_subadmin(Request $request) + { + + + /* + Created By : Megha + Created at : 12 Feb 2024 + Use : To store sub admin form. + */ + try { + + // DB::beginTransaction(); + + + $sub_admin = new IamPrincipal(); + $sub_admin->first_name = $request->input('sub_admin_name'); + $sub_admin->user_name = 'sub_admin'; + $sub_admin->principal_type_xid = 2; + $sub_admin->principal_source_xid = Auth::guard('admin')->user()->principal_source_xid; + $sub_admin->email_address = $request->input('sub_admin_email'); + $sub_admin->password = bcrypt($request->input('password')); + $sub_admin->save(); + + + $moduleIds = $request->input('module_id'); + + foreach ($moduleIds as $moduleId) { + + $sub_admin_permission = new ManageModuleLink; + $sub_admin_permission->principal_xid = $sub_admin->id; + $sub_admin_permission->manage_modules_xid = $moduleId; + $sub_admin_permission->save(); + + } + + $mailData =[ + 'username'=>$request->input('sub_admin_name'), + 'password'=>$request->input('password'), + ]; + + + + // Mail::to($sub_admin->email_address)->send(new Add_Subadmin($mailData)); + $mail = Mail::to($request->input('sub_admin_email'))->send(new Add_Subadmin($mailData)); + // dd($mail); + + // DB::commit(); + return jsonResponseWithSuccessMessage(__('success.save_data')); + // return response()->json(['status'=>200]); + // return $voucher_data; + } catch (Exception $e) { + DB::rollBack(); + Log::error("restaurant Store Page Load Failed " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } + } + public function edit($id) + { + // dd($id); + $sub_admins_module = ManageModule::latest()->get(); + $edit_sub_admin = IamPrincipal::with(['moduleLinks' => function ($query) { + $query->with('module'); + }])->find($id); + return view('admin.pages.manage_users.manage_sub_admin.edit', compact('edit_sub_admin', 'sub_admins_module')); + } + + public function delete_sub_admin($id) + { + /* + Created By : Megha + Created at : 14 Feb 2024 + Use : To Delete Admin. + */ + try { + DB::beginTransaction(); + + $passport = IamPrincipal::find($id); + $passport->delete(); + + DB::commit(); + + return response()->json(['success' => true, 'status' => 200]); + } catch (Exception $e) { + DB::rollBack(); + Log::error("delete_passport function Load Failed " . $e->getMessage()); + return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]); + } + } + + public function update_subadmin(Request $request) + { + /* + Created By : Megha + Created at : 14 Feb 2024 + Use : To update sub admin form. + */ + try { + DB::beginTransaction(); + + $sub_admin = IamPrincipal::find($request->sub_admin_id); + $sub_admin->user_name = 'sub_admin'; + $sub_admin->first_name = $request->input('sub_admin_name'); + $sub_admin->principal_type_xid = 2; + $sub_admin->principal_source_xid = Auth::guard('admin')->user()->principal_source_xid; + $sub_admin->email_address = $request->input('sub_admin_email'); + // $sub_admin->password = bcrypt($request->input('password')); + $sub_admin->save(); + + $moduleIds = $request->input('module_id'); + // dd($moduleIds); + $update_module = ManageModuleLink::where('principal_xid', $sub_admin->id)->delete(); + + foreach ($moduleIds as $moduleId) { + $sub_admin_permission = new ManageModuleLink; + $sub_admin_permission->principal_xid = $sub_admin->id; + $sub_admin_permission->manage_modules_xid = $moduleId; + $sub_admin_permission->save(); + } + + + DB::commit(); + return jsonResponseWithSuccessMessage(__('success.save_data')); + // return $voucher_data; + } catch (Exception $e) { + DB::rollBack(); + Log::error("restaurant Store Page Load Failed " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } + } + + + + } diff --git a/app/Mail/Add_Subadmin.php b/app/Mail/Add_Subadmin.php new file mode 100644 index 0000000..7de4d5e --- /dev/null +++ b/app/Mail/Add_Subadmin.php @@ -0,0 +1,61 @@ +mailData = $mailData; + } + + /** + * Get the message envelope. + */ + // public function envelope(): Envelope + // { + // return new Envelope( + // subject: 'You add in subadmin ', + // ); + // } + + // /** + // * Get the message content definition. + // */ + // public function content(): Content + // { + // return new Content( + // view: 'mail.subadmin', + // ); + // } + + // /** + // * Get the attachments for the message. + // * + // * @return array + // */ + // public function attachments(): array + // { + // return []; + // } + + public function build() + { + // $otp = $this->otp; + return $this->subject('OTP From Cheers to the Session')->view('mail.subadmin'); + } +} diff --git a/app/Models/IamPrincipal.php b/app/Models/IamPrincipal.php index a65e7f0..55052b6 100644 --- a/app/Models/IamPrincipal.php +++ b/app/Models/IamPrincipal.php @@ -8,11 +8,9 @@ use Illuminate\Notifications\Notifiable; use Tymon\JWTAuth\Contracts\JWTSubject; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; -use App\Models\ManageFeedback; -use App\Models\ManageModuleLink; -use App\Models\ManageModule; -use App\Models\ManageState; - +use App\Models\admin\ManageFeedback; +use App\Models\admin\ManageModuleLink; +use App\Models\admin\ManageModule; use App\Models\OrderedPassport; @@ -42,10 +40,6 @@ class IamPrincipal extends Authenticatable implements JWTSubject 'notification_status', 'deleted_by_admin' ]; - public function state() - { - return $this->belongsTo(ManageState::class, 'state_xid', 'id'); - } public function moduleLinks() { diff --git a/app/Models/ManageFeedback.php b/app/Models/ManageFeedback.php new file mode 100644 index 0000000..867825b --- /dev/null +++ b/app/Models/ManageFeedback.php @@ -0,0 +1,34 @@ +belongsTo(IamPrincipal::class, 'principal_xid', 'id')->withDefault([ + 'id' => null, // Default id value + // Add more default attributes as needed + ]); + } + + + public function feedbackReaction() + { + return $this->belongsTo(FeedbackReaction::class, 'feedback_reaction_xid', 'feedback_reaction_xid'); + } + + + +} diff --git a/app/Models/ManageModule.php b/app/Models/ManageModule.php index 555f2a3..3220f70 100644 --- a/app/Models/ManageModule.php +++ b/app/Models/ManageModule.php @@ -6,16 +6,12 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; - class ManageModule extends Model { use HasFactory; use SoftDeletes; - protected $table='manage_modules'; + protected $table ='manage_module'; + protected $dates = ['deleted_at']; - public function moduleLinks() - { - return $this->hasMany(ManageModuleLink::class); - } } diff --git a/app/Models/ManageModuleLink.php b/app/Models/ManageModuleLink.php index eb0937f..b850665 100644 --- a/app/Models/ManageModuleLink.php +++ b/app/Models/ManageModuleLink.php @@ -8,8 +8,12 @@ use Illuminate\Database\Eloquent\Model; class ManageModuleLink extends Model { use HasFactory; - protected $table='manage_module_links'; + protected $table ='manage_module_link'; + protected $fillable =[ + 'principal_xid', + 'manage_modules_xid' + ]; public function iamprinciple() { return $this->belongsTo(IamPrincipal::class); diff --git a/composer.lock b/composer.lock index 3f1c6e5..2df44d0 100644 --- a/composer.lock +++ b/composer.lock @@ -4617,38 +4617,27 @@ "time": "2024-04-27T21:32:50+00:00" }, { - "name": "sabberworm/php-css-parser", - "version": "v8.5.1", + "name": "stella-maris/clock", + "version": "0.1.7", "source": { "type": "git", - "url": "https://github.com/MyIntervals/PHP-CSS-Parser.git", - "reference": "4a3d572b0f8b28bb6fd016ae8bbfc445facef152" + "url": "https://github.com/stella-maris-solutions/clock.git", + "reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/4a3d572b0f8b28bb6fd016ae8bbfc445facef152", - "reference": "4a3d572b0f8b28bb6fd016ae8bbfc445facef152", + "url": "https://api.github.com/repos/stella-maris-solutions/clock/zipball/fa23ce16019289a18bb3446fdecd45befcdd94f8", + "reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8", "shasum": "" }, "require": { - "ext-iconv": "*", - "php": ">=5.6.20" - }, - "require-dev": { - "phpunit/phpunit": "^5.7.27" - }, - "suggest": { - "ext-mbstring": "for parsing UTF-8 CSS" + "php": "^7.0|^8.0", + "psr/clock": "^1.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-main": "9.0.x-dev" - } - }, "autoload": { "psr-4": { - "Sabberworm\\CSS\\": "src/" + "StellaMaris\\Clock\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -4657,29 +4646,22 @@ ], "authors": [ { - "name": "Raphael Schweikert" - }, - { - "name": "Oliver Klee", - "email": "github@oliverklee.de" - }, - { - "name": "Jake Hotson", - "email": "jake.github@qzdesign.co.uk" + "name": "Andreas Heigl", + "role": "Maintainer" } ], - "description": "Parser for CSS Files written in PHP", - "homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser", + "description": "A pre-release of the proposed PSR-20 Clock-Interface", + "homepage": "https://gitlab.com/stella-maris/clock", "keywords": [ - "css", - "parser", - "stylesheet" + "clock", + "datetime", + "point in time", + "psr20" ], "support": { - "issues": "https://github.com/MyIntervals/PHP-CSS-Parser/issues", - "source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v8.5.1" + "source": "https://github.com/stella-maris-solutions/clock/tree/0.1.7" }, - "time": "2024-02-15T16:41:13+00:00" + "time": "2022-11-25T16:15:06+00:00" }, { "name": "symfony/clock", diff --git a/database/migrations/2024_05_28_075849_create_manage_module_table.php b/database/migrations/2024_05_28_075849_create_manage_module_table.php new file mode 100644 index 0000000..b3e2775 --- /dev/null +++ b/database/migrations/2024_05_28_075849_create_manage_module_table.php @@ -0,0 +1,33 @@ +id(); + $table->string('name'); + $table->string('slug'); + $table->integer('created_by')->nullable(); + $table->integer('modified_by')->nullable(); + $table->softDeletes(); + $table->timestamps(); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('manage_module'); + } +}; diff --git a/database/migrations/2024_05_28_101851_create_manage_module_link_table.php b/database/migrations/2024_05_28_101851_create_manage_module_link_table.php new file mode 100644 index 0000000..10a94fc --- /dev/null +++ b/database/migrations/2024_05_28_101851_create_manage_module_link_table.php @@ -0,0 +1,32 @@ +id(); + $table->unsignedBigInteger('principal_xid'); + $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade'); + $table->unsignedBigInteger('manage_modules_xid'); + $table->foreign('manage_modules_xid')->references('id')->on('manage_module')->onDelete('cascade'); + $table->timestamps(); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('manage_module_link'); + } +}; diff --git a/public/assets/js/admin/manage_sub_admin/add.js b/public/assets/js/admin/manage_sub_admin/add.js index f9fef86..32bffaf 100644 --- a/public/assets/js/admin/manage_sub_admin/add.js +++ b/public/assets/js/admin/manage_sub_admin/add.js @@ -20,6 +20,9 @@ $(document).on("click", "#add_sub_admin_form_btn", function (e) { password: { required: true } + ,"module_id[]":{ + required: true + } }, messages: { sub_admin_name: { @@ -32,6 +35,9 @@ $(document).on("click", "#add_sub_admin_form_btn", function (e) { }, password: { required: 'Please enter this filed' + }, + "module_id[]":{ + required: 'Please enter this filed' } }, errorClass: 'error-message', @@ -58,12 +64,12 @@ $(document).on("click", "#add_sub_admin_form_btn", function (e) { if (result.status_code == 200) { toastr.success('Data Added Sucessfully'); setTimeout(function () { - window.location.href = base_url + "/manage_sub_admin"; + window.location.href = base_url + "/manage-sub-admin"; }, 2000); } else { toastr.error('Something Went Wrong'); setTimeout(function () { - window.location.href = base_url + "/manage_sub_admin"; + window.location.href = base_url + "/manage-sub-admin"; }, 2000); } $('#add_sub_admin_form_btn').attr('disabled', false); diff --git a/public/assets/js/admin/manage_sub_admin/edit.js b/public/assets/js/admin/manage_sub_admin/edit.js index b1b176a..7d33c6d 100644 --- a/public/assets/js/admin/manage_sub_admin/edit.js +++ b/public/assets/js/admin/manage_sub_admin/edit.js @@ -43,22 +43,22 @@ $('#update_admin_btn').on("click", function (e) { if (result.status_code == 200) { toastr.success('Data Updated Sucessfully'); setTimeout(function() { - window.location.href = base_url + "/manage_sub_admin"; + window.location.href = base_url + "/manage-sub-admin"; }, 2000); } else { toastr.error('Something Went Wrong'); setTimeout(function() { - window.location.href = base_url + "/manage_sub_admin"; + window.location.href = base_url + "/manage-sub-admin"; }, 2000); } $('#update_admin_btn').attr('disabled', false); $('#update_admin_btn').text('Submit'); }, - + }); // $('#update_admin_btn').attr('disabled', false); // $('#update_admin_btn').text('Submit'); } }); -}); \ No newline at end of file +}); diff --git a/public/assets/js/admin/manage_sub_admin/main.js b/public/assets/js/admin/manage_sub_admin/main.js index 27638db..bc058ab 100644 --- a/public/assets/js/admin/manage_sub_admin/main.js +++ b/public/assets/js/admin/manage_sub_admin/main.js @@ -48,7 +48,7 @@ $(document).on("click", ".admin_delete", function (e) { if (response.status == 200) { toastr.success('Deleted Successfully'); setTimeout(function () { - window.location.href = base_url + "/manage_sub_admin"; + window.location.href = base_url + "/manage-sub-admin"; }, 1000); } else { toastr.error("Something went wrong"); @@ -80,4 +80,4 @@ $(".sub_admin_table").on("change", ".active_admin", function () { } }, }); -}); \ No newline at end of file +}); diff --git a/resources/views/Admin/pages/manage_cms/manage_privacy/manage_privacy.blade.php b/resources/views/Admin/pages/manage_cms/manage_privacy/manage_privacy.blade.php index 8d97a15..6b3f519 100644 --- a/resources/views/Admin/pages/manage_cms/manage_privacy/manage_privacy.blade.php +++ b/resources/views/Admin/pages/manage_cms/manage_privacy/manage_privacy.blade.php @@ -81,21 +81,12 @@ $currentPage = 'manage-privacy'; -->
-
-
-
-
-
-
Privacy Policy Customer
- - @if(!empty($view_privacy_policy)) - - Edit Details - -@else - -@endif +
+ diff --git a/resources/views/Admin/pages/manage_users/manage_sub_admin/create.blade.php b/resources/views/Admin/pages/manage_users/manage_sub_admin/create.blade.php new file mode 100644 index 0000000..2ab11ac --- /dev/null +++ b/resources/views/Admin/pages/manage_users/manage_sub_admin/create.blade.php @@ -0,0 +1,100 @@ +@extends('admin.layouts.master') + +@section('content') + + + +
+
+
+ +
+
+
+
+
+
+
+ + + + +
+
+
+
+ + + + +
+
+ +
+
+ + +
+
+ @foreach ($sub_admins_module as $sub_admins_modules) +
+ + +
+ @endforeach + +
+
+
+
+ + +
+
+
+ +
+
+
+
+
+
+
+
+
+@endsection + + +@section('section_script') + +@endsection diff --git a/resources/views/Admin/pages/manage_users/manage_sub_admin/edit.blade.php b/resources/views/Admin/pages/manage_users/manage_sub_admin/edit.blade.php new file mode 100644 index 0000000..8ed88f6 --- /dev/null +++ b/resources/views/Admin/pages/manage_users/manage_sub_admin/edit.blade.php @@ -0,0 +1,82 @@ +@extends('admin.layouts.master') + +@section('content') + + +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ @foreach ($sub_admins_module as $sub_admin_module) +
+ moduleLinks->contains('manage_modules_xid', $sub_admin_module->id)) checked @endif> + +
+ @endforeach +
+
+
+ +
+
+
+
+
+
+ +
+
+
+ +@endsection + + +@section('section_script') + + + +@endsection diff --git a/resources/views/Admin/pages/manage_users/manage_sub_admin/manage_subadmin.blade.php b/resources/views/Admin/pages/manage_users/manage_sub_admin/manage_subadmin.blade.php index b54c954..03ad052 100644 --- a/resources/views/Admin/pages/manage_users/manage_sub_admin/manage_subadmin.blade.php +++ b/resources/views/Admin/pages/manage_users/manage_sub_admin/manage_subadmin.blade.php @@ -39,6 +39,7 @@ + @foreach ( $sub_admins_data as $sub_admins)
@@ -46,11 +47,11 @@
1 - Akanksha - akanksha@gmail.com - 08/22/2023 + {{ $sub_admins->first_name }} + {{ $sub_admins->email_address }} + {{ \Carbon\Carbon::parse($sub_admins->created_at)->format('d/m/y') }} - View + View
@@ -62,19 +63,19 @@
  • - - + is_active ? 'checked' : '' }} class="active_admin" type="checkbox" id="switch{{ $sub_admins->id }}" switch="bool" checked /> +
  • - - + + Edit
  • - - + + Delete
  • @@ -82,49 +83,7 @@
- - -
- -
- - 1 - Akanksha - akanksha@gmail.com - 08/22/2023 - - View - - -
- - -
- - + @endforeach @@ -134,32 +93,85 @@
+ {{-- Premission-modal --}} + +{{-- Premission-modal End--}} + +{{-- Delete-modal --}} + +{{-- Delete-modal --}} @endsection + @section('section_script') + + + + @endsection diff --git a/resources/views/mail/subadmin.blade.php b/resources/views/mail/subadmin.blade.php new file mode 100644 index 0000000..7b1fd78 --- /dev/null +++ b/resources/views/mail/subadmin.blade.php @@ -0,0 +1,244 @@ + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + +
+
+ {{-- --}} +
+
+
+

+

+ {{--

Dear {{ $data['first_name'] }},

--}} +

Dear {{$mailData['username']}},

+ +

Congratulations! Your sub-admin account with Cheers to the session + has been successfully approved.

+ +

Your login credentials are as follows:

+
    +
  • User Name: {{$mailData['username']}}
  • + +
  • Password: {{$mailData['password']}}
  • +
+ +

You can now log in to your sub-admin dashboard to access your + account .

+ +

Please click on the link below to access your dashboard:

+

https://ctts.betadelivery.com +

+ +

If you have any questions or need further assistance, please + feel free to contact us.

+` +

Best regards,
Cheers to the session

+
+
+
+
+ + + + diff --git a/routes/web.php b/routes/web.php index 8d49a8b..320bffb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -56,6 +56,12 @@ Route::post('/export_selected_customer', [ManageCustomerController::class, 'expo Route::get('/manage-restaurants', [ManageRestrauntController ::class, 'index'])->name('manage.restaurants'); //*******************************************************manage subadmin******************************************************** Route::get('/manage-sub-admin', [ ManageSubAdminController ::class, 'index'])->name('manage.subAdmin'); +Route::get('/create_sub_admin', [ManageSubAdminController::class, 'create'])->name('manage.sub_admin_create'); +Route::post('/insert_sub_admin', [ManageSubAdminController::class, 'store_subadmin']); +Route::delete('/manage_sub_admin/{id}', [ManageSubAdminController::class, 'delete_sub_admin']); +Route::get('/edit_sub_admin/{id}', [ManageSubAdminController::class, 'edit'])->name('sub_admin_edit'); +Route::post('/update_sub_admin', [ManageSubAdminController::class, 'update_subadmin']); +Route::get('/change_admin_status', [ManageSubAdminController::class, 'change_admin_status']); //*******************************************************manage passport******************************************************** Route::get('/manage-passport', [ ManagePassportController ::class, 'index'])->name('manage.passport'); //*******************************************************manage voucher********************************************************