jonnybarnes.uk/app/Models/Bookmark.php

47 lines
877 B
PHP
Raw Normal View History

2017-10-10 15:58:07 +01:00
<?php
declare(strict_types=1);
2017-12-19 16:00:42 +00:00
namespace App\Models;
2017-10-10 15:58:07 +01:00
use Illuminate\Database\Eloquent\Model;
class Bookmark extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['url', 'name', 'content'];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'syndicates' => 'array',
];
2017-10-10 15:58:07 +01:00
/**
* The tags that belong to the bookmark.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
2017-10-10 15:58:07 +01:00
*/
public function tags()
{
2017-12-19 16:00:42 +00:00
return $this->belongsToMany('App\Models\Tag');
2017-10-10 15:58:07 +01:00
}
2017-10-13 13:45:57 +01:00
/**
2017-10-13 19:50:22 +00:00
* The full url of a bookmark.
*
* @return string
2017-10-13 13:45:57 +01:00
*/
public function getLongurlAttribute(): string
2017-10-13 13:45:57 +01:00
{
return config('app.url') . '/bookmarks/' . $this->id;
}
2017-10-10 15:58:07 +01:00
}