<?php
namespace App;

use Illuminate\Database\Eloquent\Model;

class Paste extends Model
{
    protected $fillable = ['id', 'link', 'title', 'content', 'views', 'created_by', 'blacklist', 'fingerprint', 'password', 'unlisted', 'private', 'flagged', 'flagdate'];


    public function getIcons(){
        $icons = '';
        if(!is_null($this->password)){
            $icons .= '<span class="material-icons paste-icon" title="Password protected">password</span>';
        }
        if($this->private){
            $icons .= '<span class="material-icons paste-icon" title="Private">lock</span>';
        }
        if($this->unlisted){
            $icons .= '<span class="material-icons paste-icon" title="Unlisted">visibility_off</span>';
        }
        
        return $icons . " ";
    }

    public function getComments(){
        $comments = DB::table('comments')->where('doxId', $this->id)->get();
        return $comments;
    }
}