scarlet pro
scarlet pro

Reputation: 191

Laravel php database check the date

Is there the proper way to check the database date if smaller than "before date" then do the restriction?

currently What I have is

        if (count(Sale::where('date','<=' ,'2018-08-01')->get()) > 0 ) {
            echo "Sales is closed";
            return false;
        }else {
            echo "Sales is open";
            return true;
        }

The sale will closed for the date that before 2018-08-01 and new sale will open after the date.

Upvotes: 0

Views: 64

Answers (1)

Jignesh Joisar
Jignesh Joisar

Reputation: 15125

yes proper method in laravel-4 but directly used count method u can achieve (get method is not needed here)

if (Sale::where('date','<=' ,'2018-08-01')->count() > 0 ) {
    //restriction
}else {
   //not restrication 
}

Upvotes: 1

Related Questions