12 Commits

Author SHA1 Message Date
sayliraut
64d91c6aa8 Merge branch 'main' of https://github.com/WDI-Ideas/cheerstothe_season_laravel11 into sayli 2024-06-19 17:26:54 +05:30
sayliraut
47ea603c10 search state API 2024-06-19 17:26:37 +05:30
sayliraut
52f7299d6a Merge branch 'main' of https://github.com/WDI-Ideas/cheerstothe_season_laravel11 into sayli 2024-06-19 16:21:13 +05:30
Sayli Raut
e4c12c5fa9 Merge pull request #175 from WDI-Ideas/sayli
Sayli
2024-06-19 16:21:02 +05:30
sayliraut
bd81d002b7 notification changes 2024-06-19 16:20:52 +05:30
sayliraut
7af971cada Merge branch 'main' of https://github.com/WDI-Ideas/cheerstothe_season_laravel11 into sayli 2024-06-19 13:35:50 +05:30
Sayli Raut
f0db020b63 Merge pull request #174 from WDI-Ideas/sayli
Sayli
2024-06-19 13:35:40 +05:30
sayliraut
efeef736f9 change 2024-06-19 13:35:33 +05:30
sayliraut
15fa3454ff Merge branch 'main' of https://github.com/WDI-Ideas/cheerstothe_season_laravel11 into sayli 2024-06-19 13:24:04 +05:30
Sayli Raut
4fbcde8b07 Merge pull request #173 from WDI-Ideas/sayli
Sayli
2024-06-19 13:23:58 +05:30
sayliraut
7264174ede manage_rules 2024-06-19 13:23:51 +05:30
CodewithSayali
fb046fc536 Merge pull request #172 from WDI-Ideas/sayaliP
Sayali p
2024-06-19 12:54:01 +05:30
15 changed files with 669 additions and 159 deletions

View File

@@ -269,4 +269,20 @@ class AuthController extends Controller
return response()->json(__('something_went_wrong'), 500);
}
}
/**
* Created By : Sayli Raut
* Created at : 19 June 2024
* Use : Search State.
*/
public function searchState(Request $request)
{
try {
return $this->AuthServices->searchState($request);
} catch (\Exception $ex) {
Log::error("Login API Failed: " . $ex->getMessage());
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
}
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers\Admin\APIs\Customer_API;
use App\Http\Controllers\Controller;
use App\Services\APIs\CustomerAPIs\RulesApiServices;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\Request;
class RulesControllerAPI extends Controller
{
protected $RulesApiServices;
public function __construct(RulesApiServices $RulesApiServices)
{
$this->RulesApiServices = $RulesApiServices;
}
/**
* Created By : sayli Raut
* Created at : 19 June 2024
* Use : To get voucher rules and regulation.
*/
public function getVoucherRules()
{
try {
$token = readHeaderToken();
if ($token) {
$customerIamId = $token['sub'];
$response = $this->RulesApiServices->getVoucherRules();
return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200);
} else {
return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409);
}
} catch (\Exception $e) {
Log::error('Voucher rules get data controller function failed: ' . $e->getMessage());
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
}
}
}

View File

