Question 1 : is this eloquent or query builder ?
$q = Topic::from('topic')
->join( 'subject', 'subject.id', '=', 'topic.subject_id')
->select( 'topic.*',
'subject.name as subject_name',
)
->get();
Question 2 : if question 1 is eloquent, then is this the right query builder ?
$q = DB::table('topic')
->join( 'subject', 'subject.id', '=', 'topic.subject_id')
->select( 'topic.*',
'subject.name as subject_name',
)
->get();
Question 3 : if in my Topic model, have a function to call topic image path, how do i access it with Query Builder from question 2 ?
is there a better way to access my topic image?
class Topic extends Model
{
public function image()
{
//example
return $pathImage;
}
}
thanks if anyone can help me answer my question im confused about the eloquent and query builder