samedi 6 août 2022

Custom legend in Chart [duplicate]

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.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/zsyxjM1
via IFTTT

vendredi 5 août 2022

HTTP ERROR 500? is currently unable to handle this request? [closed]

/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



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/ZYOaUQr
via IFTTT

jeudi 4 août 2022

Laravel permissions pivot table

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): enter image description here



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/oIEAx5e
via IFTTT

How to export currently searched data in excel laravel?

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.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/rxQNXY5
via IFTTT

mardi 2 août 2022

"Invalid argument supplied for foreach()", in laravel controller

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);
                }
            }
        });

    });
});


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/g1WkEc0
via IFTTT

lundi 1 août 2022

PHP add minutes to MongoDB\BSON\UTCDateTime

use MongoDB\BSON\UTCDateTime;

$date = new UTCDateTime($val * 1000); // 1659356187861

How can I do this if I want to subtract or add 5 minutes from this $date variable?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/jzC1Hn3
via IFTTT

Laravel SwitMessage add Reply-path header

We have a Laravel application which sends newsletters to customers. As per the client's request, we would like to add a header in the email indicating that it's a newsletter or mail to a list to avoid out of office email bounces. Upon research, I found that one way to do so is to add Precedence: bulk header. But answer also says that RFC 2076 discourages adding Precedence header. Some post recommend adding Return-Path: <> (a NULL Return-Path). However, I'm not able to add this header. I have tried following codes to add such a header but not working.

$headers->addTextHeader('Return-Path', ''); - Uses the mail id defined in config file 
$headers->addTextHeader('Return-Path', '<>') - This generates a malformed header as in the attached image
$headers->addTextHeader('Return-Path', ' '); - Adds a header like Return-Path   
< > but not sure if this is correct or it will create other issues


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/Hi3ILUB
via IFTTT