<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;

class Article extends Model
{
    protected $fillable = ['user_id', 'body', 'status'];

    public function like()
    {
        return Like::where('user_id', Auth::id())->where('post_id', $this->id)->where('type', 'article')->first();
    }

    public function likes_count()
    {
        return Like::where('post_id', $this->id)->where('type', 'article')->where('status', 1)->count();
    }
}
