firefly-iii/app/models/Reminder.php

59 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-06 05:12:55 -06:00
class Reminder extends Eloquent
{
2014-12-06 05:12:55 -06:00
use ValidatingTrait;
protected $table = 'reminders';
2014-12-06 05:12:55 -06:00
public function getDataAttribute($value)
{
return json_decode($value);
}
/**
* @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();
}
public function scopeDateIs($query, Carbon $start, Carbon $end)
{
return $query->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'));
}
/**
* @param $value
*/
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value);
}
2014-12-06 05:12:55 -06:00
/**
* User
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('User');
}
}