firefly-iii/app/Models/Note.php

44 lines
919 B
PHP
Raw Normal View History

2016-10-22 03:13:49 -05:00
<?php
/**
* Note.php
* Copyright (C) 2016 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 League\CommonMark\CommonMarkConverter;
2016-10-22 03:13:49 -05:00
class Note extends Model
{
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $fillable = ['title', 'text'];
/**
* @return string
*/
public function getMarkdownAttribute(): string
{
2016-11-05 05:47:21 -05:00
$converter = new CommonMarkConverter;
return $converter->convertToHtml($this->text);
}
2016-10-22 03:13:49 -05:00
/**
* Get all of the owning noteable models. Currently only piggy bank
*/
public function noteable()
{
return $this->morphTo();
}
2016-10-23 05:42:44 -05:00
}