firefly-iii/app/models/Reminder.php

56 lines
1.1 KiB
PHP
Raw Normal View History

<?php
use Carbon\Carbon;
2014-12-06 05:12:55 -06:00
use Watson\Validating\ValidatingTrait;
2014-12-20 08:00:53 -06:00
use \Illuminate\Database\Eloquent\Model as Eloquent;
2014-12-13 14:59:02 -06:00
/**
* Class Reminder
*/
2014-12-06 05:12:55 -06:00
class Reminder extends Eloquent
{
2014-12-06 05:12:55 -06:00
use ValidatingTrait;
protected $table = 'reminders';
/**
* @return array
*/
public function getDates()
{
return ['created_at', 'updated_at', 'startdate', 'enddate'];
}
2014-11-17 13:55:31 -06:00
/**
* A polymorphic thing or something!
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function remindersable()
{
return $this->morphTo();
}
2014-12-13 14:59:02 -06:00
/**
* @param $query
* @param Carbon $start
* @param Carbon $end
*
* @return mixed
*/
public function scopeDateIs($query, Carbon $start, Carbon $end)
{
2015-01-01 06:12:05 -06:00
return $query->where('startdate', $start->format('Y-m-d 00:00:00'))->where('enddate', $end->format('Y-m-d 00:00:00'));
}
2014-12-06 05:12:55 -06:00
/**
* User
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('User');
}
}