controller refactoring part 17

This commit is contained in:
Peter Papp
2021-07-21 11:20:41 +02:00
parent e0eaf5cede
commit dccf98602d
21 changed files with 370 additions and 94 deletions

View File

@@ -3,10 +3,12 @@ namespace Domain\Traffic\Models;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/**
* @method static whereYear(string $string, string $string1, int $year)
* @method static currentMonth()
*/
class Traffic extends Model
{
@@ -22,6 +24,13 @@ class Traffic extends Model
protected $keyType = 'string';
public function scopeCurrentMonth($query): Builder
{
return $query
->whereYear('created_at', '=', now()->year)
->whereMonth('created_at', '=', now()->month);
}
protected static function boot()
{
parent::boot();