@@ -81,90 +81,79 @@ class ManageNotificationsController extends Controller
* Use : To add notification .
*/
public function store_notificaton_data(Request $request)
{
// dd($request);
try {
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
]);
{
try {
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
]);
DB::beginTransaction();
DB::beginTransaction();
if (isset($request->image)) {
$image = $request->image;
$image_db = null;
} else {
$image = null;
$image_db = $request->image;
}
$tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db);
$imagePath = ListingImageUrl('notification_images', $tnormalImage);
$allCustomerOneSignalIds = IamPrincipal::where('is_active', 1)
->where('notification_status', 1)
->where('principal_type_xid', 3)
->where('state_xid', $request->state)
->pluck('id');
$allRestaurantOneSignalIds = IamPrincipal::where('is_active', 1)
->where('notification_status', 1)
->where('principal_type_xid', 3)
->where('state_xid', $request->state)
->pluck('id');
// Find the remaining user data
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
$title = $request->title;
$message = $request->description;
$content_type = 'Notification';
$imageUrl = $imagePath;
// FOR all customer
if ($request->user_type == 1) {
foreach ($UserData as $customerIdItem) {
if ($customerIdItem->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$customerIdItem->one_signal_player_id,
$title,
$message,
$content_type,
$imageUrl,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($customerIdItem->id, $content_type, $title, $imagePath);
}
} elseif ($request->user_type == 2) {
$restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get();
foreach ($restaurantData as $restIdItem) {
if ($restIdItem->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$restIdItem->one_signal_player_id,
$title,
$message,
$content_type,
$imageUrl,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($restIdItem->id, $content_type, $title, $imagePath);
}
}
DB::commit();
return jsonResponseWithSuccessMessage(__('success.save_data'));
} catch (Exception $e) {
DB::rollBack();
Log::error("Notification send Failed " . $e->getMessage());
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
if (isset($request->image)) {
$image = $request->image;
$image_db = null;
} else {
$image = null;
$image_db = $request->image;
}
$tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db);
$imagePath = ListingImageUrl('notification_images', $tnormalImage);
// Fetch OneSignal IDs based on the selected states and user type
$states = $request->states;
$userQuery = IamPrincipal::where('is_active', 1)
->where('notification_status', 1)
->where('principal_type_xid', 3)
->whereIn('state_xid', $states);
if ($request->user_type == 1) {
$allCustomerOneSignalIds = $userQuery->pluck('id');
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
foreach ($UserData as $customerIdItem) {
if ($customerIdItem->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$customerIdItem->one_signal_player_id,
$request->title,
$request->description,
'Dashboard Notification',
$imagePath,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath);
}
} elseif ($request->user_type == 2) {
$allRestaurantOneSignalIds = $userQuery->pluck('id');
$restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get();
foreach ($restaurantData as $restIdItem) {
if ($restIdItem->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$restIdItem->one_signal_player_id,
$request->title,
$request->description,
'Dashboard Notification',
$imagePath,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($restIdItem->id, 'Notification', $request->title, $imagePath);
}
}
DB::commit();
return jsonResponseWithSuccessMessage(__('success.save_data'));
} catch (Exception $e) {
DB::rollBack();
Log::error("Notification send Failed " . $e->getMessage());
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
}
}
/**

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\ManageRule;
use Illuminate\Http\Request;
class ManageRulesController extends Controller
{
/**
* Created By : sayli Raut
* Created at : 19 June 2024
* Use : To view Rules page.
*/
public function index()
{
$data = ManageRule::all()->toArray();
return view('Admin.pages.manage_rule.manage_rule', compact('data'));
}
/**
* Created By : sayli Raut
* Created at : 19 June 2024
* Use : To edit Rules.
*/
public function edit($id)
{
$data = ManageRule::find($id);
return view('Admin.pages.manage_rule.manage_rules_edit', compact('data'));
}
/**
* Created By : sayli Raut
* Created at : 19 June 2024
* Use : To update Rules.
*/
public function update(Request $request)
{
$validated = $request->validate([
'article_des' => 'required',
]);
$update = ManageRule::find($request->rule_id);
$update->message = $request->input('article_des');
$update->save();
return response()->json(['success' => true, 'status' => 200]);
}
}

18
app/Models/ManageRule.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ManageRule extends Model
{
use HasFactory;
protected $table = 'manage_rules';
protected $fillable = [
'message'
];
}

View File

