public function getVendor($vendorId, $fields = null, $relationships = null) { $query = Vendor::where('id', '=', $vendorId); if (isset($fields)) { $query->select($fields); } if (isset($relationships)) { $query->with($relationships); } $vendor = $query->first(); return $vendor; }