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
|
|
|
|
2020-09-13 17:00:45 +01:00
|
|
|
use Eloquent;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
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;
|
2020-09-13 17:00:45 +01:00
|
|
|
use Illuminate\Support\Carbon;
|
2017-10-10 15:58:07 +01:00
|
|
|
|
2020-02-22 11:06:43 +00:00
|
|
|
/**
|
2020-09-13 17:22:52 +01:00
|
|
|
* App\Models\Bookmark.
|
2020-02-22 11:06:43 +00:00
|
|
|
*
|
|
|
|
* @property int $id
|
|
|
|
* @property string $url
|
|
|
|
* @property string|null $name
|
|
|
|
* @property string|null $content
|
|
|
|
* @property string|null $screenshot
|
|
|
|
* @property string|null $archive
|
|
|
|
* @property array|null $syndicates
|
2020-09-13 17:00:45 +01:00
|
|
|
* @property Carbon|null $created_at
|
|
|
|
* @property Carbon|null $updated_at
|
2020-02-22 11:06:43 +00:00
|
|
|
* @property-read string $longurl
|
2020-09-13 17:00:45 +01:00
|
|
|
* @property-read Collection|Tag[] $tags
|
2020-02-22 11:06:43 +00:00
|
|
|
* @property-read int|null $tags_count
|
2020-09-13 17:00:45 +01:00
|
|
|
* @method static Builder|Bookmark newModelQuery()
|
|
|
|
* @method static Builder|Bookmark newQuery()
|
|
|
|
* @method static Builder|Bookmark query()
|
|
|
|
* @method static Builder|Bookmark whereArchive($value)
|
|
|
|
* @method static Builder|Bookmark whereContent($value)
|
|
|
|
* @method static Builder|Bookmark whereCreatedAt($value)
|
|
|
|
* @method static Builder|Bookmark whereId($value)
|
|
|
|
* @method static Builder|Bookmark whereName($value)
|
|
|
|
* @method static Builder|Bookmark whereScreenshot($value)
|
|
|
|
* @method static Builder|Bookmark whereSyndicates($value)
|
|
|
|
* @method static Builder|Bookmark whereUpdatedAt($value)
|
|
|
|
* @method static Builder|Bookmark whereUrl($value)
|
|
|
|
* @mixin Eloquent
|
2020-02-22 11:06:43 +00:00
|
|
|
*/
|
2017-10-10 15:58:07 +01:00
|
|
|
class Bookmark extends Model
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = ['url', 'name', 'content'];
|
|
|
|
|
2017-11-17 14:25:30 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2018-01-15 14:02:13 +00:00
|
|
|
*
|
2020-02-22 11:06:43 +00:00
|
|
|
* @return 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.
|
2018-01-15 14:02:13 +00:00
|
|
|
*
|
|
|
|
* @return string
|
2017-10-13 13:45:57 +01:00
|
|
|
*/
|
2018-01-15 14:02:13 +00: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
|
|
|
}
|