12345678910111213141516171819202122232425262728 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class Article extends Model
- {
- use SoftDeletes;
- const STATUS_DRAFT = 0;
- const STATUS_PENDING = 1;
- const STATUS_PUBLISHED = 2;
- const STATUS_ARCHIVE = 3;
- function scopePending($query) {
- $query->where("status", static::STATUS_PENDING);
- }
- function scopePublished($query) {
- $query->where("status", static::STATUS_PUBLISHED);
- }
- function comments() {
- return $this->morphMany(Comment::class, "commentable");
- }
- }
|