38 lines
779 B
PHP
38 lines
779 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Articles extends Model
|
|
{
|
|
public function category()
|
|
{
|
|
return $this->belongsTo(ArticlesCategories::class, 'category_id');
|
|
}
|
|
|
|
public function recipes()
|
|
{
|
|
return $this->belongsToMany(Recipes::class);
|
|
}
|
|
|
|
public function answers()
|
|
{
|
|
return $this->hasMany(SurveysAnswers::class, 'article_id');
|
|
}
|
|
|
|
public function notifiable()
|
|
{
|
|
return $this->morphOne(Notifications::class, 'notifiable');
|
|
}
|
|
|
|
public function surveysAnswersUsers()
|
|
{
|
|
return $this->hasManyThrough(
|
|
SurveysAnswers::class,
|
|
SurveysAnswersUsers::class,
|
|
'survey_answer_id',
|
|
'article_id'
|
|
);
|
|
}
|
|
}
|