@@ -20,6 +20,7 @@ class ModelAction extends Model
2020 protected $ casts = [
2121 'status ' => Status::class,
2222 'properties ' => 'collection ' ,
23+ 'act_on ' => 'datetime:Y-m-d ' ,
2324 'act_at ' => 'datetime ' ,
2425 'finished_at ' => 'datetime '
2526 ];
@@ -60,12 +61,17 @@ public function scopeDispatched($query)
6061
6162 public function scopeToActToday ($ query )
6263 {
63- return $ query ->whereDate ('act_at ' , self ::today ());
64+ return $ query ->whereDate ('act_on ' , self ::today ());
6465 }
6566
66- public function scopeToActBetween ($ query , $ start , $ end )
67+ public function scopeToActOn ($ query , Carbon $ date )
6768 {
68- return $ query ->whereBetween ('act_at ' , [$ start , $ end ]);
69+ return $ query ->whereDate ('act_on ' , $ date );
70+ }
71+
72+ public function scopeToActBetween ($ query , Carbon $ start , Carbon $ end )
73+ {
74+ return $ query ->whereBetween ('act_at ' , [$ start ->toTimeString (), $ end ->toTimeString ()]);
6975 }
7076
7177 public function scopeWhereExtraProperty ($ query , $ prop , $ value )
@@ -83,7 +89,9 @@ public function scopeWhereExtraProperties($query, array $properties)
8389
8490 public function scopeOrderByWhenToAct ($ query , string $ direction = 'asc ' )
8591 {
86- return $ query ->orderBy ('act_at ' , $ direction !== 'asc ' ? 'desc ' : 'asc ' );
92+ return $ query
93+ ->orderBy ('act_on ' , $ direction !== 'asc ' ? 'desc ' : 'asc ' )
94+ ->orderBy ('act_at ' , $ direction !== 'asc ' ? 'desc ' : 'asc ' );
8795 }
8896
8997 public function scopeFor ($ query , Model $ model )
0 commit comments