|
10 | 10 | use App\Traits\HasTags;
|
11 | 11 | use App\Traits\Reactable;
|
12 | 12 | use App\Traits\RecordsActivity;
|
13 |
| -use Carbon\Carbon; |
14 | 13 | use CyrildeWit\EloquentViewable\Contracts\Viewable;
|
15 | 14 | use CyrildeWit\EloquentViewable\InteractsWithViews;
|
16 | 15 | use Illuminate\Database\Eloquent\Builder;
|
|
25 | 24 | * @property string $title
|
26 | 25 | * @property string $slug
|
27 | 26 | * @property string $body
|
| 27 | + * @property string | null $canonical_url |
| 28 | + * @property bool $show_toc |
| 29 | + * @property bool $is_pinned |
| 30 | + * @property int $is_sponsored |
| 31 | + * @property int | null $tweet_id |
28 | 32 | * @property int $user_id
|
29 |
| - * @property User $user |
| 33 | + * @property \Illuminate\Support\Carbon|null $published_at |
| 34 | + * @property \Illuminate\Support\Carbon|null $submitted_at |
| 35 | + * @property \Illuminate\Support\Carbon|null $approved_at |
| 36 | + * @property \Illuminate\Support\Carbon|null $shared_at |
| 37 | + * @property \Illuminate\Support\Carbon|null $declined_at |
| 38 | + * @property \Illuminate\Support\Carbon|null $sponsored_at |
| 39 | + * @property \Illuminate\Support\Carbon $created_at |
| 40 | + * @property \Illuminate\Support\Carbon $updated_at |
| 41 | + * @property-read User $user |
| 42 | + * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activity |
| 43 | + * @property-read int|null $activity_count |
| 44 | + * @property-read \Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection<int, \Spatie\MediaLibrary\MediaCollections\Models\Media> $media |
| 45 | + * @property-read int|null $media_count |
| 46 | + * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Reaction> $reactions |
| 47 | + * @property-read int|null $reactions_count |
| 48 | + * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Tag> $tags |
| 49 | + * @property-read int|null $tags_count |
| 50 | + * @property-read \Illuminate\Database\Eloquent\Collection<int, \CyrildeWit\EloquentViewable\View> $views |
| 51 | + * @property-read int|null $views_count |
| 52 | + * |
| 53 | + * @method static \Illuminate\Database\Eloquent\Builder|Article approved() |
| 54 | + * @method static \Illuminate\Database\Eloquent\Builder|Article awaitingApproval() |
| 55 | + * @method static \Illuminate\Database\Eloquent\Builder|Article declined() |
| 56 | + * @method static \Database\Factories\ArticleFactory factory($count = null, $state = []) |
| 57 | + * @method static \Illuminate\Database\Eloquent\Builder|Article forTag(string $tag) |
| 58 | + * @method static \Illuminate\Database\Eloquent\Builder|Article newModelQuery() |
| 59 | + * @method static \Illuminate\Database\Eloquent\Builder|Article newQuery() |
| 60 | + * @method static \Illuminate\Database\Eloquent\Builder|Article notApproved() |
| 61 | + * @method static \Illuminate\Database\Eloquent\Builder|Article notDeclined() |
| 62 | + * @method static \Illuminate\Database\Eloquent\Builder|Article notPinned() |
| 63 | + * @method static \Illuminate\Database\Eloquent\Builder|Article notPublished() |
| 64 | + * @method static \Illuminate\Database\Eloquent\Builder|Article notShared() |
| 65 | + * @method static \Illuminate\Database\Eloquent\Builder|Article orderByUniqueViews(string $direction = 'desc', $period = null, ?string $collection = null, string $as = 'unique_views_count') |
| 66 | + * @method static \Illuminate\Database\Eloquent\Builder|Article orderByViews(string $direction = 'desc', ?\CyrildeWit\EloquentViewable\Support\Period $period = null, ?string $collection = null, bool $unique = false, string $as = 'views_count') |
| 67 | + * @method static \Illuminate\Database\Eloquent\Builder|Article pinned() |
| 68 | + * @method static \Illuminate\Database\Eloquent\Builder|Article popular() |
| 69 | + * @method static \Illuminate\Database\Eloquent\Builder|Article published() |
| 70 | + * @method static \Illuminate\Database\Eloquent\Builder|Article query() |
| 71 | + * @method static \Illuminate\Database\Eloquent\Builder|Article recent() |
| 72 | + * @method static \Illuminate\Database\Eloquent\Builder|Article shared() |
| 73 | + * @method static \Illuminate\Database\Eloquent\Builder|Article sponsored() |
| 74 | + * @method static \Illuminate\Database\Eloquent\Builder|Article submitted() |
| 75 | + * @method static \Illuminate\Database\Eloquent\Builder|Article trending() |
| 76 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereApprovedAt($value) |
| 77 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereBody($value) |
| 78 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereCanonicalUrl($value) |
| 79 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereCreatedAt($value) |
| 80 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereDeclinedAt($value) |
| 81 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereId($value) |
| 82 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereIsPinned($value) |
| 83 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereIsSponsored($value) |
| 84 | + * @method static \Illuminate\Database\Eloquent\Builder|Article wherePublishedAt($value) |
| 85 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereSharedAt($value) |
| 86 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereShowToc($value) |
| 87 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereSlug($value) |
| 88 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereSponsoredAt($value) |
| 89 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereSubmittedAt($value) |
| 90 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereTitle($value) |
| 91 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereTweetId($value) |
| 92 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereUpdatedAt($value) |
| 93 | + * @method static \Illuminate\Database\Eloquent\Builder|Article whereUserId($value) |
| 94 | + * @method static \Illuminate\Database\Eloquent\Builder|Article withViewsCount(?\CyrildeWit\EloquentViewable\Support\Period $period = null, ?string $collection = null, bool $unique = false, string $as = 'views_count') |
30 | 95 | */
|
31 | 96 | final class Article extends Model implements HasMedia, ReactableInterface, Viewable
|
32 | 97 | {
|
@@ -111,31 +176,6 @@ public function registerMediaCollections(): void
|
111 | 176 | ->acceptsMimeTypes(['image/jpg', 'image/jpeg', 'image/png']);
|
112 | 177 | }
|
113 | 178 |
|
114 |
| - public function submittedAt(): ?Carbon |
115 |
| - { |
116 |
| - return $this->submitted_at; |
117 |
| - } |
118 |
| - |
119 |
| - public function approvedAt(): ?Carbon |
120 |
| - { |
121 |
| - return $this->approved_at; |
122 |
| - } |
123 |
| - |
124 |
| - public function createdAt(): ?Carbon |
125 |
| - { |
126 |
| - return $this->created_at; |
127 |
| - } |
128 |
| - |
129 |
| - public function sponsoredAt(): ?Carbon |
130 |
| - { |
131 |
| - return $this->sponsored_at; |
132 |
| - } |
133 |
| - |
134 |
| - public function publishedAt(): ?Carbon |
135 |
| - { |
136 |
| - return $this->published_at; |
137 |
| - } |
138 |
| - |
139 | 179 | public function isSubmitted(): bool
|
140 | 180 | {
|
141 | 181 | return ! $this->isNotSubmitted();
|
@@ -178,7 +218,7 @@ public function isNotDeclined(): bool
|
178 | 218 |
|
179 | 219 | public function isPublished(): bool
|
180 | 220 | {
|
181 |
| - return ! $this->isNotPublished() && ($this->publishedAt() && $this->publishedAt()->lessThanOrEqualTo(now())); |
| 221 | + return ! $this->isNotPublished() && ($this->published_at && $this->published_at->lessThanOrEqualTo(now())); |
182 | 222 | }
|
183 | 223 |
|
184 | 224 | public function isNotPublished(): bool
|
|
0 commit comments