@@ -310,4 +310,24 @@ class AuthServices
return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403);
}
}
public function searchState($request)
{
try {
$searchQuery = $request->input('search_data');
$query = ManageState::select('id', 'name')->where('is_active', 1);
if ($searchQuery) {
$query->where(function ($q) use ($searchQuery) {
$q->where('name', 'like', '%' . $searchQuery . '%');
});
}
$restaurants = $query->get();
return jsonResponseWithSuccessMessageApi(__('auth.data_fetched_successfully'), $restaurants, 200);
} catch (\Exception $e) {
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage());
return response()->json(__('something_went_wrong'), 500);
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Services\APIs\CustomerAPIs;
use App\Models\ManageRule;
use Illuminate\Support\Facades\Log;
use Exception;
class RulesApiServices
{
public function getVoucherRules()
{
try {
$data = ManageRule::select('id', 'message')
->get()
->toArray();
return $data;
} catch (Exception $ex) {
Log::error('Voucher rules and regulation Get service failed : ' . $ex->getMessage());
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
}
}
}

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('manage_rules', function (Blueprint $table) {
$table->id();
$table->longtext('message')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('manage_rules');
}
};

View File

@@ -352,6 +352,21 @@
</li>
@endif
@if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-rules'))
<li class="tooltip-element <?php
if ($currentPage == 'manage-rules') {
echo 'active';
}
?>" data-tooltip="6">
<a href="{{ route('manage_rules') }}" data-active="6">
<div class="icons">
<img src="{{ asset('public/assets/img/Group.svg') }}" />
<span class="text">Manage Rules</span>
</div>
</a>
</li>
@endif
@if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-notification'))
<li class="tooltip-element <?php
if ($currentPage == 'manage-notification') {

View File

@@ -8,36 +8,36 @@
<div class="layout-px-spacing">
<div class="middle-content container-xxl p-0">
<div class="row layout-top-spacing ">
<div class="top-tabel">
<div class="row">
<div class="col-md-4">
<h6 class="card-title">Manage Notification</h6>
</div>
<div class="col-md-8">
</div>
<div class="layout-px-spacing">
<div class="middle-content container-xxl p-0">
<div class="row layout-top-spacing ">
<div class="top-tabel">
<div class="row">
<div class="col-md-4">
<h6 class="card-title">Manage Notification</h6>
</div>
<div class="col-md-8">
</div>
</div>
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-8 position-btn">
<table id="zero-config" class="table dt-table-hover" style="width:100%">
<thead class="text-center">
<tr>
<th class="text-start">Sr No.</th>
<th class="text-start">Notification content</th>
<th class="text-start">Email</th>
<th class="text-start">Created Date</th>
<th class="text-start">Recipients</th>
<th class="text-start">Date sent</th>
<th class="no-content">Status</th>
</tr>
</thead>
<tbody class="text-center">
@foreach ($notifications as $notification)
</div>
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-8 position-btn">
<table id="zero-config" class="table dt-table-hover" style="width:100%">
<thead class="text-center">
<tr>
<th class="text-start">Sr No.</th>
<th class="text-start">Notification content</th>
<th class="text-start">Email</th>
<th class="text-start">Created Date</th>
<th class="text-start">Recipients</th>
<th class="text-start">Date sent</th>
<th class="no-content">Status</th>
</tr>
</thead>
<tbody class="text-center">
@foreach ($notifications as $notification)
<tr>
<td class="text-start">{{ $loop->iteration }}</td>
<td class="text-start">{{ $notification->type }}</td>
@@ -86,40 +86,101 @@
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@section('section_script')
<script src="../src/plugins/src/table/datatable/datatables.js"></script>
<script>
$('#zero-config').DataTable({
"dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
"<'table-responsive'tr>" +
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
"oLanguage": {
"oPaginate": { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
"sInfo": "Showing page _PAGE_ of _PAGES_",
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
"sSearchPlaceholder": "Search...",
"sLengthMenu": "Results : _MENU_",
},
"stripeClasses": [],
"lengthMenu": [7, 10, 20, 50],
"pageLength": 10
});
</script>
<script>
$(document).ready(function () {
$('<button><a class="extra-btn width-max-content" href="{{ route('manage_add_notifications') }}">Add</a></button><button><ul class="navbar-item flex-row ms-lg-auto ms-0"><li class="nav-item dropdown action-dropdown order-lg-0 order-1"><a href="javascript:void(0);"class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="avatar-container"><div class="avatar avatar-sm avatar-indicators avatar-online"><h3>Filter</h3></div></div></a><div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown"><div class="dropdown-item"><a href="#"><span>All</span></a></div><div class="dropdown-item"><a href="#"><span>Customer</span></a></div><div class="dropdown-item"><a href="#"> <span>Restaurant</span></a></div></div></li></ul></button>').insertBefore("#zero-config_filter label");
});
</script>
</div>
@endsection
@section('section_script')
<script src="../src/plugins/src/table/datatable/datatables.js"></script>
<script>
$('#zero-config').DataTable({
"dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
"<'table-responsive'tr>" +
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
"oLanguage": {
"oPaginate": {
"sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
},
"sInfo": "Showing page _PAGE_ of _PAGES_",
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
"sSearchPlaceholder": "Search...",
"sLengthMenu": "Results : _MENU_",
},
"stripeClasses": [],
"lengthMenu": [7, 10, 20, 50],
"pageLength": 10
});
</script>
<script>
$(document).ready(function() {
$('<button><a class="extra-btn width-max-content" href="{{ route('manage_add_notifications') }}">Add</a></button><button><ul class="navbar-item flex-row ms-lg-auto ms-0"><li class="nav-item dropdown action-dropdown order-lg-0 order-1"><a href="javascript:void(0);"class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="avatar-container"><div class="avatar avatar-sm avatar-indicators avatar-online"><h3>Filter</h3></div></div></a><div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown"><div class="dropdown-item"><a href="{{ route('manage.notification') }}" id="allFilter"><span>All</span></a></div><div class="dropdown-item"><a href="{{ route('manage.notification', ['active' => 4]) }}" id="activeFilter"><span>Customer</span></a></div><div class="dropdown-item"><a href="{{ route('manage.notification', ['active' => 3]) }}" id="expiredFilter"> <span>Restaurant</span></a></div></div></li></ul></button>')
.insertBefore("#zero-config_filter label");
// Retrieve the selected filter from local storage
var selectedFilter = localStorage.getItem('selectedFilter');
// If a selected filter exists, set its color
if (selectedFilter) {
handleChange(selectedFilter);
} else {
// If no selected filter is found, simulate a click event on the default filter button
$('#allFilter').trigger('click');
}
// Add event listeners to filter links
$('#activeFilter').on('click', function() {
// Prevent the default anchor behavior
handleChange('active');
// Store selected filter in local storage
localStorage.setItem('selectedFilter', 'active');
});
$('#expiredFilter').on('click', function() {
// Prevent the default anchor behavior
handleChange('expired');
// Store selected filter in local storage
localStorage.setItem('selectedFilter', 'expired');
});
$('#allFilter').on('click', function() {
// Prevent the default anchor behavior
handleChange('all');
// Store selected filter in local storage
localStorage.setItem('selectedFilter', 'all');
});
});
// Define handleChange function
function handleChange(filterType) {
// Reset background color of all filters
$('#activeFilter, #expiredFilter, #allFilter').css('background-color', '');
// Set background color based on filter type
if (filterType === 'active') {
$('#activeFilter').css({
'padding': '4px 8px',
'background-color': 'rgb(233, 233, 234)',
'color': 'rgb(191, 191, 196)'
}); // Set color for active filter
} else if (filterType === 'expired') {
$('#expiredFilter').css({
'padding': '4px 8px',
'background-color': 'rgb(233, 233, 234)',
'color': 'rgb(191, 191, 196)'
}); // Set color for expired filter
} else if (filterType === 'all') {
$('#allFilter').css({
'padding': '4px 8px',
'background-color': 'rgb(233, 233, 234)',
'color': 'rgb(191, 191, 196)'
});
}
}
</script>
@endsection

View File

@@ -69,33 +69,39 @@
value="1" id="select-all-ids" />
<label class="form-check-label" for="select-all-ids">Send to unsubscribed
users who are in their respective states</label><br>
<div id="dropdown-1" style="display: none;">
<select class="form-select" aria-label="Default select example"
id="single" name="state">
<option value="">Select State</option>
@foreach ($state as $states)
<option value="{{ $states['id'] }}">{{ $states['name'] }}
</option>
@endforeach
</select>
<div id="dropdown-1"
style="display: none; max-height: 200px; overflow-y: auto;">
@foreach ($state as $states)
<div class="form-check">
<input class="form-check-input" type="checkbox" name="states[]"
value="{{ $states['id'] }}"
id="state-{{ $states['id'] }}" />
<label class="form-check-label"
for="state-{{ $states['id'] }}">{{ $states['name'] }}</label>
</div>
@endforeach
</div>
<input class="form-check-input" type="radio" name="user_type"
id="select-popular-ids" value="2" /><br>
<label class="form-check-label" for="select-popular-ids">Send to subscribed
users who are in their respective states</label><br>
<div id="dropdown-2" style="display: none;">
<select class="form-select" aria-label="Default select example"
id="single" name="state">
<option value="">Select State</option>
@foreach ($state as $states)
<option value="{{ $states['id'] }}">{{ $states['name'] }}
</option>
@endforeach
</select>
<div id="dropdown-2"
style="display: none; max-height: 200px; overflow-y: auto;">
@foreach ($state as $states)
<div class="form-check">
<input class="form-check-input" type="checkbox" name="states[]"
value="{{ $states['id'] }}"
id="state-{{ $states['id'] }}" />
<label class="form-check-label"
for="state-{{ $states['id'] }}">{{ $states['name'] }}</label>
</div>
@endforeach
</div>
</div>
</div>
</div>
<div class="col-md-12">
<button class="download-btn-custom mt-3 custom-width-10" type="submit"
id="store_notification_btn">

View File

@@ -0,0 +1,59 @@
@extends('Admin.layouts.master')
@section('content')
@php
$currentPage = 'manage-rules';
@endphp
<div class="layout-px-spacing">
<div class="middle-content container-xxl p-0">
<div class="row layout-top-spacing ">
<div class="top-tabel">
<div class="row">
<div class="col-md-12 left d-flex align-items-center justify-content-between"
style="gap: 15px;">
<h6 class="card-title pl-2"> Manage Rules </h6>
<a class="view-details-btn mr-2"
href="{{ route('rules_edit', ['id' => $data[0]['id']]) }}"
data-id="{{ $data[0]['id'] }}">
<span>Edit</span>
</a>
</div>
</div>
</div>
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-8 position-btn p-0">
@csrf
<div class="view-details">
<div class="simple-tab">
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel"
aria-labelledby="home-tab" tabindex="0">
<div class="row">
<div class="col-md-12">
<p>
{!! $data[0]['message'] !!}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('section_script')
@endsection

View File

@@ -0,0 +1,170 @@
@extends('Admin.layouts.master')
@section('content')
@php
$currentPage = 'manage-rules';
@endphp
<style>
.error-message {
color: #FF0000;
}
form .error-message {
color: red;
/* Set your desired color here */
}
form .input_class.error-message {
color: #0e1726;
}
</style>
<div class="layout-px-spacing">
<div class="middle-content container-xxl p-0">
<div class="row layout-top-spacing ">
<div class="top-tabel">
<div class="row">
<div class="col-md-12 left d-flex align-items-center justify-content-between" style="gap: 15px;">
<a class="d-flex align-items-center justify-content-center pl-2" href="{{ route('manage_rules') }}">
<img class="back-btn" src="{{ asset('public/assets/img/left-arrow.svg') }}">
<h6 class="card-title p-0">Edit Details</h6>
</a>
</div>
</div>
</div>
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-8 position-btn p-0">
<div class="view-details">
<div class="simple-tab">
@csrf
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel" aria-labelledby="home-tab" tabindex="0">
<div class="row">
<form id="rules_form">
<div class="col-md-12">
<input type="hidden" name="rule_id" value="{{ $data->id }}">
<input type="hidden" id="stored-terms-message" value="{{ $data->message }}">
<div id="rules-quill-edit" name="article_des" class="editor-quill" style="height: 300px;" minlength="10"></div>
<span class="error-message" id="error-message"></span>
</div>
<div class="col-md-12">
<button type="submit" id="update_rules" class="download-btn-custom mt-3 custom-width-10">
<span>Update</span>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('section_script')
<!-- <script>
var quill = new Quill('#terms-quill-edit', {
theme: 'snow'
});
</script> -->
{{-- <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/jquery.validate.min.js"></script>
<script src="{{ asset('public/assets/js/admin/manage_cms/manage_terms_cond/manage_terms_condition.js')}}"></script> --}}
<script>
$(document).ready(function() {
var quill = new Quill('#rules-quill-edit', {
theme: 'snow'
});
var storedMessage = document.getElementById('stored-terms-message').value;
quill.clipboard.dangerouslyPasteHTML(storedMessage);
$('#update_rules').on("click", function(e) {
e.preventDefault();
$('#rules_form').validate({
ignore: [],
debug: false,
rules: {
article_des: {
required: true,
minlength:1000,
}
},
messages: {
article_des: {
required: "Please Enter Rules",
minlength:"Please Enter Rules"
}
},
errorClass: 'error-message',
submitHandler: function(form) {
// Get the HTML content from Quill editor
var article_des = quill.root.innerHTML;
if (article_des.trim() === '<p><br></p>') {
toastr.error("Please Enter Rules");
return false;
}
let base_url = url_path;
var rule_id = document.querySelector('input[name="rule_id"]').value;
// Create a form data object
var formData = new FormData(form);
formData.append('article_des', article_des);
$.ajaxSetup({
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
});
$.ajax({
url: base_url + '/update_rules',
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(response) {
if (response.status == 200) {
toastr.success('Rules Data Updated Successfully');
setTimeout(function() {
window.location.href = base_url + "/manage_rules";
}, 1000);
} else {
toastr.error("Something went wrong");
}
},
error: function(response) {
toastr.error("An error occurred while updating the rules");
}
});
}
});
// Trigger form validation
$('#rules_form').submit();
});
});
</script>
@endsection

View File

@@ -7,6 +7,7 @@ use App\Http\Controllers\Admin\APIs\Customer_API\CustomerControllerApi;
use App\Http\Controllers\Admin\APIs\Customer_API\FeedbackApiController;
use App\Http\Controllers\Admin\APIs\Customer_API\NotificationController;
use App\Http\Controllers\Admin\APIs\Customer_API\RestaurantControllerApi;
use App\Http\Controllers\Admin\APIs\Customer_API\RulesControllerAPI;
use App\Http\Controllers\Admin\ReferralCodeController;
use Illuminate\Support\Facades\Route;
@@ -23,6 +24,8 @@ Route::middleware(['customerApiBasicAuth'])->group(function () {
Route::post('/v1/password/verify-otp', [AuthController::class, 'verifyOtpForgotPassword']);
Route::post('/v1/change-password', [AuthController::class, 'changePassword']);
Route::post('/v1/resend-otp', [AuthController::class, 'resendOtp']);
Route::post('/v1/search-state', [AuthController::class, 'searchState']);
Route::group(['middleware' => ['customer.jwt.verify']], function () {
@@ -72,5 +75,7 @@ Route::middleware(['customerApiBasicAuth'])->group(function () {
//*******************************************************Check referral code********************************************************
Route::post('/v1/check-referral', [ReferralCodeController::class, 'CheckReferral']);
//*******************************************************Rules ********************************************************
Route::get('/v1/voucher-rules', [RulesControllerAPI::class, 'getVoucherRules']);
});
});

View File

@@ -22,7 +22,7 @@ use App\Http\Controllers\Admin\LoginController;
use App\Http\Controllers\Admin\ManageCmsController;
use App\Http\Controllers\Admin\RestaurantAppController;
use App\Http\Controllers\Admin\ManageLocationController;
use App\Http\Controllers\Admin\ManageRulesController;
Route::get('/', [LoginController::class, 'index'])->name('login');
Route::post('/check_login', [LoginController::class, 'login_check']);
@@ -184,4 +184,11 @@ Route::group(['middleware' => ['checkStatus']], function () {
Route::get('/change_location_status', [ManageLocationController::class, 'change_location_status']);
Route::delete('/delete_location/{id}', [ManageLocationController::class, 'delete_location']);
Route::post('/update_location', [ManageLocationController::class, 'update']);
//*******************************************************Rules and regulation********************************************************
Route::get('/manage_rules', [ManageRulesController::class, 'index'])->name('manage_rules');
Route::get('/rules_edit/{id}', [ManageRulesController::class, 'edit'])->name('rules_edit');
Route::post('/update_rules', [ManageRulesController::class, 'update']);
});