Browse Source

add model

remotes/origin/mohammad
mahdihty 4 years ago
parent
commit
42ff482886
  1. 31
      app/Models/Activity.php

31
app/Models/Activity.php

@ -2,8 +2,37 @@
namespace App\Models;
use App\Models\Model;
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;
}
}
Loading…
Cancel
Save