Article Model
class Articles extends Model
{
protected $fillable = ['id','title', 'body', 'students_id', 'created_at', 'updated_at'];
protected $table = 'articles';
public function students(){
return $this->belongsTo('App\Students');
}
public function categories(){
return $this->belongsTo('App\Categories');
}
}
Code 01 : $articles = Articles::with('students')->with('categories')->get();
Code 02 : $articles = Articles::get();
Whatever code(01 or 02) I used I got the object which join article,categories and students tables.
So my question is what is the purpose of with('students')->with('categories')
part?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire