<?php
namespace Koselig\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Post extends Model
{
public $table = DB_PREFIX . 'posts';
public $primaryKey = 'ID';
public function scopePostType($query, $name)
{
return $query->where('post_type', $name);
}
public function scopePublished($query)
{
return $query->where('post_status', 'publish');
}
public function meta()
{
return $this->hasMany(Meta::class);
}
public function author()
{
return $this->belongsTo(User::class, 'post_author');
}
}