2014-08-06 17:02:02 +02:00
|
|
|
<?php
|
2014-12-06 12:12:55 +01:00
|
|
|
use Watson\Validating\ValidatingTrait;
|
2014-12-20 15:00:53 +01:00
|
|
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
2014-12-13 21:59:02 +01:00
|
|
|
/**
|
2014-12-29 20:28:17 +01:00
|
|
|
* Class Bill
|
2014-12-13 21:59:02 +01:00
|
|
|
*/
|
2014-12-29 20:28:17 +01:00
|
|
|
class Bill extends Eloquent
|
2014-08-06 17:02:02 +02:00
|
|
|
{
|
|
|
|
|
2014-12-06 12:12:55 +01:00
|
|
|
use ValidatingTrait;
|
2014-12-20 15:00:53 +01:00
|
|
|
protected $rules
|
2014-11-18 09:47:50 +01:00
|
|
|
= [
|
|
|
|
'user_id' => 'required|exists:users,id',
|
2014-12-20 15:00:53 +01:00
|
|
|
'name' => 'required|between:1,255|min:1',
|
2014-11-18 09:47:50 +01:00
|
|
|
'match' => 'required',
|
|
|
|
'amount_max' => 'required|between:0,65536',
|
|
|
|
'amount_min' => 'required|between:0,65536',
|
|
|
|
'date' => 'required|date',
|
2014-12-20 15:00:53 +01:00
|
|
|
'active' => 'between:0,1',
|
|
|
|
'automatch' => 'between:0,1',
|
2014-11-18 09:47:50 +01:00
|
|
|
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly',
|
|
|
|
'skip' => 'required|between:0,31',];
|
2014-11-12 22:37:44 +01:00
|
|
|
protected $fillable = ['user_id', 'name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'active', 'automatch'];
|
2014-08-10 18:22:42 +02:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2014-08-07 07:44:37 +02:00
|
|
|
public function getDates()
|
|
|
|
{
|
|
|
|
return ['created_at', 'updated_at', 'date'];
|
|
|
|
}
|
|
|
|
|
2014-11-17 07:33:18 +01:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function transactionjournals()
|
|
|
|
{
|
|
|
|
return $this->hasMany('TransactionJournal');
|
|
|
|
}
|
|
|
|
|
2014-11-21 11:12:22 +01:00
|
|
|
|
2014-11-13 16:13:32 +01:00
|
|
|
|
2014-08-10 18:22:42 +02:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
2014-08-06 17:02:02 +02:00
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('User');
|
|
|
|
}
|
2015-01-02 06:16:49 +01:00
|
|
|
}
|