2017-10-10 15:58:07 +01:00
|
|
|
<?php
|
|
|
|
|
2018-01-15 14:02:13 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-12-19 16:00:42 +00:00
|
|
|
namespace App\Models;
|
2017-10-10 15:58:07 +01:00
|
|
|
|
2022-11-26 10:50:19 +00:00
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
2020-10-19 19:41:50 +01:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2017-10-10 15:58:07 +01:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2020-02-22 11:06:43 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
2017-10-10 15:58:07 +01:00
|
|
|
|
|
|
|
class Bookmark extends Model
|
|
|
|
{
|
2020-10-19 19:41:50 +01:00
|
|
|
use HasFactory;
|
|
|
|
|
2023-02-18 09:34:57 +00:00
|
|
|
/** @var array<int, string> */
|
2017-10-10 15:58:07 +01:00
|
|
|
protected $fillable = ['url', 'name', 'content'];
|
|
|
|
|
2023-02-18 09:34:57 +00:00
|
|
|
/** @var array<string, string> */
|
2017-11-17 14:25:30 +00:00
|
|
|
protected $casts = [
|
|
|
|
'syndicates' => 'array',
|
|
|
|
];
|
|
|
|
|
2023-02-18 09:34:57 +00:00
|
|
|
public function tags(): BelongsToMany
|
2017-10-10 15:58:07 +01:00
|
|
|
{
|
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
|
|
|
|
2022-11-26 10:50:19 +00:00
|
|
|
protected function longurl(): Attribute
|
2017-10-13 13:45:57 +01:00
|
|
|
{
|
2022-11-26 10:50:19 +00:00
|
|
|
return Attribute::get(
|
|
|
|
get: fn () => config('app.url') . '/bookmarks/' . $this->id,
|
|
|
|
);
|
2017-10-13 13:45:57 +01:00
|
|
|
}
|
2017-10-10 15:58:07 +01:00
|
|
|
}
|