firefly-iii/app/models/Reminder.php

91 lines
2.6 KiB
PHP
Raw Normal View History

<?php
use Carbon\Carbon;
use LaravelBook\Ardent\Ardent;
/**
* Reminder
*
* @property integer $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property integer $user_id
* @property \Carbon\Carbon $startdate
* @property \Carbon\Carbon $enddate
* @property boolean $active
2014-11-24 11:06:21 -06:00
* @property boolean $notnow
* @property integer $remembersable_id
* @property string $remembersable_type
2014-11-21 04:12:22 -06:00
* @property-read \Piggybank $remindersable
* @property-read \User $user
* @property mixed $data
2014-11-22 00:34:08 -06:00
* @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereStartdate($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereEnddate($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereActive($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereRemembersableId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereRemembersableType($value)
* @method static \Reminder dateIs($start, $end)
* @property integer $remindersable_id
* @property string $remindersable_type
2014-11-22 01:17:37 -06:00
* @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableType($value)
*/
2014-11-25 14:04:00 -06:00
class Reminder extends Ardent
{
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();
}
/**
* User
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('User');
}
2014-11-21 04:12:22 -06:00
public function scopeDateIs($query, Carbon $start, Carbon $end)
{
return $query->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'));
}
public function getDataAttribute($value)
{
return json_decode($value);
}
/**
* @param $value
*/
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value);
}
}