<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/5
 * Time: 16:24
 */
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Post extends Model
{
    //
    use SoftDeletes;
    protected $table = 'post';
    protected $guarded = [];

    public function imgs()
    {
        return $this->hasMany('App\Models\PostImgs', 'post_id', 'id');
    }

    public function data()
    {
        return $this->hasOne('App\Models\PostData', 'post_id', 'id');
    }

    public function topic()
    {
        return Topic::whereIn('id', explode(',', $this->topic_ids))->pluck('name', 'id');
    }

}