Jul 2, 2020
2
Level 5
Creating an Accessor need guidance
I have two cruds and want to create an accessor to be used on queries to return boolean and not really sure how to do it.
Have the following details for the models
// doctype.php
protected $fillable = [
'title',
'slug',
];
public function Docs()
{
return $this->belongsToMany(Doc::class);
}
// doc.php
protected $fillable = [
'published',
'set_name',
'industry',
'slug',
'status_id',
];
public function Doctypes()
{
return $this->belongsToMany(DocType::class);
}
I need a doc scope that will query the doctype and @if current doc has a doctype wth id == 2 return true @else return false @endif
Like i said i have never created one before and could use your help.
Thank you
Please or to participate in this conversation.