@@ -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('FAW get data controller function failed: ' . $e->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
50
app/Http/Controllers/Admin/ManageRulesController.php
Normal file
50
app/Http/Controllers/Admin/ManageRulesController.php
Normal 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
18
app/Models/ManageRule.php
Normal 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'
|
||||
];
|
||||
|
||||
}
|
||||
25
app/Services/APIs/CustomerAPIs/RulesApiServices.php
Normal file
25
app/Services/APIs/CustomerAPIs/RulesApiServices.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -352,6 +352,21 @@
|
||||
</li>
|
||||
@endif
|
||||
|
||||
{{-- @if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-notification')) --}}
|
||||
<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') {
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
@@ -72,5 +73,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']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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']);
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user