status == self::STATUS_DRAFT; } /** * Is current content visible for all visitors? * * @return bool */ public function isPublic() { return $this->status == self::STATUS_PUBLIC; } /** * Is current content visible only for logged users? * * @return bool */ public function isProtected() { return $this->status == self::STATUS_PROTECTED; } /** * Is current content visible for logged user OR for everyone? * * @return bool */ public function isVisible() { return $this->isPublic() || $this->isProtected(); } /** * Mark relationship with its historical records * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function history() { return $this->hasMany(\App\Models\Content\ContentHistory::class); } /** * Mark relationship with users table * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function author() { return $this->belongsTo(User::class, 'user_id'); } /** * Related files to content page * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function files() { return $this->belongsToMany(File::class, 'contents_has_files'); } public function category() { return $this->belongsTo(Category::class); } }