<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class AnuncioIntranet extends Model
{
    protected $table = 'anuncio_intranet';

    protected $appends = ['id_rol'];

    protected $fillable = [
        'nombre',
        'descripcion',
        'pathimagen',
        'id_responsable',
        'urlimagen',
        'activo',
        'fecha_inicio',
        'fecha_fin'
    ];

    public function roles(){
        return $this->belongsToMany('App\Model\Role','anuncio_rol','id_anuncio','id_rol')->pluck('id_rol')->all();
    }

    public function getRolesIdsAttribute()
    {
        return $this->roles->pluck('id_rol');
    }
}
