Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Division By Zero In Laravel in home.blade.php

I m having Division by Zero in home.blade.php. Is this due to PHP version or something wrong here as error showing

 <div id="student-view-slider" class="student-view-slider-main-block owl-carousel">
            <?php $__currentLoopData = $cors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
             <?php if($c->status == 1 && $c->featured == 1): ?>   
            <div class="item student-view-block student-view-block-1">
                <div class="genre-slide-image <?php if($gsetting['course_hover'] == 1): ?> protip <?php endif; ?>"
                    data-pt-placement="outside" data-pt-interactive="false"
                    data-pt-title="#prime-next-item-description-block<?php echo e($c->id); ?>">
                    <div class="view-block">
                        <div class="view-img">
                            <?php if($c['preview_image'] !== NULL && $c['preview_image'] !== ''): ?>
                            <a href="<?php echo e(route('user.course.show',['id' => $c->id, 'slug' => $c->slug ])); ?>"><img
                                    data-src="<?php echo e(asset('images/course/'.$c['preview_image'])); ?>" alt="course"
                                    class="img-fluid owl-lazy"></a>
                            <?php else: ?>
                            <a href="<?php echo e(route('user.course.show',['id' => $c->id, 'slug' => $c->slug ])); ?>"><img
                                    data-src="<?php echo e(Avatar::create($c->title)->toBase64()); ?>" alt="course"
                                    class="img-fluid owl-lazy"></a>
                            <?php endif; ?>
                        </div>
                        <div class="badges bg-priamry offer-badge"><span>OFF<span><?php echo round((($c->price - $c->discount_price) * 100)

Screenshot of error

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You will need to make sure that $c->price is not equal to zero before trying to perform the division.

<?php 
if ($c->price != 0) {
    echo round((($c->price - $c->discount_price) * 100));
}
?>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading