<?php

class ProjectNews extends Eloquent {
  
	protected $table    	 = 'project_news';
	protected $softDelete	 = true;
	protected $guarded		 = array();
	public static $rules	 = array();

	public function project() {
		return $this->belongsTo('Project');
	}
  public function projectNewsTypes() {
		return $this->belongsTo('ProjectNewsTypes', 'type_id');
	}
	
	public function sendNews($userForNews) {
		$subject						 = 'Новости Legaton. ';
		$email							 = $userForNews->email;
		$view								 = 'emails.project_news.news';
		$data['name']			   = $this->name;
		$data['content']		 = $this->content;
		
    //Mail::pretend();
		Mail::queue($view, $data, function($message) use($email, $subject) {
			$message->to($email)->subject($subject);
		});
		
	}
	
}
