Add validation for column quantity, if availability column equals to "in stock", the quantity column should be greater than 0.
via Chebli Mohamed
Add validation for column quantity, if availability column equals to "in stock", the quantity column should be greater than 0.
I am working on a code
if (!function_exists('decrypt_password')) {
function decrypt_password( $iv, $value)
{
$key = config('services.decrypt.key');
$string_iv =hex_to_string($iv);
$encrypter = new Encrypter($key, 'AES-256-CBC');
$dec['iv'] = base64_encode($string_iv);
$dec['value'] = $value;
$dec['mac'] = hash_hmac('sha256', $dec['iv'] . $dec['value'], $key);
return ($encrypter->decrypt(base64_encode(json_encode($dec)),false));
}
}
this piece of code should make a layer of decrypting the password, and key is missing in config and I can't get one or generate a new one. any help!
i am using xcosta/laravel-chartjs to generate chart. In the docs there is no mention of legendcallback:function(){}. i want to generate custom legend but am being unable to generate. Can someone help me on this one.
/home/maxmpgdb/public_html/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(61): Illuminate\View\Engines\PhpEngine->evaluatePa in /home/maxmpgdb/public_html/resources/views/themes/royalblue/partials/footer.blade.php on line 58enter image description here
I am making custom permissions,
I would like them to be divided into sections e.g. orders, customers etc. and each section would have some permission e.g. edit, delete, add. Just to check if a particular user has access I would have to start with the Section model?
Because I can't do something like Auth::user()->permissions()->with('sections')->contains('name','display')->contains('sections','order')
I would like to simply check if the user has access to, for example, order.display. I have a feeling that this section does not make sense here.
How to do it? I know there is a spatie(laravel-permission), but there is a role division there.
Example schema of the database (user_permission is a pivot): 
I am trying to exceldownload only the data searched by the user but my code isnt working.
Controller
public function get_data(Request $request, Covidrecord $covidrecord)
{
$search = $request['search'] ?? '';
if ($search != '') {
$covidrecord = Covidrecord::where('fullname', 'LIKE', "%$search%")
->orWhere('gender', 'LIKE', "%$search%")
->orWhere('age', 'LIKE', "%$search%")
->orWhere('hospital_type', 'LIKE', "%$search%")
->orWhere('vaccine_status', 'LIKE', "%$search%")
->get();
}
Excel::create('covidrecord', function($excel) use($covidrecord) {
$excel->sheet('sheet 1', function($sheet) use($covidrecord){
$sheet->fromArray($covidrecord);
});
})->download('xlsx');
}
Below is the Export.php..How can i filter search here??
CovidRecordExport.php
class CovidRecordExport implements FromCollection
{
public function headings():array{
return[
'fullname',
'age',
'gender',
'ethinicity',
'religion',
'occupation',
'qualification',
'financial_status',
'marital_status',
'infection_date',
'covid_verficiation',
'hospitalization_date',
'hospital_type',
'death_date',
'death_reason',
'after_covid_death',
'death_location',
'vaccine_status',
];
}
public function collection()
{
return CovidRecord::all();
}
}
I tried dd() and it seems like my if condition is not working.
I want to add coupon code system in e commerce website using laravel 5.8 when i click on apply coupon button it gives me error like "Invalid argument supplied for foreach()" the problem is with that foreach loop in my controller when i remove it then it shows 0 price can anybody help me to solve this problem
here is my controller
public function applycoupon(Request $request){
$coupon = $request->input('coupon_code');
if(Coupons::where('coupon_code',$coupon)->exists())
{
$coupon = Coupons::where('coupon_code',$coupon)->first();
if($coupon->start_date<=Carbon::today()&& Carbon::today()<= $coupon->end_date){
$totalprice = "0";
$cookie_data = stripslashes(Cookie::get('shoping_cart'));
$cart_data = json_decode($cookie_data,true);
foreach ($cart_data as $itemdata){
$product = Product::find($itemdata['item_id']);
$prod_price = $product->offer_price;
// $prod_price_tax = ($prod_price*$product->tax)/100;
$totalprice = $totalprice+($itemdata['item_quantity']*$prod_price);
}
//checking Type (percentage or amount)
if($coupon->coupon_type=='Percentage')
{
$discount_price = ($totalprice/100)*$coupon->coupon_price;
}
elseif($coupon->coupon_price=='amount'||'Amount')
{
$discount_price = $coupon->coupon_price;
}
$grand_total = $totalprice-$discount_price;
return response()->json([
'discount_price' =>$discount_price,
'grand_total' =>$grand_total,
]);
}
else
{
return response()->json([
'status'=> 'coupon code has been expired',
'error_status'=>'error'
]);
}
}
else
{
return response()->json([
'status'=> 'coupon code does not exists',
'error_status'=>'error'
]);
}
}
views.blade file
<div class="card-body">
<div class="d-flex justify-content-between mb-3 pt-1">
<h6 class="font-weight-medium">Subtotal</h6>
<h6 class="font-weight-medium">$</h6>
</div>
<div class="d-flex justify-content-between">
<h6 class="font-weight-medium">Discount</h6>
<h6 class="font-weight-medium discount_price">0.00</h6>
</div>
</div>
Route
Route::post('apply-coupons','CouponController@applycoupon');
custom js file
custom js file
//Apply coupons
$(document).ready(function () {
$('.apply-coupon-btn').click(function (e) {
e.preventDefault();
var coupon_code = $('.coupon_code').val();
if ($.trim(coupon_code).length == 0) {
error_coupon = "please enter valid coupon";
$('#error_coupon').text(error_coupon);
} else {
error_coupon = "";
$('#error_coupon').text(error_coupon);
}
if (error_coupon != '') {
return false;
}
$.ajax({
method: "POST",
url: "/apply-coupons",
data: {
'coupon_code': coupon_code,
},
success: function (response) {
if (response.error_status == 'error') {
alertify.set('notifier', 'position', 'top-right');
alertify.success(response.status);
$('.coupon_code').val('');
}
else{
var discount_price = response.discount_price;
var grand_total = response.grand_total;
$('.discount_price').text(discount_price);
$('.grand_total').text(grand_total);
}
}
});
});
});