You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

38 lines
1010 B

<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Activity extends Model
{
use HasFactory;
protected $fillable = [
'business_id', 'project_id', 'system_id', 'workflow_id', 'status_id', 'sprint_id',
'actor_id', 'task_id', 'subject_id', 'user_id', 'crud_id', 'table_id', 'original', 'diff'
];
public $casts = [
'original' => 'array',
'diff' => 'array',
];
public function scopeCreatesBefore($query, $date)
{
return $query->whereDate('created_at', '<=', Carbon::parse($date));
}
public function scopeCreatesAfter($query, $date)
{
return $query->whereDate('created_at', '>=', Carbon::parse($date));
}
public function scopeCreatesIn($query, $days)
{
return $days != "" ?
$query->whereDate('created_at', '>=', Carbon::now()->modify('-'.$days.' day')->toDate()) :
$query;
}
}