firefly-iii/app/models/Category.php

48 lines
1.6 KiB
PHP
Raw Normal View History

<?php
2014-11-17 00:33:18 -06:00
2014-07-15 15:16:29 -05:00
/**
* Category
*
2014-11-17 00:33:18 -06:00
* @property integer $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $name
* @property integer $user_id
* @property string $class
2014-07-15 15:16:29 -05:00
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
2014-11-17 00:33:18 -06:00
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
* @property-read \User $user
* @method static \Illuminate\Database\Query\Builder|\Category whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Category whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Category whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Category whereName($value)
* @method static \Illuminate\Database\Query\Builder|\Category whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\Category whereClass($value)
2014-07-15 15:16:29 -05:00
*/
class Category extends Component
{
protected $isSubclass = true;
/**
* @return Carbon
*/
public function lastActionDate()
{
$transaction = $this->transactionjournals()->orderBy('updated_at', 'DESC')->first();
2014-11-17 00:33:18 -06:00
if (is_null($transaction)) {
return null;
}
return $transaction->date;
}
2014-11-17 00:33:18 -06:00
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function transactionjournals()
{
return $this->belongsToMany('TransactionJournal', 'component_transaction_journal', 'component_id');
}
}