2014-08-23 15:32:12 -05:00
|
|
|
<?php
|
|
|
|
|
2014-11-17 15:32:55 -06:00
|
|
|
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-08-23 15:32:12 -05:00
|
|
|
{
|
2014-12-06 05:12:55 -06:00
|
|
|
use ValidatingTrait;
|
2014-08-23 15:32:12 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2014-11-17 15:32:55 -06:00
|
|
|
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-11-17 03:10:57 -06:00
|
|
|
}
|
|
|
|
|
2014-12-06 05:12:55 -06:00
|
|
|
/**
|
|
|
|
* User
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('User');
|
|
|
|
}
|
|
|
|
|
2014-11-17 03:10:57 -06:00
|
|
|
|
2014-08-23 15:32:12 -05:00
|
|
|
}
|