Merge pull request #317 from WDI-Ideas/sayli

Sayli
This commit is contained in:
Sayli Raut
2024-07-12 17:19:16 +05:30
committed by GitHub
10 changed files with 260 additions and 71 deletions

View File

@@ -12,6 +12,7 @@ use Exception;
use App\Helpers\onesignalhelper;
use App\Models\IamPrincipal;
use App\Models\ManageState;
use App\Models\RestaurantClosedHour;
use App\Models\RestaurantTimeInterval;
use Illuminate\Support\Facades\Log;
use Maatwebsite\Excel\Facades\Excel;
@@ -29,11 +30,11 @@ class ManageRestrauntController extends Controller
$activeQuery = $request->query('active');
if ($activeQuery == 1) {
$restaurant = ManageRestaurant::where('is_active', 1)->latest()->get();
$restaurant = ManageRestaurant::with('state')->where('is_active', 1)->latest()->get();
} else if ($activeQuery == 0 && $activeQuery != null) {
$restaurant = ManageRestaurant::where('is_active', 0)->latest()->get();
$restaurant = ManageRestaurant::with('state')->where('is_active', 0)->latest()->get();
} else {
$restaurant = ManageRestaurant::latest()->get();
$restaurant = ManageRestaurant::with('state')->latest()->get();
}
return view('Admin.pages.manage_restaurants.manage_restaurants', compact('restaurant'));
}
@@ -87,6 +88,7 @@ class ManageRestrauntController extends Controller
$restaurant->try_on_4 = $request->input('try_on_4');
$restaurant->save();
// Storing operating hours
foreach ($request->input('operating_hours') as $day => $hours) {
OperatingHour::create([
'manage_restaurant_xid' => $restaurant->id,
@@ -96,6 +98,7 @@ class ManageRestrauntController extends Controller
]);
}
// Storing restaurant time interval
$restTimeInterval = new RestaurantTimeInterval();
$restTimeInterval->manage_restaurants_xid = $restaurant->id;
$restTimeInterval->time_hours = $request->timeHours;
@@ -103,8 +106,18 @@ class ManageRestrauntController extends Controller
$restTimeInterval->quantity = $request->timeQuantity;
$restTimeInterval->save();
$imagePath = ListingImageUrl('restaurant_images', $restaurant->image);
// Storing closed restaurant date and time
if ($request->has('closed_date')) {
$ClosedTime = new RestaurantClosedHour();
$ClosedTime->restaurant_id = $restaurant->id;
$ClosedTime->day = $request->closed_date;
$ClosedTime->start_time = $request->closed_start_time;
$ClosedTime->end_time = $request->closed_end_time;
$ClosedTime->save();
}
// Sending notifications
$imagePath = ListingImageUrl('restaurant_images', $restaurant->image);
$allCustomerOneSignalIds = IamPrincipal::select('id', 'one_signal_player_id')->where('is_active', 1)->where('notification_status', 1)->where('principal_type_xid', 3)->get();
$title = "New " . $restaurant->name . " is added";
$message = "New Restaurant is Now Live.";
@@ -125,7 +138,6 @@ class ManageRestrauntController extends Controller
onesignalhelper::StoreNotificationDetails($customerIdItem->id, $content_type, $title, $imagePath);
}
DB::commit();
return jsonResponseWithSuccessMessage(__('success.save_data'));
} catch (Exception $e) {
@@ -136,6 +148,7 @@ class ManageRestrauntController extends Controller
}
/*
Created By : Sayli Raut
Created at : 29 May 2024
@@ -146,6 +159,7 @@ class ManageRestrauntController extends Controller
try {
$operating_hours = OperatingHour::where('manage_restaurant_xid', $id)->get()->keyBy('day_of_week');
$restaurantItem = ManageRestaurant::with('timeInterval')->where('id', $id)->first();
$restaurantClosedTime = RestaurantClosedHour::with('restaurant')->where('restaurant_id', $id)->first();
$timeInterval = $restaurantItem->timeInterval->first();
$state = ManageState::where('is_active', 1)->get()->toArray();
@@ -157,7 +171,8 @@ class ManageRestrauntController extends Controller
'operating_hours',
'state',
'timeInterval'
'timeInterval',
'restaurantClosedTime'
)
);
} catch (Exception $e) {
@@ -245,6 +260,26 @@ class ManageRestrauntController extends Controller
]);
}
// Handle closed restaurant data
$closedTime = RestaurantClosedHour::where('restaurant_id', $restaurant->id)->first();
if ($closedTime) {
// Update existing record
$closedTime->update([
'day' => $request->input('closed_date'),
'start_time' => $request->input('closed_start_time'),
'end_time' => $request->input('closed_end_time'),
]);
} else {
// Create new record
RestaurantClosedHour::create([
'restaurant_id' => $restaurant->id,
'day' => $request->input('closed_date'),
'start_time' => $request->input('closed_start_time'),
'end_time' => $request->input('closed_end_time'),
]);
}
DB::commit();
return jsonResponseWithSuccessMessage(__('success.update_data'));
@@ -258,6 +293,7 @@ class ManageRestrauntController extends Controller
/*
Created By : Sayli Raut
Created at : 29 May 2024

View File

@@ -60,5 +60,10 @@ class ManageRestaurant extends Model
return $this->hasMany(RestaurantTimeInterval::class, 'manage_restaurants_xid', 'id');
}
public function closedRestaurant()
{
return $this->hasMany(RestaurantClosedHour::class, 'restaurant_id', 'id');
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class RestaurantClosedHour extends Model
{
use HasFactory;
protected $table = 'restaurant_closed_hours';
protected $fillable = [
'restaurant_id', 'day', 'start_time', 'end_time'
];
public function restaurant()
{
return $this->belongsTo(ManageRestaurant::class);
}
}

View File

@@ -0,0 +1,33 @@
<?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('restaurant_closed_hours', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('restaurant_id');
$table->string('day');
$table->time('start_time')->nullable();
$table->time('end_time')->nullable();
$table->timestamps();
$table->foreign('restaurant_id')->references('id')->on('manage_restaurants')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('restaurant_closed_hours');
}
};

View File

@@ -64,6 +64,16 @@ $(document).on("click", "#update_restaurant_btn", function (e) {
required: true,
number: true,
min: 1
},
closed_start_time: {
required: function (element) {
return $('input[name="closed_date"]').val() !== '';
}
},
closed_end_time: {
required: function (element) {
return $('input[name="closed_date"]').val() !== '';
}
}
},
messages: {
@@ -122,11 +132,17 @@ $(document).on("click", "#update_restaurant_btn", function (e) {
required: "Please enter the maximum number of cocktails",
number: "Maximum number of cocktails must be a number",
min: "Maximum number of cocktails must be greater than 0"
},
closed_start_time: {
required: "Please select the start time for closing hours"
},
closed_end_time: {
required: "Please select the end time for closing hours"
}
},
errorClass: 'error-message',
submitHandler: function (form) {
e.preventDefault(); // Prevent default form submission
e.preventDefault();
var form = $('#update_restaurant_form')[0];
var formData = new FormData(form);
@@ -163,7 +179,6 @@ $(document).on("click", "#update_restaurant_btn", function (e) {
},
error: function (xhr, status, error) {
toastr.error('Something Went Wrong');
// Handle error
},
complete: function () {
$('#update_restaurant_btn').attr('disabled', false);
@@ -173,5 +188,3 @@ $(document).on("click", "#update_restaurant_btn", function (e) {
}
});
});

View File

@@ -24,37 +24,33 @@
<div class="top-tabel">
<div class="row">
<div class="col-md-4">
<!-- <h6 class="card-title">Edit Manage Customers</h6> -->
<a class="d-flex align-items-center justify-content-center pl-2"
href="{{ route('manage.restaurants') }}">
<img class="back-btn" src="{{ asset('public/assets/img/left-arrow.svg') }}">
<h6 class="card-title p-0">Add Details</h6>
</a>
</div>
<div class="col-md-8">
</div>
</div>
</div>
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
<div class="widget-content widget-content-area br-8 position-btn h-10">
<div class="view-details Article">
<form id="update_restaurant_form" enctype="multipart/form-data">
<div class="row">
<div class="col-md-6">
<div class="form-group ">
<div class="form-group">
<label for="company-name" class="label">Restaurant Name</label>
<input type="text" class="form-control" name="name" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<div class="form-group">
<label for="company-name" class="label">Restaurant ID</label>
<input type="text" class="form-control" name="rest_id" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<div class="form-group">
<label for="location" class="label">Address</label>
<input type="text" class="form-control" name="address" required>
</div>
@@ -63,52 +59,52 @@
<div class="form-group">
<label class="label">Image</label>
<div class="">
<input type="file" class="form-control input_class" accept="image/*"
placeholder="Upload an Image" name="image" id="selectImage" required>
<img id="preview" src="#" alt="your image" class="mt-3 "
<input type="file" class="form-control" accept="image/*" name="image"
id="selectImage" required>
<img id="preview" src="#" alt="your image" class="mt-3"
style="display:none;width:20%;" />
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<div class="form-group">
<label for="location" class="label">Exclusion</label>
<textarea type="text" class="form-control" name="exclusion"></textarea>
</div>
</div>
<div class="col-md-6">
<label for="location" class="label">Select state</label>
<select class="form-select" aria-label="Default select example" id="single"
name="state_xid">
<option value="">Select State</option>
@foreach ($state as $states)
<option value="{{ $states['id'] }}">{{ $states['name'] }}
</option>
@endforeach
</select>
<div class="form-group">
<label for="location" class="label">Select State</label>
<select class="form-select" aria-label="Default select example" id="single"
name="state_xid">
<option value="">Select State</option>
@foreach ($state as $states)
<option value="{{ $states['id'] }}">{{ $states['name'] }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<div class="form-group">
<label for="location" class="label">Latitude</label>
<input type="text" class="form-control" name="latitude" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<div class="form-group">
<label for="location" class="label">Longitude</label>
<input type="text" class="form-control" name="longitude" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<label for="phone_number" class="label">Phone number</label>
<div class="form-group">
<label for="phone_number" class="label">Phone Number</label>
<input type="text" class="form-control" name="phone_number" maxlength="15"
required>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<div class="form-group">
<label for="company-name" class="label">Bio</label>
<input type="text" class="form-control" name="bio" required>
</div>
@@ -117,7 +113,7 @@
<div class="form-group">
<label class="label">Operating Hours</label>
@foreach (['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] as $day)
<div class="row">
<div class="row mb-2">
<div class="col-md-3">
<label>{{ $day }} Start Time:</label>
<input type="time" class="form-control"
@@ -132,6 +128,32 @@
@endforeach
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="closed_date" class="label">Date for Close Restaurant</label>
<input type="date" class="form-control" name="closed_date"
id="closed_date">
</div>
</div>
<!-- Close Hours of Restaurant Start Time -->
<div class="col-md-6">
<div class="form-group">
<label for="start-time" class="label">Close Hours of Restaurant Start
Time</label>
<input type="time" class="form-control" name="closed_start_time">
</div>
</div>
<!-- Close Hours of Restaurant End Time -->
<div class="col-md-6">
<div class="form-group">
<label for="end-time" class="label">Close Hours of Restaurant End
Time</label>
<input type="time" class="form-control" name="closed_end_time">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="timeHours" class="label">Time in hours between redeeming two
@@ -142,36 +164,32 @@
<div class="input-group">
<select class="form-control" id="timeInterval" name="timeInterval"
required>
{{-- <option value="day">Day</option>
<option value="week">Week</option> --}}
<option value="month">Month</option>
</select>
<input type="number" class="form-control" id="timeQuantity"
name="timeQuantity" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<label for="company-name" class="label">While at Restaurant be sure to
try:</label>
<input type="text" class="form-control mb-3" name="try_on_1" required>
<input type="text" class="form-control mb-3" name="try_on_2" required>
<input type="text" class="form-control mb-3" name="try_on_3" required>
<input type="text" class="form-control mb-3" name="try_on_4" required>
</div>
</div>
<div class="col-md-12">
<button id="update_restaurant_btn" type="submit"
class="download-btn-custom mt-3 custom-width-10">Save</button>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="company-name" class="label">While at Restaurant be sure to
try:</label>
<input type="text" class="form-control mb-3" name="try_on_1" required>
<input type="text" class="form-control mb-3" name="try_on_2" required>
<input type="text" class="form-control mb-3" name="try_on_3" required>
<input type="text" class="form-control mb-3" name="try_on_4" required>
</div>
</div>
<div class="col-md-12">
<button id="update_restaurant_btn" type="submit"
class="download-btn-custom mt-3 custom-width-10">Save</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
@@ -201,4 +219,10 @@
theme: 'snow'
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
var today = new Date().toISOString().split('T')[0];
document.getElementsByName("closed_date")[0].setAttribute('min', today);
});
</script>
@endsection

View File

@@ -123,6 +123,7 @@
$timeQuantity = $timeInterval->quantity ?? '';
@endphp
<div class="col-md-6">
<div class="form-group">
<label for="timeHours" class="label">Time in hours between redeeming two
@@ -196,6 +197,30 @@
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="closed_date" class="label">Date for Close Restaurant</label>
<input type="date" class="form-control" name="closed_date"
id="closed_date" value="{{ $restaurantClosedTime->day ?? '' }}"
min="{{ date('Y-m-d') }}">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="closed_start_time" class="label">Close Start Time</label>
<input type="time" class="form-control" name="closed_start_time"
value="{{ $restaurantClosedTime->start_time ?? '' }}">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="closed_end_time" class="label">Close End Time</label>
<input type="time" class="form-control" name="closed_end_time"
value="{{ $restaurantClosedTime->end_time ?? '' }}">
</div>
</div>
<div class="col-md-12">
<button class="download-btn "style="width: 30%;" id="update_restaurant">
<span>Submit</span>
@@ -324,6 +349,16 @@
try_on_4: {
required: true,
},
closed_start_time: {
required: function(element) {
return $('input[name="closed_date"]').val() !== '';
}
},
closed_end_time: {
required: function(element) {
return $('input[name="closed_date"]').val() !== '';
}
}
},
messages: {
name: {
@@ -379,6 +414,12 @@
try_on_4: {
required: "Please enter this field",
},
closed_start_time: {
required: "Please select the start time for closing hours"
},
closed_end_time: {
required: "Please select the end time for closing hours"
}
},
errorClass: 'error-message',
submitHandler: function(form) {
@@ -425,4 +466,17 @@
});
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const closedDateInput = document.getElementById('closed_date');
closedDateInput.addEventListener('input', function() {
const today = new Date().toISOString().split('T')[0];
if (this.value < today) {
alert('Please select a future date.');
this.value = '';
}
});
});
</script>
@endsection

View File

@@ -42,6 +42,7 @@
<th class="text-center">Sr no</th>
<th class="text-center">Restaurant Name</th>
<th class="text-center">Restaurant ID</th>
<th class="text-center">State</th>
<th class="text-center">Status</th>
<th class="no-content">Action</th>
</tr>
@@ -60,6 +61,7 @@
<td class="text-center">{{ $count }}</td>
<td class="text-center">{{ $restaurants->name }}</td>
<td class="text-center">{{ $restaurants->restaurant_id }}</td>
<td class="text-center">{{ $restaurants->state->name }}</td>
<td class="text-center">
<form>
<div class="switch-btn" id="status-change">

View File

@@ -32,7 +32,7 @@
<th class="text-start">Restaurant Name</th>
<th class="text-start">Restaurant Image</th>
<th class="text-start">Redemption Date and Time</th>
<th class="text-start">Voucher Count</th>
{{-- <th class="text-start">Voucher Count</th> --}}
<th class="text-start">Voucher Status</th>
</tr>
@@ -56,7 +56,7 @@
<span>No date</span>
@endif
</td>
<td class="text-start">{{ $redeemDetail->count }}</td>
{{-- <td class="text-start">{{ $redeemDetail->count }}</td> --}}
<!-- <td class="text-center">
<div class="switch-btn" id="status-change">
<input type="checkbox" id="switch{{ $redeemDetail['id'] }}"
@@ -67,7 +67,7 @@
data-off-label="Inactive"></label>
</div>
</td> -->
<td class="text-center">
<div class="switch-btn">
<input type="checkbox" id="switch{{ $redeemDetail['id'] }}" switch="bool" data-id="{{ $redeemDetail['id'] }}"
@@ -75,7 +75,7 @@
<label for="switch{{ $redeemDetail['id'] }}" data-on-label="Active" data-off-label="Inactive"></label>
</div>
</td>
</tr>
@endforeach

View File

@@ -44,7 +44,10 @@ use App\Http\Controllers\Admin\ManageRulesController;
Route::get('/', [LoginController::class, 'index'])->name('login');
Route::get('/admin/login', [LoginController::class, 'index'])->name('login');
Route::get('/', function () {
return redirect('/admin/login');
});
Route::post('/check_login', [LoginController::class, 'login_check']);
Route::get('/forgot_password', [LoginController::class, 'forgot_password']);
Route::post('/send_otp', [LoginController::class, 'add_forgot_password']);
@@ -215,8 +218,6 @@ Route::group(['middleware' => ['checkStatus']], function () {
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']);
});
@@ -232,17 +233,17 @@ Route::group(['middleware' => ['customer.jwt.verify']], function () {
// Route::middleware(['checkToken'])->group(function () {
Route::get('list-of-plans', [SubscriptionController::class, 'listOfProduct'])->name('list-of-products');
Route::get('list-of-plans', [SubscriptionController::class, 'listOfProduct'])->name('list-of-products');
// });
Route::post('subscribe-to-plan', [SubscriptionController::class, 'subscriptionToPlan'])->name('subscribe-to-plan');
Route::get('thank-you', [SubscriptionController::class, 'thankyou'])->name('thankyou');
Route::post('cancel-subscription',[SubscriptionController::class,'cancelSubscription'])->name('cancel-subscription');
Route::get('cancel-subscription-thank-you',[SubscriptionController::class,'cancelSubscriptionThankYou'])->name('cancel-subscription-thank-you');
// });
Route::post('subscribe-to-plan', [SubscriptionController::class, 'subscriptionToPlan'])->name('subscribe-to-plan');
Route::get('thank-you', [SubscriptionController::class, 'thankyou'])->name('thankyou');
Route::post('cancel-subscription', [SubscriptionController::class, 'cancelSubscription'])->name('cancel-subscription');
Route::get('cancel-subscription-thank-you', [SubscriptionController::class, 'cancelSubscriptionThankYou'])->name('cancel-subscription-thank-you');
Route::post('apply-referral-code', [SubscriptionController::class, 'applyReferralCode'])->name('apply-referral-code');
Route::post('apply-referral-code', [SubscriptionController::class, 'applyReferralCode'])->name('apply-referral-code');
// Route::post('subscribe-to-product', [SubscriptionController::class, 'subscribeToProduct'])->name('subscribe-to-product');
// Route::post('cancel-subscription', [SubscriptionController::class, 'cancelSubscription'])->name('cancel-subscription');