Files
monica/app/Models/User/Changelog.php
T
Régis FreydandGitHub 29197090a7 Restructure where models are stored (#1476)
The idea is to clean the repository a little bit by moving models into their respective folders.
2018-06-14 20:49:12 -04:00

46 lines
903 B
PHP

<?php
namespace App\Models\User;
use Parsedown;
use App\Helpers\DateHelper;
use Illuminate\Database\Eloquent\Model;
class Changelog extends Model
{
/**
* The attributes that aren't mass assignable.
*
* @var array
*/
protected $guarded = ['id'];
/**
* Get the user records associated with the tag.
*/
public function users()
{
return $this->belongsToMany(User::class)->withPivot('read', 'upvote')->withTimestamps();
}
/**
* Return the markdown parsed description.
*
* @return string
*/
public function getDescriptionAttribute($value)
{
return (new Parsedown())->text($value);
}
/**
* Return the created_at date in a friendly format.
*
* @return string
*/
public function getCreatedAtAttribute($value)
{
return DateHelper::getShortDate($value);
}
}