Avatar of emi_sastra
emi_sastra

asked on 

Add more filters to Eloquent Laravel

Hi All,

I have below code:


if($filters->has('Date') && $this->isAffectedBy($top ? 'top5partner' : 'bottom5partner', 'Date')){
            $from = new \Carbon\Carbon(date('Y-m-d', strtotime($filters['Date'][0])));
            $to = new \Carbon\Carbon(date('Y-m-d', strtotime($filters['Date'][1])));
        }

        $where = [
            ['Dimension', 'like', '%Final Score']
        ];

        $dt = \DB::table('datamaster')
            ->select(\DB::raw("Partner,
                AVG(DimensionScore) score"))    
            ->groupBy('Partner')
            ->where($where);

I want to add filter Month between $from and $to

How could I do it?

Thank you.
LaravelPHP

Avatar of undefined
Last Comment
emi_sastra
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of emi_sastra
emi_sastra

ASKER

It works.

Thank you.

PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo