firefly-iii/app/Models/TransactionCurrency.php

70 lines
2.8 KiB
PHP
Raw Normal View History

2016-05-20 01:57:45 -05:00
<?php
/**
* TransactionCurrency.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
2016-05-20 01:57:45 -05:00
declare(strict_types = 1);
namespace FireflyIII\Models;
2015-02-27 09:48:33 -06:00
2016-01-09 09:09:26 -06:00
use Auth;
2015-02-27 09:48:33 -06:00
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
2016-01-09 09:09:26 -06:00
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
2016-08-11 11:44:11 -05:00
use Watson\Validating\ValidatingTrait;
2015-02-27 09:48:33 -06:00
/**
2016-01-01 14:49:27 -06:00
* FireflyIII\Models\TransactionCurrency
2015-02-27 09:48:33 -06:00
*
* @property integer $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at
* @property string $code
* @property string $name
* @property string $symbol
* @property-read \Illuminate\Database\Eloquent\Collection|TransactionJournal[] $transactionJournals
2016-03-12 00:36:23 -06:00
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereDeletedAt($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereCode($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereName($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionCurrency whereSymbol($value)
* @mixin \Eloquent
2015-02-27 09:48:33 -06:00
*/
class TransactionCurrency extends Model
{
2016-08-11 11:44:11 -05:00
use SoftDeletes, ValidatingTrait;
2015-02-27 09:48:33 -06:00
2016-01-15 15:32:21 -06:00
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
2016-08-11 11:44:11 -05:00
protected $fillable = ['name', 'code', 'symbol'];
protected $rules = ['name' => 'required|between:1,200', 'code' => 'required|between:3,3', 'symbol' => 'required|between:1,12'];
2016-01-09 09:09:26 -06:00
/**
* @param TransactionCurrency $currency
*
* @return TransactionCurrency
2016-01-09 09:09:26 -06:00
*/
public static function routeBinder(TransactionCurrency $currency)
{
if (Auth::check()) {
return $currency;
}
throw new NotFoundHttpException;
}
2016-08-11 11:44:11 -05:00
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function transactionJournals()
{
return $this->hasMany('FireflyIII\Models\TransactionJournal');
}
2015-02-27 09:48:33 -06:00
}