|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Dimitri BOUTEILLE (https://github.com/dimitriBouteille) |
| 4 | + * See LICENSE.txt for license details. |
| 5 | + * |
| 6 | + * Author: Dimitri BOUTEILLE <[email protected]> |
| 7 | + */ |
| 8 | + |
| 9 | +namespace Dbout\WpOrm\Models\Multisite; |
| 10 | + |
| 11 | +use Carbon\Carbon; |
| 12 | +use Dbout\WpOrm\Orm\AbstractModel; |
| 13 | +use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 14 | +use Illuminate\Database\Eloquent\Relations\HasOne; |
| 15 | + |
| 16 | +/** |
| 17 | + * @method int getSiteId() |
| 18 | + * @method Blog setSiteId(int $siteId) |
| 19 | + * @method string getDomain() |
| 20 | + * @method Blog setDomain(string $domain) |
| 21 | + * @method string getPath() |
| 22 | + * @method Blog setPath(string $path) |
| 23 | + * @method Carbon getRegistered() |
| 24 | + * @method Blog setRegistered($registered) |
| 25 | + * @method Carbon getLastUpdated() |
| 26 | + * @method Blog setLastUpdated($lastUpdated) |
| 27 | + * @method bool getPublic() |
| 28 | + * @method Blog setPublic(bool $public) |
| 29 | + * @method bool getArchived() |
| 30 | + * @method Blog setArchived(bool $archived) |
| 31 | + * @method bool getMature() |
| 32 | + * @method Blog setMature(bool $mature) |
| 33 | + * @method bool getSpam() |
| 34 | + * @method Blog setSpam(bool $spam) |
| 35 | + * @method bool getDeleted() |
| 36 | + * @method Blog setDeleted(bool $deleted) |
| 37 | + * @method int getLangId() |
| 38 | + * @method Blog setLangId(int $langId) |
| 39 | + * |
| 40 | + * @property-read Site $site |
| 41 | + * @property-read BlogVersion|null $version |
| 42 | + */ |
| 43 | +class Blog extends AbstractModel |
| 44 | +{ |
| 45 | + public const CREATED_AT = self::REGISTERED; |
| 46 | + public const UPDATED_AT = self::LAST_UPDATED; |
| 47 | + |
| 48 | + final public const BLOG_ID = 'blog_id'; |
| 49 | + final public const SITE_ID = 'site_id'; |
| 50 | + final public const DOMAIN = 'domain'; |
| 51 | + final public const PATH = 'path'; |
| 52 | + final public const REGISTERED = 'registered'; |
| 53 | + final public const LAST_UPDATED = 'last_updated'; |
| 54 | + final public const PUBLIC = 'public'; |
| 55 | + final public const ARCHIVED = 'archived'; |
| 56 | + final public const MATURE = 'mature'; |
| 57 | + final public const SPAM = 'spam'; |
| 58 | + final public const DELETED = 'deleted'; |
| 59 | + final public const LANG_ID = 'lang_id'; |
| 60 | + |
| 61 | + protected $primaryKey = self::BLOG_ID; |
| 62 | + |
| 63 | + protected bool $useBasePrefix = true; |
| 64 | + |
| 65 | + protected $casts = [ |
| 66 | + self::BLOG_ID => 'int', |
| 67 | + self::SITE_ID => 'int', |
| 68 | + self::REGISTERED => 'datetime', |
| 69 | + self::LAST_UPDATED => 'datetime', |
| 70 | + self::PUBLIC => 'bool', |
| 71 | + self::ARCHIVED => 'bool', |
| 72 | + self::MATURE => 'bool', |
| 73 | + self::SPAM => 'bool', |
| 74 | + self::DELETED => 'bool', |
| 75 | + self::LANG_ID => 'int', |
| 76 | + ]; |
| 77 | + |
| 78 | + protected $table = 'blogs'; |
| 79 | + |
| 80 | + public function site(): BelongsTo |
| 81 | + { |
| 82 | + return $this->belongsTo(Site::class, self::SITE_ID); |
| 83 | + } |
| 84 | + |
| 85 | + public function version(): HasOne |
| 86 | + { |
| 87 | + return $this->hasOne(BlogVersion::class, BlogVersion::BLOG_ID); |
| 88 | + } |
| 89 | +} |
0 commit comments