firefly-iii/app/Models/LinkType.php
2017-08-23 21:21:42 +02:00

62 lines
1.3 KiB
PHP

<?php
/**
* LinkType.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types=1);
namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* @property int $journalCount
* Class LinkType
*
* @package FireflyIII\Models
*/
class LinkType extends Model
{
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'created_at' => 'date',
'updated_at' => 'date',
'deleted_at' => 'date',
'editable' => 'boolean',
];
/**
* @param $value
*
* @return mixed
* @throws NotFoundHttpException
*/
public static function routeBinder($value)
{
if (auth()->check()) {
$model = self::where('id', $value)->first();
if (!is_null($model)) {
return $model;
}
}
throw new NotFoundHttpException;
}
public function transactionJournalLinks()
{
return $this->hasMany(TransactionJournalLink::class);
}
}