firefly-iii/app/models/Preference.php

55 lines
1.5 KiB
PHP
Raw Normal View History

<?php
use LaravelBook\Ardent\Ardent;
2014-07-15 15:16:29 -05:00
/**
* Preference
*
2014-07-30 00:14:00 -05:00
* @property integer $id
2014-07-15 15:16:29 -05:00
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
2014-07-30 00:14:00 -05:00
* @property integer $user_id
* @property string $name
* @property string $data
* @property-read \User $user
* @method static \Illuminate\Database\Query\Builder|\Preference whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Preference whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Preference whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Preference whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\Preference whereName($value)
* @method static \Illuminate\Database\Query\Builder|\Preference whereData($value)
2014-07-15 15:16:29 -05:00
*/
class Preference extends Ardent
{
public static $rules
= [
'user_id' => 'required|exists:users,id',
'name' => 'required|between:1,255',
'data' => 'required'
];
public static $factory
= [
'user_id' => 'factory|User',
'name' => 'string',
'data' => 'string'
];
2014-07-09 06:19:30 -05:00
public function user()
{
return $this->belongsTo('User');
}
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value);
}
2014-07-15 00:36:01 -05:00
//
public function getDataAttribute($value)
{
return json_decode($value);
}
}