firefly-iii/app/models/Reminder.php

59 lines
1.2 KiB
PHP
Raw Normal View History

<?php
use Carbon\Carbon;
2015-01-02 02:06:44 -06:00
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model as Eloquent;
2014-12-06 05:12:55 -06:00
use Watson\Validating\ValidatingTrait;
2015-01-02 02:06:44 -06:00
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
/**
2015-01-02 02:06:44 -06:00
* @param EloquentBuilder $query
* @param Carbon $start
* @param Carbon $end
2014-12-13 14:59:02 -06:00
*
* @return mixed
*/
2015-01-02 02:06:44 -06:00
public function scopeDateIs(EloquentBuilder $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');
}
2015-01-01 23:16:49 -06:00
}