restaurant time interval
This commit is contained in:
@@ -44,7 +44,7 @@ class ReinstateRestaurant extends Command
|
||||
if ($managerestaurant && $managerestaurant->is_active == 1) {
|
||||
$redeemDate = Carbon::parse($record->redeem_date);
|
||||
|
||||
$fourHourPlusTimeOfRecord = $redeemDate->copy()->addHours($managerestaurant->time_hours);
|
||||
$fourHourPlusTimeOfRecord = $redeemDate->copy()->addHours(4);
|
||||
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use Exception;
|
||||
use App\Helpers\onesignalhelper;
|
||||
use App\Models\IamPrincipal;
|
||||
use App\Models\ManageState;
|
||||
use App\Models\RestaurantTimeInterval;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -45,7 +46,7 @@ class ManageRestrauntController extends Controller
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$state = ManageState::where('is_active', 1)->get()->toArray();
|
||||
$state = ManageState::with('timeInterval')->where('is_active', 1)->get()->toArray();
|
||||
return view('Admin.pages.manage_restaurants.add_restaurant', compact('state'));
|
||||
}
|
||||
|
||||
@@ -84,10 +85,6 @@ class ManageRestrauntController extends Controller
|
||||
$restaurant->try_on_2 = $request->input('try_on_2');
|
||||
$restaurant->try_on_3 = $request->input('try_on_3');
|
||||
$restaurant->try_on_4 = $request->input('try_on_4');
|
||||
$restaurant->time_hours = $request->input('timeHours');
|
||||
$restaurant->max_numb_day = $request->input('maxNumbDay');
|
||||
$restaurant->max_numb_week = $request->input('maxNumbWeek');
|
||||
$restaurant->max_numb_month = $request->input('maxNumbMonth');
|
||||
$restaurant->save();
|
||||
|
||||
foreach ($request->input('operating_hours') as $day => $hours) {
|
||||
@@ -99,6 +96,13 @@ class ManageRestrauntController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
$restTimeInterval = new RestaurantTimeInterval();
|
||||
$restTimeInterval->manage_restaurants_xid = $restaurant->id;
|
||||
$restTimeInterval->time_hours = $request->timeHours;
|
||||
$restTimeInterval->time_interval = $request->timeInterval;
|
||||
$restTimeInterval->quantity = $request->timeQuantity;
|
||||
$restTimeInterval->save();
|
||||
|
||||
$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();
|
||||
@@ -141,7 +145,9 @@ class ManageRestrauntController extends Controller
|
||||
{
|
||||
try {
|
||||
$operating_hours = OperatingHour::where('manage_restaurant_xid', $id)->get()->keyBy('day_of_week');
|
||||
$restaurantItem = ManageRestaurant::where('id', $id)->first();
|
||||
$restaurantItem = ManageRestaurant::with('timeInterval')->where('id', $id)->first();
|
||||
$timeInterval = $restaurantItem->timeInterval->first();
|
||||
|
||||
$state = ManageState::where('is_active', 1)->get()->toArray();
|
||||
$restaurantItem['image'] = ListingImageUrl('restaurant_images', $restaurantItem['image']);
|
||||
return view(
|
||||
@@ -150,7 +156,8 @@ class ManageRestrauntController extends Controller
|
||||
'restaurantItem',
|
||||
|
||||
'operating_hours',
|
||||
'state'
|
||||
'state',
|
||||
'timeInterval'
|
||||
)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
@@ -193,12 +200,9 @@ class ManageRestrauntController extends Controller
|
||||
$restaurant->try_on_2 = $request->input('try_on_2');
|
||||
$restaurant->try_on_3 = $request->input('try_on_3');
|
||||
$restaurant->try_on_4 = $request->input('try_on_4');
|
||||
$restaurant->time_hours = $request->input('timeHours');
|
||||
$restaurant->max_numb_day = $request->input('maxNumbDay');
|
||||
$restaurant->max_numb_week = $request->input('maxNumbWeek');
|
||||
$restaurant->max_numb_month = $request->input('maxNumbMonth');
|
||||
$restaurant->save();
|
||||
|
||||
// Handle operating hours
|
||||
foreach ($request->input('operating_hours') as $day => $hours) {
|
||||
$operatingHour = OperatingHour::where('manage_restaurant_xid', $restaurant->id)
|
||||
->where('day_of_week', $day)
|
||||
@@ -221,6 +225,26 @@ class ManageRestrauntController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// Handle time interval
|
||||
$timeInterval = RestaurantTimeInterval::where('manage_restaurants_xid', $restaurant->id)->first();
|
||||
|
||||
if ($timeInterval) {
|
||||
// Update existing record
|
||||
$timeInterval->update([
|
||||
'time_hours' => $request->input('timeHours'),
|
||||
'time_interval' => $request->input('timeInterval'),
|
||||
'quantity' => $request->input('timeQuantity'),
|
||||
]);
|
||||
} else {
|
||||
// Create new record
|
||||
RestaurantTimeInterval::create([
|
||||
'manage_restaurants_xid' => $restaurant->id,
|
||||
'time_hours' => $request->input('timeHours'),
|
||||
'time_interval' => $request->input('timeInterval'),
|
||||
'quantity' => $request->input('timeQuantity'),
|
||||
]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('success.update_data'));
|
||||
@@ -233,6 +257,7 @@ class ManageRestrauntController extends Controller
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayli Raut
|
||||
Created at : 29 May 2024
|
||||
@@ -248,7 +273,7 @@ class ManageRestrauntController extends Controller
|
||||
|
||||
return view('Admin.pages.manage_restaurants.view_restaurant', compact('restaurantItem', 'operating_hours'));
|
||||
} catch (Exception $e) {
|
||||
Log::error("view Voucher Load Failed" . $e->getMessage()) ;
|
||||
Log::error("view Voucher Load Failed" . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,5 +55,10 @@ class ManageRestaurant extends Model
|
||||
}
|
||||
|
||||
|
||||
public function timeInterval()
|
||||
{
|
||||
return $this->hasMany(RestaurantTimeInterval::class, 'manage_restaurants_xid', 'id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
21
app/Models/RestaurantTimeInterval.php
Normal file
21
app/Models/RestaurantTimeInterval.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RestaurantTimeInterval extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'resaurant_time_intervals';
|
||||
|
||||
protected $fillable = [
|
||||
'manage_restaurants_xid',
|
||||
'time_hours',
|
||||
'time_interval',
|
||||
'is_active',
|
||||
'quantity'
|
||||
|
||||
];
|
||||
}
|
||||
@@ -30,10 +30,6 @@ return new class extends Migration
|
||||
$table->string('exclusion', 255)->nullable();
|
||||
$table->string('latitude');
|
||||
$table->string('longtitude');
|
||||
$table->integer('time_hours')->default(1)->comment('Time in hours between redeeming two cocktails');
|
||||
$table->integer('max_numb_day')->default(1)->comment('Maximum number of cocktails per day');
|
||||
$table->integer('max_numb_week')->default(1)->comment('Maximum number of cocktails per week');
|
||||
$table->integer('max_numb_month')->default(1)->comment('Maximum number of cocktails per month');
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
$table->integer('created_by')->nullable();
|
||||
$table->integer('modified_by')->nullable();
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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('resaurant_time_intervals', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('manage_restaurants_xid');
|
||||
$table->foreign('manage_restaurants_xid')->references('id')->on('manage_restaurants')->onDelete('cascade');
|
||||
$table->integer('time_hours');
|
||||
$table->integer('quantity');
|
||||
$table->enum('time_interval', ['day', 'week', 'month'])->default('day');
|
||||
$table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
|
||||
$table->softDeletes();
|
||||
$table->integer('created_by')->nullable();
|
||||
$table->integer('modified_by')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('resaurant_time_intervals');
|
||||
}
|
||||
};
|
||||
@@ -24,14 +24,14 @@ $(document).on("click", "#update_restaurant_btn", function (e) {
|
||||
latitude: {
|
||||
required: true,
|
||||
number: true,
|
||||
normalizer: function(value) {
|
||||
normalizer: function (value) {
|
||||
return $.trim(value);
|
||||
}
|
||||
},
|
||||
longitude: {
|
||||
required: true,
|
||||
number: true,
|
||||
normalizer: function(value) {
|
||||
normalizer: function (value) {
|
||||
return $.trim(value);
|
||||
}
|
||||
},
|
||||
@@ -55,17 +55,12 @@ $(document).on("click", "#update_restaurant_btn", function (e) {
|
||||
number: true,
|
||||
min: 1
|
||||
},
|
||||
maxNumbDay: {
|
||||
timeQuantity: {
|
||||
required: true,
|
||||
number: true,
|
||||
min: 1
|
||||
},
|
||||
maxNumbWeek: {
|
||||
required: true,
|
||||
number: true,
|
||||
min: 1
|
||||
},
|
||||
maxNumbMonth: {
|
||||
maxCocktails: {
|
||||
required: true,
|
||||
number: true,
|
||||
min: 1
|
||||
@@ -118,20 +113,15 @@ $(document).on("click", "#update_restaurant_btn", function (e) {
|
||||
number: "Time must be a number",
|
||||
min: "Time must be greater than 0"
|
||||
},
|
||||
maxNumbDay: {
|
||||
required: "Please enter the maximum number of cocktails per day",
|
||||
number: "Value must be a number",
|
||||
min: "Value must be greater than 0"
|
||||
timeQuantity: {
|
||||
required: "Please enter the time quantity",
|
||||
number: "Time quantity must be a number",
|
||||
min: "Time quantity must be greater than 0"
|
||||
},
|
||||
maxNumbWeek: {
|
||||
required: "Please enter the maximum number of cocktails per week",
|
||||
number: "Value must be a number",
|
||||
min: "Value must be greater than 0"
|
||||
},
|
||||
maxNumbMonth: {
|
||||
required: "Please enter the maximum number of cocktails per month",
|
||||
number: "Value must be a number",
|
||||
min: "Value must be greater than 0"
|
||||
maxCocktails: {
|
||||
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"
|
||||
}
|
||||
},
|
||||
errorClass: 'error-message',
|
||||
|
||||
@@ -135,51 +135,37 @@
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="timeHours" class="label">Time in hours between redeeming two
|
||||
cocktails in hours</label>
|
||||
cocktails</label>
|
||||
<input type="number" class="form-control" id="timeHours" name="timeHours"
|
||||
required>
|
||||
<label for="timeQuantity" class="label">Maximum number of cocktails</label>
|
||||
<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>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="maxNumbDay" class="label">Maximum number of cocktails per
|
||||
day</label>
|
||||
<input type="number" class="form-control" id="maxNumbDay" name="maxNumbDay"
|
||||
required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="maxNumbWeek" class="label">Maximum number of cocktails per
|
||||
week</label>
|
||||
<input type="number" class="form-control" id="maxNumbWeek"
|
||||
name="maxNumbWeek" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="maxNumbMonth" class="label">Maximum number of cocktails per
|
||||
month</label>
|
||||
<input type="number" class="form-control" id="maxNumbMonth"
|
||||
name="maxNumbMonth" 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 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>
|
||||
<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>
|
||||
|
||||
@@ -116,38 +116,42 @@
|
||||
maxlength="30" value="{{ $restaurantItem->longtitude }}">
|
||||
</div>
|
||||
</div>
|
||||
@php
|
||||
$timeInterval = $restaurantItem->timeInterval->first();
|
||||
$timeHours = $timeInterval->time_hours ?? '';
|
||||
$timeIntervalValue = $timeInterval->time_interval ?? '';
|
||||
$timeQuantity = $timeInterval->quantity ?? '';
|
||||
@endphp
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="timeHours" class="label">Time in hours between redeeming two
|
||||
cocktails in hours</label>
|
||||
cocktails</label>
|
||||
<input type="number" class="form-control" id="timeHours" name="timeHours"
|
||||
value="{{ $restaurantItem->time_hours }}">
|
||||
value="{{ $timeHours }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="maxNumbDay" class="label">Maximum number of cocktails per
|
||||
day</label>
|
||||
<input type="number" class="form-control" id="maxNumbDay" name="maxNumbDay"
|
||||
value="{{ $restaurantItem->max_numb_day }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="maxNumbWeek" class="label">Maximum number of cocktails per
|
||||
week</label>
|
||||
<input type="number" class="form-control" id="maxNumbWeek"
|
||||
value="{{ $restaurantItem->max_numb_week }}" name="maxNumbWeek">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="maxNumbMonth" class="label">Maximum number of cocktails per
|
||||
month</label>
|
||||
<input type="number" class="form-control" id="maxNumbMonth"
|
||||
value="{{ $restaurantItem->max_numb_month }}" name="maxNumbMonth">
|
||||
<label for="timeQuantity" class="label">Maximum number of cocktails</label>
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="timeInterval" name="timeInterval"
|
||||
required>
|
||||
<option value="day"
|
||||
{{ $timeIntervalValue == 'day' ? 'selected' : '' }}>Day</option>
|
||||
<option value="week"
|
||||
{{ $timeIntervalValue == 'week' ? 'selected' : '' }}>Week</option>
|
||||
<option value="month"
|
||||
{{ $timeIntervalValue == 'month' ? 'selected' : '' }}>Month
|
||||
</option>
|
||||
</select>
|
||||
<input type="number" class="form-control" id="timeQuantity"
|
||||
name="timeQuantity" value="{{ $timeQuantity }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<label for="company-name" class="label">Bio</label>
|
||||
@@ -157,7 +161,8 @@
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<label for="company-name" class="label">While at Restaurant be sure to try
|
||||
<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"
|
||||
value="{{ $restaurantItem->try_on_1 }}">
|
||||
@@ -294,17 +299,12 @@
|
||||
number: true,
|
||||
min: 1
|
||||
},
|
||||
maxNumbDay: {
|
||||
timeQuantity: {
|
||||
required: true,
|
||||
number: true,
|
||||
min: 1
|
||||
},
|
||||
maxNumbWeek: {
|
||||
required: true,
|
||||
number: true,
|
||||
min: 1
|
||||
},
|
||||
maxNumbMonth: {
|
||||
maxCocktails: {
|
||||
required: true,
|
||||
number: true,
|
||||
min: 1
|
||||
@@ -354,20 +354,15 @@
|
||||
number: "Time must be a number",
|
||||
min: "Time must be greater than 0"
|
||||
},
|
||||
maxNumbDay: {
|
||||
required: "Please enter the maximum number of cocktails per day",
|
||||
number: "Value must be a number",
|
||||
min: "Value must be greater than 0"
|
||||
timeQuantity: {
|
||||
required: "Please enter the time quantity",
|
||||
number: "Time quantity must be a number",
|
||||
min: "Time quantity must be greater than 0"
|
||||
},
|
||||
maxNumbWeek: {
|
||||
required: "Please enter the maximum number of cocktails per week",
|
||||
number: "Value must be a number",
|
||||
min: "Value must be greater than 0"
|
||||
},
|
||||
maxNumbMonth: {
|
||||
required: "Please enter the maximum number of cocktails per month",
|
||||
number: "Value must be a number",
|
||||
min: "Value must be greater than 0"
|
||||
maxCocktails: {
|
||||
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"
|
||||
},
|
||||
bio: {
|
||||
required: "Enter Bio",
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
<td class="text-scrollable">{{ $restaurantItem->try_on_2 }}</td>
|
||||
<td class="text-scrollable">{{ $restaurantItem->try_on_3 }}</td>
|
||||
<td class="text-scrollable">{{ $restaurantItem->try_on_4 }}</td>
|
||||
<td>{{ $restaurantItem->exclusion }}</td>
|
||||
<td class="text-scrollable">{{ $restaurantItem->exclusion }}</td>
|
||||
<td>{{ $restaurantItem->latitude }}</td>
|
||||
<td>{{ $restaurantItem->longtitude }}</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user