- 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
This commit is contained in:
44
app/Repositories/CourseNotification.php
Normal file
44
app/Repositories/CourseNotification.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user