Some checks failed
continuous-integration/drone/push Build is failing
- Complete GGZ Ecademy Laravel backend application - RESTful API for learning products, members, filters - Authentication and authorization system - Database migrations and seeders - Custom CRUD generator commands - Email notification system - Integration with frontend applications
45 lines
851 B
PHP
45 lines
851 B
PHP
<?php
|
|
|
|
namespace App\Repositories;
|
|
|
|
use DateTime;
|
|
use DateInterval;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CourseNotification extends Model
|
|
{
|
|
protected $dates = ['deleted_at'];
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
public function learning_product()
|
|
{
|
|
return $this->belongsTo(LearningProduct::class);
|
|
}
|
|
|
|
public function scopeNotExpired($query)
|
|
{
|
|
return $query->where('date', '>', new DateTime());
|
|
}
|
|
|
|
public function scopeExpired($query)
|
|
{
|
|
return $query->where('date', '<', new DateTime());
|
|
}
|
|
|
|
public function scopeExpireInFiveMinutes($query)
|
|
{
|
|
$minutes_to_add = 5;
|
|
$time = new DateTime();
|
|
$time->add(new DateInterval('PT' . $minutes_to_add . 'M'));
|
|
// $stamp = $time->format('Y-m-d H:i');
|
|
|
|
return $query->where('date', '<', $time);
|
|
}
|
|
|
|
public function scopeNotSent($query)
|
|
{
|
|
return $query->where('sent', false);
|
|
}
|
|
}
|